Hi Chris,
I'm using AC with UCC. I'm having a small trouble with scene loading.
My game goes from Main menu -> loading scene -> gameplay scene.
Scene loading is being handled via custom code.
There is only 1 gameplay scene and only it has the AC components.
There is a section in UCC docs that mentioning that scene loading problems can be fixed by changing Script execution order but it doesn't help me. Here is what happens.
When Multi scene Checker' Awake method gets called, ObjectIsInActiveScene returns false because my loading scene calls my Level Generation method and while it is happening active scene is some other scene.
MSC code continues and calls SetActive(false) to camera and player.
This creates the problem for the rest of my code.
I tried to call AC.KickStarter.TurnOffAC();
but couldn't find a good time to call it.
I tried AC.EventManager.OnInitialiseScene event
but it seems this is also too late.
I thought maybe I don't need "Multi Scene Checker" but then "KickStarter.stateHandler" is null for some reason (AC_UCC_Character needs it)
Only thing that worked for me is to move MultiSceneChecker.Awake code into Start method.
Is there an alternative way for doing what Multi Scene Checker does? or defer it?
Is it OK to make a new component and copy MSC code (moving Awake code to Start)?
Thanks
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You can similarly set the Script Execution Order of the MultiSceneChecker script, but MSC makes the ObjectiveIsInActiveScene check a few times.
I can look into moving this into a separate function/property so that it can be overridden more easily, but if you remove these checks for now (i.e. any ObjectIsInActiveScene check returns true), does that allow it to work with your custom scene loader?
I tried running MSC at a later time in frame via Script Execution Order. It didn't didn't help. (I haven't tested but) I think it is because I also am positioning the player after level is created and since MSC disables the player my code can't do it.
My scene loader only works if I move MSC code in Awake method to MSC' Start method. MSC still needs to do what it does but a bit later.
If I remove the code completely, AC_UCC_Character fails to work.
But if you mean, let MSC code stay in Awake and just make ObjectIsInActiveScene return true. I just tried it and it also works.
I'm sorry but this getting more complex the more I look into it.
This post is only to clarify what is going on.
Currently MCS is not in Script Execution Order list so it runs on default time.
If I start my game from my main menu scene and go to game scene. I need MCS code to run at Start. But if I want to test my game, starting from my game scene. Then MCS code needs to run at Awake.
Just like you said: if it is possible for you to move MCS Awake code into its own public method and make Awake and Start virtual then I might find my way out of this.
PM sent.
Magic!
I didn't have to do anything other than setting "Force Main" to true.
It works, if I start from my "game play" scene,
it works, if I start from my "main menu" scene.
I anything else happens later on, I can go and write code to customize these parts. (For anyone else reading, MSC now has virtual methods)
Thank you very much Chris!