using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ClickEvent : MonoBehaviour {
public GameObject[] cube1; //3D物体集合
private void Start()
{
//为相机添加3个组件
if (this.gameObject.GetComponent<PhysicsRaycaster>() == null) {
gameObject.AddComponent<PhysicsRaycaster>();
}
if (this.gameObject.GetComponent<EventSystem>() == null)
{
this.gameObject.AddComponent<EventSystem>();
}
if (this.gameObject.GetComponent<StandaloneInputModule>() == null)
{
gameObject.AddComponent<StandaloneInputModule>();
}
//为3D物体添加点击事件
for (int i = 0; i < cube1.Length; i++)
{
AddObjectClickEvent(cube1[i]);
}
}
public void