Skip to content

SceneController

Feynmen edited this page Jun 18, 2018 · 7 revisions

SceneControllerBase Description

On each scene, you must create the class which inherited from SceneControllerBase and it to GameObject on the scene. This class is the start point of the workflow on the scene. The second step is to add scene name to this script on the scene. (This option will be removed in future)

This class do finding on the scene all GameObjects with class ControllerBase, add it to the dictionary, inject managers and init ControllerBase.

SceneControllerBase Initialization workflow

  1. Unity Awake
  • Finding class which inherited from CoreSystem and add reference. (In Editor mode you mustn't add ApplicationSystem into the current scene. ApplicationSystem will be Instantiate to the scene from the path in variable DEBUG_APPSYS_PREFAB_PATH )
  • Adding SceneController reference into founded Controllers using Injection
  1. Unity IEnumerator Start
  • Adding Managers reference into founded Controllers which using Injection attribute
  • Init founded Controllers
  • Execute PreInitExecutionQueue
  • Invoke Init function of SceneController

SceneController Features

  1. From yours Controllers you can add IEnumerator method to PreInitExecutionQueue
 public Queue<IEnumerator> PreInitExecutionQueue
  1. You can get access to other controllers using these functions:
  public T Get<T>() where T : ControllerBase
  public ControllerBase Get(Type controllerType)
  public bool TryGet<T>(out T controller) where T : ControllerBase
  1. You can set Enable state to Controllers
  public void Enable<T>() where T : ControllerBase
  public void Disable<T>() where T : ControllerBase

SceneController Example

public class TestSceneController : SceneControllerBase 
{
	public override IEnumerator Init()
	{
		yield return null;
	}
}

Clone this wiki locally