Я хочу что-то вроде этого.Мгновенная сборка должна вызывать функцию из главного сценария?
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();
}
}
Я получаю это как ошибку:
The member `PrefabBox.go' cannot be used as method or delegate