My prefab will not retain the move joystick reference. If I add the reference back while running, the everything works, but the instantiated prefab will lost the reference once I delete it from the screen, or run the project.
I was sure to hit Apply on the prefab, but essentially, its acting as though I didn't.
the reference is added here...
but gone on the instantiated object...
Note that the ship object that I drag into the scene still has the reference, but the instantiated ship does not.
I've tried this with the joystick container as a prefab and not a prefab.
Prefabs cannot maintain references to objects in the scene, as when they get instantiated, there's no guaranteed that that object still exists.
You will have to assign the reference to the script when you instantiate the prefab. You can do this by calling instance_obj.GetComponent<Move>().moveJoystick = ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With