immersivecognition / unity-experiment-framework

UXF - Framework for creating human behaviour experiments in Unity
https://immersivecognition.github.io/unity-experiment-framework/
MIT License
214 stars 41 forks source link

Values in [UXF_Rig] don't seem to stick #107

Closed mrstruijk closed 2 years ago

mrstruijk commented 2 years ago

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'm running UXF Version 2.3.6 on Unity 2021.2.11.

What else can I try to solve this?

Best, Maarten

mrstruijk commented 2 years ago

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.

jackbrookes commented 2 years ago

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 image 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:

image

mrstruijk commented 2 years ago

Well you're right, the Awake doesn't get run from the first scene at all.

In Session, I added this to Awake: Screenshot 2022-02-17 at 12 16 18

I added a Session Generator which lives on the Rig for now: Screenshot 2022-02-17 at 12 20 38

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...: Screenshot 2022-02-17 at 12 14 28

I have my own DDOL class that I often use: Screenshot 2022-02-17 at 12 22 33

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: Screenshot 2022-02-17 at 12 24 32

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 :).

mrstruijk commented 2 years ago

Now to your other point: Setting the Editor Options to 'Reload Scene' works wonders as well...!

This is without my own DDOL script enabled, but only having Reload Scene enabled: Screenshot 2022-02-17 at 12 32 20

With only Reload Domain enabled it doesn't work: Screenshot 2022-02-17 at 12 31 20

Both enabled works too obviously.

jackbrookes commented 2 years ago

I'll look for a better solution to this, but in the meantime I recommend people enable ReloadDomain and ReloadScene.

jackbrookes commented 2 years ago

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.

https://github.com/immersivecognition/unity-experiment-framework/wiki/Common-issues#general-compatibility.