Values in [UXF_Rig] don't seem to stick
mrstruijk opened this issue · comments
Hi!
I noticed in my main project that if I change certain value prior to entering PlayMode in the Rig, they don't seem to affect the behaviour of the Rig.
For instance, if I toggle "Don't Destroy", it still gets destroyed when loading a new scene. I can get the Rig to persist, if I add my own DontDestroyOnLoad script to the object. The code is exactly the same as the one in Session.cs, which confuses me a bit.
Also, if I first set the Settings Mode in [UXF_UI] to 'Download from URL', and I make a spelling error in the URL (e.g. change the default URL to 'https://giste...' instead of 'https://gist...'), I naturally get an Internal Server Error, which is expected. However, if I then change the Settings Mode to 'Empty', without first fixing my typo, I still get the same Server Error. That only changes if I first fix the typo, and only then set the Settings Mode to 'Empty'. It looks like the Rig always wants to connect to the URL, regardless of the mode it's on.
On a brand new Unity Project, when following the same steps, I don't seem to have these issues.
Things I've changed / tried in my main project:
- I've added ASMDefs for the UXF and the UXF.tests (also did this in the new test project, and there it's no prob).
- Changed the script execution order to have Session be running first. No luck.
- Disabled the SessionEditor, thought that maybe the Editor was not updating the values correctly. No luck.
I'm running UXF Version 2.3.6 on Unity 2021.2.11.
What else can I try to solve this?
Best,
Maarten
To add to this: If I put the Rig not in the first scene, but in one of the subsequent ones, the DontDestroyOnLoad works fine... The minor issue with the SettingsMode remains the same however.
Interesting! I cannot replicate in any of the example scenes.
Question: When you change a value as you described, then save/close the scene (or Unity), and re-open, does the value stick?
My first thought was to enable these settings in Project Settings -> Editor
I suspected it could be an issue related to initialisation performed in Edit mode. But I cannot replicate the behaviour either way.
To further debug, could you see if the Awake methods are being called correctly in UXF.Session & UXF.UIController components? It should run when pressing play. Just slip a Debug.Log in the Awake methods:
Well you're right, the Awake doesn't get run from the first scene at all.
In Session, I added this to Awake:
I added a Session Generator which lives on the Rig for now:
I added the Rig to both first and second scene, and named them '[UXF_Rig] in first scene' and '[UXF_Rig] in second scene'
When going from first to second scene, you can see that the Session gets started and killed based on the first scene's SessionGenerator loading and unloading (which also unloads the Rig), and then only in the second scene does Awake get called...:
I have my own DDOL class that I often use:
Now if I add my own DDOL class to the Rig in the first scene (but not the second), you see that the first Rig is not destroyed, but the second Rig is based on the Instance checker already in UXF's Session:
I don't mind keeping the Rig in the second scene for now. It works fine for my purposes. It's just that I'm curious, and have a tendency to get stuck on "this should work but it doesn't"-issues :).
I'll look for a better solution to this, but in the meantime I recommend people enable ReloadDomain and ReloadScene.
In UXF v2.4.2 you can now fix this with the UXF Wizard compatibility checker. In the future I hope this works without the need for these settings.