public void SetViewDataForScene(ScaffoldingStartingView sv)
        {
            bool added = false;
            int  i = 0, l = StartingView.Count;

            for (; i < l; ++i)
            {
                if (StartingView[i].SceneName == sv.SceneName)
                {
                    StartingView[i] = sv;
//					Debug.Log(StartingView[i].StartingViewName);
                    added = true;
                    break;
                }
            }
            if (!added)
            {
//				ScaffoldingStartingView	[] sva = new ScaffoldingStartingView[l+1];
//				StartingView.CopyTo(sva,0);
//				StartingView = sva;
                StartingView.Add(sv);
//				Debug.Log(StartingView[l]);
                EditorUtility.SetDirty(this);
            }
        }
        public ScaffoldingStartingView GetDefaultStartingView()
        {
            ScaffoldingStartingView sv = new ScaffoldingStartingView();

                        #if UNITY_EDITOR
            sv.SceneName = EditorApplication.currentScene;
            sv.SceneName = sv.SceneName.Remove(0, sv.SceneName.LastIndexOf("/") + 1);
            int index = sv.SceneName.LastIndexOf(".unity");
            sv.SceneName = sv.SceneName.Remove(index, sv.SceneName.Length - index);
#else
            sv.SceneName = Application.loadedLevelName;
#endif
            sv.StartingViewIndex = 0;
            sv.StartingViewType  = ViewType.View;
            sv.StartingViewName  = "";
            return(sv);
        }
        private void LevelWasLoaded()
        {
            if (DontDestroyThisOnLoad)
            {
                if (_viewToOpenWithScene != null && _viewToOpenWithScene.ContainsKey(_requestedSceneName))
                {
                    Type t = _viewToOpenWithScene[_requestedSceneName];
                    _viewToOpenWithScene.Remove(_requestedSceneName);
                    RequestView(t);
                }
                else if (_overlayToOpenWithScene != null && _overlayToOpenWithScene.ContainsKey(_requestedSceneName))
                {
                    Type t = _overlayToOpenWithScene[_requestedSceneName];
                    _overlayToOpenWithScene.Remove(_requestedSceneName);
                    RequestOverlay(t);
                }
                else
                {
                    //use defaults that are in the scene!
                    ScaffoldingStartingView sv = _scaffoldingConfig.GetViewDataForScene(Application.loadedLevelName);
                    Type t = ScaffoldingConfig.GetType(sv.StartingViewName);

                    if (t != null)
                    {
                        switch (sv.StartingViewType)
                        {
                        case ViewType.View:
                            RequestView(t);
                            break;

                        case ViewType.Overlay:
                            RequestOverlay(t);
                            break;
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Scaffolding:: No views or overlays have been set to open when this scene loads.");
                    }
                }
            }
        }
        /// <summary>
        /// The startup sequence. Scaffolding starts from here.
        /// </summary>
        public void Init()
        {
            if (DontDestroyThisOnLoad)
            {
                GameObject.DontDestroyOnLoad(gameObject);
            }

            _scaffoldingConfig    = Resources.Load <ScaffoldingConfig>("SCConfig");
            _disabledInputsOnView = new Dictionary <Type, List <Type> >();

            _currentOverlays = new Dictionary <Type, AbstractView>();
            ScaffoldingStartingView sv = _scaffoldingConfig.GetViewDataForScene(Application.loadedLevelName);
            Type t = ScaffoldingConfig.GetType(sv.StartingViewName);

            if (t != null && GameObject.FindObjectOfType <AbstractView>() == null)
            {
                switch (sv.StartingViewType)
                {
                case ViewType.View:
                    RequestView(t);
                    break;

                case ViewType.Overlay:
                    RequestOverlay(t);
                    break;
                }
            }
            else
            {
                AbstractView v = GameObject.FindObjectOfType <AbstractView>();
                if (v != null)
                {
                    Destroy(v.gameObject);
                    RequestView(v.GetType());
                }
                else
                {
                    Debug.LogWarning("Scaffolding -- ViewManager: No views assigned to start with!");
                }
            }
        }