Loading a prefab and creating a unique instance of that game object

Question

so i want to load a prefab gameobject using resources.load and use that to create a unique game object based on the prefab that is not a reference to the prefab. Anyone have an idea how to do this? thanks!

Posted Jul 9, 2019, 6:48 AM UTC

23
SilentSin26Animancer, InspectorGadgets, Weaver, UltEvents :redditgold:•

What do you mean by "not a reference to the prefab"? A clone created by Instantiate at will not have any reference to the prefab.

4
reddKidneyOP•

yea im currently just using instantiate it works but it just feels sloppy.

I want there to be a way to use resource to create a unique object copy into a script variable that is not also added to the scene but can be at my discretion. I can load it as part of a gameobject and modify it separately before instantiating when its needed.

1
SilentSin26Animancer, InspectorGadgets, Weaver, UltEvents :redditgold:•

I'm still not sure what the problem is.

If you want to load a resource without adding it to the scene, just use Resources.Load and keep a reference to the object it returns.

If you want to create an instance of that object, use Instantiate.

If you want the instance to not be active in the scene, use GameObject.SetActive to disable it.

6