ArgumentException: The Scene is Not Loaded error

Discussion and help for Easy Save 3
Post Reply
el_nino
Posts: 1
Joined: Tue Jul 05, 2022 7:50 am

ArgumentException: The Scene is Not Loaded error

Post by el_nino »

Hi, I was wondering if anyone else was getting this. I keep getting this error message, and it's more annoying than anything else. It's always being displayed when the game is NOT in play mode, so of course it's not loaded, right? I can't make sense of it.

ES3errormsg.png
ES3errormsg.png (8.74 KiB) Viewed 1997 times

I've been getting it ever since I imported ES3 into my project, and it seems to post a new one of these messages every time I compile. It doesn't stop my program from running, and the ES3 commands seem to be working so far (from what I've tried). But you know how the annoyance gets whenever you look at your console and see error messages. ;)
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentException: The Scene is Not Loaded error

Post by Joel »

Hi there,

We've had no reports of this. Please could you post the full stack trace of the error?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
zamaroth
Posts: 2
Joined: Fri Sep 23, 2022 12:08 pm

Re: ArgumentException: The Scene is Not Loaded error

Post by zamaroth »

Hello,

I encountered the same problem and as this wasn't resolved, I can elaborate.

The problem is caused when building the app for Hololens using the MRTK. For some reason Scene cannot be accessed during build(also encountered here https://github.com/microsoft/MixedReali ... ssues/5895).

It is caused when calling Scene.GetRootGameObjects() which EasySave uses to get the easy save manager in multiple places(for example ./Scripts/ES3ReferenceMgrBase.cs, line 50).

I managed to fix it for me by replacing the logic of getting the manager with GameObject.Find("Easy Save 3 Manager").GetComponentInChildren<ES3ReferenceMgr>().
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentException: The Scene is Not Loaded error

Post by Joel »

Hi there, and thanks for the information.

It sounds like this is different to the issue in the original post as that stated that it happened outside of play mode, and not during build.

If you're able to replicate this I recommend reporting this to Unity as this would indicate an issue with their API.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Nightkin
Posts: 2
Joined: Mon Oct 03, 2022 8:21 am

Re: ArgumentException: The Scene is Not Loaded error

Post by Nightkin »

Hello,

I just signed up to chime in this thread, reporting the same issue.

In my game, I rely a lot on additive scenes and I like to load and unload scenes manually in edit mode to be able to test this or that feature immediately, without having to play a segment of the game first in order to reach the part that interests me. As a result, I have a lot of scenes in my hierarchy view, some of them are loaded, others aren't (but they're there so I don't forget about them). So this is a normal use case for some game devs at least.

Every time I save a prefab, or data inside a prefab, I get the same error. It's harmless but annoying and I'd like to stop seeing it. It comes from the call to scene.GetRootGameObjects() in ES3ReferenceMgrBase.GetManagerFromScene().

Presumably, Easy Save is trying to find a manager in all the open scenes (but open does not necessarily mean loaded) and gets an exception for all the unloaded scenes. I think there should be a test to check if a scene is loaded. I don't think this is a fault in Unity's API though, it raises an exception because things are not going exactly as planned. Admittedly, their doc page does not mention raising an exception, but that's the Unity documentation for you (https://docs.unity3d.com/ScriptReferenc ... jects.html). However, waiting for Unity to fix this, after filing a bug report that may or may not be taken into account, is asking for months of delay, at best.

Replacing (in ES3ReferenceBaseMgr.GetManagerFromScene() )

Code: Select all

            var roots = scene.GetRootGameObjects();
with

Code: Select all

            GameObject[] roots = null;
            try {
                roots = scene.GetRootGameObjects ();
            }
            catch (Exception) {
                return null;
            }
does the trick and the error no longer appears, but this is a bit heavy-handed. Probably you'll find a better solution. I'm just putting this here for those who are annoyed by this error as well and don't want to wait for a fix.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentException: The Scene is Not Loaded error

Post by Joel »

Hi there, and thanks for the detailed information.

The above bug report was actually regarding scenes which are displayed as loaded in the Editor and the isLoaded flag is true, but are internally being returned as unloaded and triggering the error.

Your use case is one we've not encountered before, but as you mention is easy to account for at our end. I'll ensure that this is included in the next update. In the meantime if you private message me your invoice number I can send this update over.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Nightkin
Posts: 2
Joined: Mon Oct 03, 2022 8:21 am

Re: ArgumentException: The Scene is Not Loaded error

Post by Nightkin »

Thank you for your fast answer. Indeed it seems all three reports are reporting different causes, but the same effect (the errors in the console). I would have thought my use case was more common, as using scenes additively is a good way to keep things modular and flexible.

I'll send you my invoice nbr in PM shortly but here is no urgency to send me an updated package, as I have already "fixed" it on my end (with the code I wrote above). But thank you anyway.
Post Reply