- Home /
Reference a Game Script in Prefab
Hi guys, It might be a stupid question but I could not figure it out..
I have created a cube, then created a prefab from it. I have also created a C# code for this prefab and attached it.
Then, I needed to reference a method in core class, so I ve written sth like:
public CoreScript core;
and used my method like core.MyMethod();
It was working fine until I deleted the object of this prefab in the hierarchy. I cannot attach anything to the Game Script object of the prefab. It always seems "None (Game Script)"
What is the best way to achieve this ? I mean, I don't want to drag this object into hierarchy at the first place, because it would be generated later, but I cannot attach Game Script without having an actual object on the hierarchy.
I think there is something wrong on my way to achieve my goal. I simply would like to have a prefab, which is going to be generated by code and would have access to another game script.
Thanks in advance for your kind support.
Deniz