StarForce icon indicating copy to clipboard operation
StarForce copied to clipboard

How to Change/Load Scene Inside Function?

Open herbertmilhomme opened this issue 3 years ago • 3 comments

I wrote a game framework to separate game logic from unity visual. Everything for game is done inside a big function (method). When game should load new scene or level, i use interface to call IInterface.Initialize(new IScene). But GameFramework only change scene inside OnUpdate()?

image

herbertmilhomme avatar Oct 04 '20 05:10 herbertmilhomme

Is it possible to change scene without Procedure and not have any issues?

I want to do this... image

herbertmilhomme avatar Oct 04 '20 05:10 herbertmilhomme

Is this okay? Do i need to use ProcedureManager? What about ChangeState<ProcedureChangeScene>(procedureOwner); and Scene change animation?

image

herbertmilhomme avatar Oct 04 '20 05:10 herbertmilhomme

Procedure is more like a state stage of the current game. You can switch scenes in your own way. Procedure will not be affected by your logic. Procedure in StarForce is just a way of using it. You can ignore it completely. You can also just create a Procedure, then load the scene in your own code.

class Procedure1
{
  
     Enter()
     {
         //Current game state initialization ....

        eventManager.Register("LoaScene",_loadScene)
     }

     string _nextScene;

     Update()
     {
        //Some logic that needs to be updated .....
       
       //2
       if(_nextScene != null)
       {
            SceneManager.LoadScene(arg)
           _nextScene = null
       }

     ///3
      if(owner.HasData(nextScene))
      {
          SceneManager.LoadScene(arg)
          owner.RemoveData(nextScene)
      }
     }

     //1
     _loadScene(arg)
     {
        SceneManager.LoadScene(arg)
     }

}

I have written three pseudo code ways, hoping to help you, scene loading you can do anywhere

yika-aixi avatar Oct 09 '20 13:10 yika-aixi