- Home /
Canvas prefab references keep getting lost after Editor restart
When I restart editor, the references inside prefab which is using Canvas element is keep getting lost for some objects.
All references are lost - images are empty white spaces, script is not referencing children and text field get reset.
It happend with two objects:
First Object:
- Empty GameObject with script referencing both text fields
GameObject with 3D model
- Canvas
Image 1 referencing sprite from assets
Image 2 referencing other sprite from assets
Text Field 1
Text Field 2
Second Object: (ment to be child of Canvas)
- Empty Object with Canvas rendered and script referencing text fields
Image 1
Image 2
Text field 1
Text field 2
I somehow managed to make both prefabs work, but sometimes when I edit it and restart Editor, all references are lost (even the one which was working before) and I have to start from scratch.
I have used the same approach in different project and it was working as expected without any reference losses.
Any idea why it might be?
Thank you!
Just Ctrl + S (save scene). Project should be saved after closing editor.
Anyway other prefabs works fine :-/
I just had the same problem, my data in my canvas keeps resetting. Hope anyone has an solution.
Gr.
Answer by malkere · Aug 23, 2015 at 06:33 PM
I've had this when using data on usb devices where the editor would seemingly load before certain data made it to it, or after sleeping my laptop with unity still running, etc.
ultimately I stopped setting anything and everything in the editor. I do it all by script now using transform.FindChild. That way there is no chance of it ever failing. This brings up the problem of sometimes one scripts Awake() has yet to be called to set a public transform though another script wishes to use it. This too can be fixed via scripting or by changing the load order in the editor.
Your answer
Follow this Question
Related Questions
Prefab Invisible on Canvas 0 Answers
On Click paramaters disappear from button prefab? 5 Answers
Cannot Set Sorting Layer Name in Nested Canvas Prefab 0 Answers
How to set the UI Text position to be relative to his "grandfather" prefab 0 Answers
Disabling Canvas Prefab only turns off prefab, not in scene canvas 1 Answer