StarForce
StarForce copied to clipboard
How to Change/Load Scene Inside Function?
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()
?
Is it possible to change scene without Procedure
and not have any issues?
I want to do this...
Is this okay? Do i need to use ProcedureManager
? What about ChangeState<ProcedureChangeScene>(procedureOwner);
and Scene change animation?
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