c# gameobject assignement

Updated on September 7, 2017 in  [R] Scripts
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
4 on August 28, 2017

Hi, please is there anyway to assign a disabled gameObject on the scene to a script in a prefab? (in c#)

i want to enable and disable it from the script (after Instantiating the prefab of course).

  • Liked by
Reply
3 on August 28, 2017

First, enable the disabled gameObject. Then, drag it into the project window to create a prefab of it. Then, drag your newly created prefab onto the other prefab with the script….

on August 28, 2017

i don’t want to Instantiate the gameobject.

 

on August 28, 2017

Can you make the object active/enabled slightly before you make your assignment to the script?

 

 Assigning an object to a script (from within the scene) requires the object to be part of the scene (thus active). If it is inactive, it basically does not exist. Using the objects as prefabs may be your best option (despite a possible rework of your solution).

 

What is it exactly that you are trying to do?

on September 7, 2017

So sorry for the late reply,

i want to activate a losing panel from a script that is on a car (i have to instantiate the car because of some other reasons).

Show more replies
  • Liked by
Reply
Cancel