Ejemplo n.º 1
0
    /// <summary>
    /// Transitions to another scene and loads additional scene if specified.
    /// game assuming that it will exist in the scene after loading is finished.
    /// </summary>
    /// <typeparam name="T">The SceneManager type that will exist in the first scene specified.</typeparam>
    /// <param name="setup">Perform additonal setup when the scene has transitioned.</param>
    /// <param name="levels">The SceneManager type that will exist in the first scene specified.</param>
    public static void TransitionLevel <T>(Action <T> setup, params string[] levels) where T : SceneManager
    {
        if (levels.Length < 1)
        {
            throw new Exception("There must be at least one level name passed to the SwitchGameAndLevel method.");
        }
        var settings = new SwitchLevelSettings <T>()
        {
            Setup  = setup,
            Levels = levels
        };

        TransitionLevel(settings);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Transitions to another scene and loads additional scene if specified.
    /// game assuming that it will exist in the scene after loading is finished.
    /// </summary>
    /// <typeparam name="T">The SceneManager type that will exist in the first scene specified.</typeparam>
    public static void TransitionLevel <T>(SwitchLevelSettings <T> settings) where T : SceneManager
    {
        if (ActiveSceneManager != null)
        {
            ActiveSceneManager.PersistantViewModels.Clear();
            ActiveSceneManager.PersistantViews.Clear();
            ActiveSceneManager.Unload();
            ActiveSceneManager.enabled = false;
            ActiveSceneManager.gameObject.SetActive(false);
            ActiveSceneManager = null;
        }

        SwitchLevelSettings = settings;

        Application.LoadLevel(Instance._LoadingLevel);
    }
Ejemplo n.º 3
0
    /// <summary>During the Game-Managers load method it waits for a scene manager to register itself.  A scenemanager's awake method will invoke this function so the game
    /// manager prepare it for loading.</summary>
    /// <param name="sceneManager">The scene manager to register.</param>
    public virtual void RegisterSceneManager(SceneManager sceneManager)
    {
        if (SceneManagers.Contains(sceneManager))
        {
            return;
        }
        SceneManagers.Add(sceneManager);
        Log(string.Format("Scene Manager {0} was registered", sceneManager.gameObject.name));
        sceneManager.Container = Container;

        if (SwitchLevelSettings != null)
        {
            SwitchLevelSettings.InvokeControllerSetup(sceneManager);
        }
        Container.Inject(sceneManager);
        sceneManager.Setup();
        sceneManager.Initialize();

        sceneManager.enabled = false;
        sceneManager.gameObject.SetActive(false);
    }
Ejemplo n.º 4
0
    /// <summary>During the Game-Managers load method it waits for a scene manager to register itself.  A scenemanager's awake method will invoke this function so the game
    /// manager prepare it for loading.</summary>
    /// <param name="sceneManager">The scene manager to register.</param>
    public virtual void RegisterSceneManager(SceneManager sceneManager)
    {
        if (SceneManagers.Contains(sceneManager))
        {
            return;
        }
        SceneManagers.Add(sceneManager);
        Log(string.Format("Scene Manager {0} was registered", sceneManager.gameObject.name));
        sceneManager.Container = Container;

        if (SwitchLevelSettings != null)
        {
            SwitchLevelSettings.InvokeControllerSetup(sceneManager);
        }
        Container.Inject(sceneManager);
#if UNITY_5
        foreach (var item in sceneManager.GetComponentsInChildren <ISystemService>())
        {
            Container.RegisterInstance <ISystemService> (item, item.GetType().Name);
        }
#else
        for (var i = 0; i < sceneManager.transform.childCount; i++)
        {
            //var service = sceneManager.transform.GetChild(i).GetComponent<ISystemService>();
            //if (service != null)
            //{
            //    Container.RegisterInstance<ISystemService>(service, service.GetType().Name);
            //}
        }
#endif
        sceneManager.Setup();

        sceneManager.Initialize();

        sceneManager.enabled = false;
        sceneManager.gameObject.SetActive(false);
    }
Ejemplo n.º 5
0
 public static void SwitchGameAndLevel <T>(SwitchLevelSettings <T> settings) where T : SceneManager
 {
 }