【发布时间】:2015-10-26 15:44:11
【问题描述】:
我想要这样的东西。
ComponentTest.cs - 此脚本附加到场景中的空游戏对象。
public class ComponentTest : MonoBehaviour {
public GameObject boxPrefab;
void Start () {
GameObject temp = Instantiate(boxPrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject;
temp.GetComponent<PrefabBox> ().go = gameObject.GetComponent<ComponentTest>().Yes();
}
public void Yes(){
print("yes");
}
}
和 PrefabBox.cs - 此脚本附加到预制件。
public class PrefabBox : MonoBehaviour {
public GameObject go;
void Start () {
go ();
}
}
我认为这是错误:
成员 `PrefabBox.go' 不能用作方法或委托
【问题讨论】:
标签: c# unity3d gameobject