When I instantiate a game object all of its references to other game objects that I have referenced in the editor are gone. How can I solve it
If you want to instantiate an object that maintains all references, make sure that those references are to prefabs, and that those prefabs are in the project folder, not in the scene view (Drag objects from your scene to the folders to make the prefab).
All assets you are refencing should be blue denoting they are prefabs, all of them should be a project folders under the “Resources” folder. So prefabs linking to other prefabs that all exist in these folders.
The script that you are generating the object from, when you click the reference to the script you want to create, it should take you to your project folder, not the scene. And when you click your references on that asset, they should link to things in the projectHere’s a quick reference.
See the duel wielding fish on the right side in the inspector? When I click it it shows me that it’s actually in the folder hierarchy and not in the scene.
I suspect you may need to auto locate assets in your scene. One simple and beginner means of doing this is to search by tag.
Hope that helps.
You might need to give more context under what circumstances this happens.
When you instance a prefab, any references to another assets should remain, and any references to game objects or components within its hierarchy should point to the corresponding copy in the instanced prefab.
Do note that prefabs, or anything in your project files, cannot reference objects in your scenes.