public static ScaffoldingConfig CreateInstance() { string path = ""; ScaffoldingConfig sc = null; #if UNITY_EDITOR RecursivelyFindFolderPath("Assets"); path = _scaffoldingPath + "/Resources/SCConfig.asset"; if (AssetDatabase.LoadAssetAtPath(path, typeof(ScaffoldingConfig)) == null) { sc = ScriptableObject.CreateInstance <ScaffoldingConfig> (); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path); AssetDatabase.CreateAsset(sc, assetPathAndName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.FocusProjectWindow(); } sc = AssetDatabase.LoadAssetAtPath(path, typeof(ScaffoldingConfig)) as ScaffoldingConfig; sc.ScaffoldingPath = _scaffoldingPath; #else path = "SCConfig.asset"; sc = Resources.Load <ScaffoldingConfig>(path); #endif return(sc); }
/// <summary> /// Closes the overlay. /// </summary> internal void CloseOverlay() { if (targetView != null) { Type t = ScaffoldingConfig.GetType(targetView); _view.RequestOverlayClose(t); } }
/// <summary> /// Requests the screen with data. /// </summary> /// <param name="screenType">Screen type.</param> /// <param name="data">Data.</param> public void RequestView(Type screenType, SObject data) { if (_targetScreen == null || (_targetScreen.GetType() != screenType && !_targetScreen.IsSettingUp)) { GameObject obj = GameObject.Instantiate(Resources.Load(_scaffoldingConfig.ViewPrefabPath(screenType.Name) + screenType.Name)) as GameObject; #if UNITY_4_6 || UNITY_5 obj.transform.SetParent(_scaffoldingConfig.DetermineParentGameObjectPath().transform); #else obj.transform.parent = _scaffoldingConfig.DetermineParentGameObjectPath().transform; #endif obj.transform.name = screenType.Name; _targetScreen = obj.GetComponent <AbstractView>(); string s = screenType.Name + "Model"; Type t = ScaffoldingConfig.GetType(s); if (t != null) { AbstractModel model = FindObjectOfType(t) as AbstractModel; if (model != null) { model.RegisterView(_targetScreen); } } if (_scaffoldingConfig.ScaffoldingEnableAllGameobjects) { _targetScreen.gameObject.EnableAllChildren(); } _targetScreen.Setup(this); obj.SetActive(false); _lastScreen = _currentScreen; _targetScreenData = data; if (_currentScreen != null) { if (_targetScreen.showingType == AbstractView.ShowingTypes.ShowImmediately) { ScreenClose(_currentScreen.GetType()); ScreenOpen(); } else { ScreenClose(_currentScreen.GetType()); } } else { ScreenOpen(); } } }
/// <summary> /// Requests the overlay open with data. /// </summary> /// <param name="overlayType">Overlay type.</param> /// <param name="data">Data.</param> public void RequestOverlay(Type overlayType, SObject viewData) { if (!_currentOverlays.ContainsKey(overlayType)) { GameObject obj = GameObject.Instantiate(Resources.Load(_scaffoldingConfig.ViewPrefabPath(overlayType.Name) + overlayType.Name)) as GameObject; #if UNITY_4_6 || UNITY_5 obj.transform.SetParent(_scaffoldingConfig.DetermineParentGameObjectPath().transform); #else obj.transform.parent = _scaffoldingConfig.DetermineParentGameObjectPath().transform; #endif obj.transform.name = overlayType.Name; string s = overlayType.Name + "Model"; Type t = ScaffoldingConfig.GetType(s); if (t != null) { AbstractModel model = FindObjectOfType(t) as AbstractModel; if (model != null) { model.RegisterView(_targetScreen); } } _targetOverlay = obj.GetComponent <AbstractView>(); if (_scaffoldingConfig.ScaffoldingEnableAllGameobjects) { _targetOverlay.gameObject.EnableAllChildren(); } _targetOverlay.Setup(this); obj.SetActive(false); if (viewData != null && viewData.GetBool("Scaffolding:DisableInputsOnOverlay")) { if (_disabledInputsOnView.ContainsKey(_currentScreen.GetType())) { _disabledInputsOnView[_currentScreen.GetType()].Add(overlayType); } else { List <Type> overlays = new List <Type>(); overlays.Add(overlayType); _disabledInputsOnView.Add(_currentScreen.GetType(), overlays); } _currentScreen.DisableAllInputs(); } _currentOverlays.Add(overlayType, _targetOverlay); OverlayOpen(_targetOverlay.GetType(), viewData); } }
/// <summary> /// Runs any methods attached to the button to run when clicked. /// </summary> private void RunButtonMethods() { int i = 0, l = selectedScript.Count; for (; i < l; ++i) { Type t = ScaffoldingConfig.GetType(selectedScript[i]); UnityEngine.Object o = GameObject.FindObjectOfType(t); if (o != null) { MethodInfo method = t.GetMethod(selectedMethod[i]); if (method.GetParameters().Length == 0) { method.Invoke(o, null); } } } }
public static ScaffoldingConfig CreateInstance() { string path = ""; ScaffoldingConfig sc = null; #if UNITY_EDITOR RecursivelyFindFolderPath("Assets"); RecursivelyFindAsset("Assets"); path = _scaffoldingConfigPath; if (_scaffoldingConfigPath != null && !_scaffoldingConfigPath.Contains("Resources")) { Debug.LogWarning("Scaffolding:: The config file needs to be in a resources folder!"); } if (path == null) { path = _scaffoldingPath + "/Resources/SCConfig.asset"; } if (AssetDatabase.LoadAssetAtPath(path, typeof(ScaffoldingConfig)) == null) { sc = ScriptableObject.CreateInstance <ScaffoldingConfig> (); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path); AssetDatabase.CreateAsset(sc, assetPathAndName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.FocusProjectWindow(); } sc = AssetDatabase.LoadAssetAtPath(path, typeof(ScaffoldingConfig)) as ScaffoldingConfig; sc.ScaffoldingPath = _scaffoldingPath; sc.ScaffoldingConfigPath = _scaffoldingConfigPath; #else path = "SCConfig.asset"; sc = Resources.Load <ScaffoldingConfig>(path); #endif return(sc); }
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!"); } } }
internal void OpenView() { if (targetView != null) { if (openAsScreen) { if (loadingOverlay != "") { _view.RequestViewWithLoadingOverlay(ScaffoldingConfig.GetType(targetView), ScaffoldingConfig.GetType(loadingOverlay)); } else { _view.RequestView(ScaffoldingConfig.GetType(targetView)); } } else { Type t = ScaffoldingConfig.GetType(targetView); _view.RequestOverlay(t, disableInputsOnOverlay); } } }