using UnityEngine;
public class p : MonoBehaviour
{
public GameObject target;
public GameObject current;
public GameObject goTo;
private void OnEnable()
{
Destroy(target.GetComponent<e>());
e execution = target.AddComponent<e>();
execution.current = current;
execution.goTo = goTo;
}
}
using UnityEngine;
public class e : MonoBehaviour
{
public GameObject current;
public GameObject goTo;
private void OnMouseDown()
{
Debug.Log("clickregisted on object");
this.goTo.SetActive(true);
// this.current.SetActive(false);
}
}
当e.cs ln.:16未评论时,统一只会崩溃 没错 不加注释时,在所有游戏对象上运行setActive。