Seeing that you made some fixes on menus, I updated Adventure Creator to Last Update (1.81.7), (just to check), added your suggested fix again, and the number of time of lost references on runtime have diminished even with Visibility hidden at start when creating new graphic elements, so that's a great start.
It stills breaks (don't find the element) if I copy and paste the element in the Menu Editor.
I'll keep working on it to check what works now and what not.
Ok.... So no. Not always that is invisible at start works. For some reason that works on some elements and others not.
With an element that was not found being invisible at start (while others they did), I made the the following change and tested:
I made a simple check;
-Graphic element Visible at start
-Hide element by Actionlist (cause Variable not reached to show it).
-Start the game. Check that is found and got hidden (the object is disabled in the AC instanced UI).
-Save the game.
-Close the game.
-Load the game. Open the menu.
-UI.Image cannot be found bug, cause the graphic element was disabled in the prefab so AC can't find it out.
So same problem.... Just that with the update it doesn't happen for all new elements. Other new elements with same behaviour like that are working.
1)yes, the menu is displayed at the time the elements are hidden (They're not hidden (if we're talking about sprite renderers disabled), the game objects are disabled, to be specific)
2)It happens in any case.
It may be worse than I originally thought.
Some testers were reporting one of the inventory views missing on loading old games after an update (with 1.85.5). I asked for a save game to see other things... And found that the inventory bug was there. Same behaviour with graphic elements; All button elements of the inventory were deactivated (when they should have even inventory elements on them). Stopped the runtime play, checked the prefab, and that inventory prefab had all buttons disabled. (So again, runtime play instanced bugged menus modifying original prefabs).
To be clear: When the inventory work, All inventory buttons game objects are enabled just empty/not visible if they have no inventory item.
When the bug is on, the inventory buttons game objects are fully disabled, like AC code were telling the game to disable the game objects because the Inventory behaviour was "disable" instead of "Clear Content", like other inventories that worked. So at least to fix that, I put the option to "Clear Content", so that way at least AC will not lose the references.
Quickly reproduced on those saves just closing and opening menus... menu having inventory slots, suddenly losing them (the buttons).
So the size of the bug is beyond what I expected. (I only started having that bug after loading that player save, never have it before. So the first time I loaded that save, I incorporated the losability of those references in the whole game.
As I hinted some times, These looks to me more of a Unity version bug than an AC version in the way it modifies original prefabs (and it works in many ways that is hard to just make a sample project without the 76 menus and all logic..). I may just check first to changing the project to another Unity version.
Were you testing the reproducibility in the provided Unity version?
I was, but I'm not so sure the Unity version is the cause.
Save games only reference Menu data by their ID - so once a fix is found it should work for old save files as well.
If AC is causing this, then it'll generally be down to either:
The linked UI object (i.e. a Graphic's Image component) being linked at runtime to the original Canvas prefab.
The linked UI object, originally linked to the prefab, is not updated to the runtime variant.
Two things to try, both inside AC's MenuGraphic script:
1) Inside the LoadUnityUI function, copy/paste:
Debug.Log ("Load UI components for menu " + _menu.title + ", element: " + title + ", canvas: " + canvas, canvas);
This'll show up in the Console for all Graphic elements. Clicking them will "ping" the Canvas involved - check that they ping the Canvas in the scene, not the prefab.
2) At the top, mark the uiImage and uiRawImage variables as non-serialized, i.e.:
What the non serialization of those elements is exactly doing? Maybe the non serialization makes them not saveable or something?
Right now all debug lines are pointing me to the instances on scene in all cases (quite handy debug line also).
I've been testing for a while, while making a new information menu (I need to make lots of those), and for now no reference is lost in any case, which is a change atribuible to the non serialization of them I guess?
In order to make long lasting save compatibility in my Early Access game, I don't rely on saving menu states (in 90% of cases), but on running all the Show and Hide logic every time a menu is open.
Now new graphic elements, starting hidden or shown, are not lost, and the code executes, but I have to spent some hours really testing real gameplay and changes and saving and loading in various states.
But suddenly (I guess because the update from 1.81.5 to 1.81.7), when naming saves, save names are not recorded. (I've been using the years old tutorial for the custom names, that just happened with this update)
I'll need more details - what save file handler / format are you using, if not the default, and do they appear correct after a restart? Please start a new thread for this.
Comments
Strange indeed. However, I can only re-iterate that I need files to work with, along with instructions on how to recreate the issue(s).
Seeing that you made some fixes on menus, I updated Adventure Creator to Last Update (1.81.7), (just to check), added your suggested fix again, and the number of time of lost references on runtime have diminished even with Visibility hidden at start when creating new graphic elements, so that's a great start.
It stills breaks (don't find the element) if I copy and paste the element in the Menu Editor.
I'll keep working on it to check what works now and what not.
Ok.... So no. Not always that is invisible at start works. For some reason that works on some elements and others not.
With an element that was not found being invisible at start (while others they did), I made the the following change and tested:
I made a simple check;
-Graphic element Visible at start
-Hide element by Actionlist (cause Variable not reached to show it).
-Start the game. Check that is found and got hidden (the object is disabled in the AC instanced UI).
-Save the game.
-Close the game.
-Load the game. Open the menu.
-UI.Image cannot be found bug, cause the graphic element was disabled in the prefab so AC can't find it out.
So same problem.... Just that with the update it doesn't happen for all new elements. Other new elements with same behaviour like that are working.
Thanks for the steps, but I just cannot recreate this issue.
Is the Menu displayed at the time the elements are hidden, and is the Menu Manager open also?
Please send the files involved - the Managers, the UI prefab, and the scene - along with instructions.
1)yes, the menu is displayed at the time the elements are hidden (They're not hidden (if we're talking about sprite renderers disabled), the game objects are disabled, to be specific)
2)It happens in any case.
It may be worse than I originally thought.
Some testers were reporting one of the inventory views missing on loading old games after an update (with 1.85.5). I asked for a save game to see other things... And found that the inventory bug was there. Same behaviour with graphic elements; All button elements of the inventory were deactivated (when they should have even inventory elements on them). Stopped the runtime play, checked the prefab, and that inventory prefab had all buttons disabled. (So again, runtime play instanced bugged menus modifying original prefabs).
To be clear: When the inventory work, All inventory buttons game objects are enabled just empty/not visible if they have no inventory item.
When the bug is on, the inventory buttons game objects are fully disabled, like AC code were telling the game to disable the game objects because the Inventory behaviour was "disable" instead of "Clear Content", like other inventories that worked. So at least to fix that, I put the option to "Clear Content", so that way at least AC will not lose the references.
Quickly reproduced on those saves just closing and opening menus... menu having inventory slots, suddenly losing them (the buttons).
So the size of the bug is beyond what I expected. (I only started having that bug after loading that player save, never have it before. So the first time I loaded that save, I incorporated the losability of those references in the whole game.
As I hinted some times, These looks to me more of a Unity version bug than an AC version in the way it modifies original prefabs (and it works in many ways that is hard to just make a sample project without the 76 menus and all logic..). I may just check first to changing the project to another Unity version.
Were you testing the reproducibility in the provided Unity version?
I was, but I'm not so sure the Unity version is the cause.
Save games only reference Menu data by their ID - so once a fix is found it should work for old save files as well.
If AC is causing this, then it'll generally be down to either:
Two things to try, both inside AC's MenuGraphic script:
1) Inside the LoadUnityUI function, copy/paste:
This'll show up in the Console for all Graphic elements. Clicking them will "ping" the Canvas involved - check that they ping the Canvas in the scene, not the prefab.
2) At the top, mark the uiImage and uiRawImage variables as non-serialized, i.e.:
What the non serialization of those elements is exactly doing? Maybe the non serialization makes them not saveable or something?
Right now all debug lines are pointing me to the instances on scene in all cases (quite handy debug line also).
I've been testing for a while, while making a new information menu (I need to make lots of those), and for now no reference is lost in any case, which is a change atribuible to the non serialization of them I guess?
In order to make long lasting save compatibility in my Early Access game, I don't rely on saving menu states (in 90% of cases), but on running all the Show and Hide logic every time a menu is open.
Now new graphic elements, starting hidden or shown, are not lost, and the code executes, but I have to spent some hours really testing real gameplay and changes and saving and loading in various states.
That's right. They'll be re-assigned at runtime anyway, so it should be safe to do so.
Give things a test, and if this change causes things to work, I'll consider making it an official change.
My testers are extensively playing, saving and loading, everything looks fixed now!
But suddenly (I guess because the update from 1.81.5 to 1.81.7), when naming saves, save names are not recorded. (I've been using the years old tutorial for the custom names, that just happened with this update)
I'll need more details - what save file handler / format are you using, if not the default, and do they appear correct after a restart? Please start a new thread for this.