Hey Everybody,
I am instantiating a prefab using an editor script. Then, I am modifying the instantiated object (say, adding a rigidbody to it). This should work, but it’s actually modifying the prefab, rather than the instantiation of it. Am I missing something obvious here? Please help out. Here is a sample of the code:
UnityEngine.Object prefabObject = AssetDatabase.LoadAssetAtPath(newObjectFullPath, typeof(GameObject));
GameObject newObject = Instantiate(prefabObject) as GameObject;
newObject.AddComponent<Rigidbody2D>();
So, am I missing anything here? I am running this from an editor script, so maybe there is a bug there? I’ve read that people have made this work from editor scripts…
Thanks!