Example #1
0
    protected override void Awake()
    {
        base.Awake();

#if UNITY_EDITOR
        if (!SceneUtility.CheckForDomain("Menu"))
        {
            LoadOnAwake = true;
        }
#endif

        GetSaveObjects();

        bool load = LoadOnAwake;
        foreach (var obj in saveObjects)
        {
            if (load)
            {
                obj.LoadSavedData();
            }
            else
            {
                obj.SetDefaultValues();
            }
        }

        SceneUtility.OnSceneUnload += SaveObjects;
    }
    IEnumerator Routine()
    {
        if (!SceneUtility.CheckForDomain("Global"))
        {
            yield return(SceneUtility.LoadAdditive(this, globalSceneName));
        }
        yield return(new WaitForEndOfFrame());

#if UNITY_EDITOR
        if (playSound)
        {
            SoundManager.instance.PlayTrack(trackIndex);
        }
#endif
    }