Forum rules - please read before posting.

Removing SubScene reference

I'm using AC for the various bits and bobs I need, but am rolling my own structure to the game, which involves asynchronously loading in-and-out scenes as they're needed.

the AC GameEngine stuff is in my core game scene with my main camera et al. Hit a bit of a stumbling block where:

1 - Load in Async scene containing AC cutscenes and hotspots and what-have-you.
2. - Unload Scene
3. - Reload scene

I get errors regarding SubScene, which I gather is created automatically so presumably there's a reference somewhere I need to null out. Any chance of a heads up on what to do here? Error below in case that's handy:

MissingReferenceException: The object of type 'SubScene' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
AC.UnityVersionHandler.GetLocalVariablesOfGameObject (UnityEngine.GameObject _gameObject) (at Assets/AdventureCreator/Scripts/Static/UnityVersionHandler.cs:243)
AC.ActionSpeech.AssignParentList (AC.ActionList actionList) (at Assets/AdventureCreator/Scripts/Actions/ActionSpeech.cs:93)
AC.ActionList+<RunAction>c__Iterator2.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:318)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

Comments

  • okay - looks like accessing AC.Kickstarter.SceneChanger.subScenes and clearing it (or removing the reference to the one in the scene to be removed) does the trick.
  • Welcome to the community, @danthat.

    I'd advise caution when tampering with the subScenes variable, as it's AC's way of keeping track of what additional scenes are open - and is necessary to successfully their loading when handling save game files.

    Are you using the Scene: Add or remove Action to load/unload your scenes, or your own code?
  • I'm using my own code, but I could roll Remove Scene into it, I guess. Thanks :)
  • Okay, can't do it via an action, but had a pilfer of the code and nabbed the appropriate parts. Plonking it here in case someone else needs it


    AC.SceneInfo sceneInfo = new AC.SceneInfo(AC.ChooseSceneBy.Name, scene, 99999);
    AC.KickStarter.sceneChanger.RemoveScene(sceneInfo);
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.