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).
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).
You can’t assign things from the scene to a script on a prefab and have it hold that reference. You’ll either have to create the reference when you instantiate the prefab or create another script that exist in the scene to hold the reference for you.
so can i assign it after instantiating the prefab with findGameObjectWithTag even if it’s disabled?
No
If you must have the gameobject inactive, consider making another object with a script that holds its reference, or keeping the object active but simply deactivating its components you don’t want active instead of the entire gameobject.
Ok i’ll try something like this. Thanks.