Пример #1
0
        private void OpenView()
        {
            //Choose view to open.
            EditorGUILayout.HelpBox("THE VIEW CALLED", MessageType.None);
            LoadAllViews();
            _target.targetViewIndex  = EditorGUILayout.Popup(_target.targetViewIndex, _viewNames.ToArray());
            _target.targetViewIndex  = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_target.targetViewLength, _target.targetViewIndex, _viewNames, _target.targetView);
            _target.targetViewLength = _viewNames.Count;
            _target.targetView       = _views[_target.targetViewIndex].name;

            //choose how its opened.
            EditorGUILayout.HelpBox("OPEN AS SCREEN OR OVERLAY?", MessageType.None);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Screen:");
            _target.openAsScreen = EditorGUILayout.Toggle(_target.openAsScreen);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Overlay:");
            _openAsOverlay = EditorGUILayout.Toggle(!_target.openAsScreen);
            if (_openAsOverlay)
            {
                _target.openAsScreen = false;
            }
            else
            {
                _target.openAsScreen = true;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();

            //if its a screen, theres some extra params.
            if (_target.openAsScreen)
            {
                EditorGUILayout.LabelField("Open a loading overlay?");
                _target.openLoadingOverlay = EditorGUILayout.Toggle(_target.openLoadingOverlay);
                if (_target.openLoadingOverlay)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    _viewNames.Remove(_target.targetView);
                    _target.loadingOverlayIndex  = EditorGUILayout.Popup(_target.loadingOverlayIndex, _viewNames.ToArray());
                    _target.loadingOverlayIndex  = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_target.loadingOverlayLength, _target.loadingOverlayIndex, _viewNames, _target.loadingOverlay);
                    _target.loadingOverlayLength = _viewNames.Count;
                    _target.loadingOverlay       = _views[_target.loadingOverlayIndex].name;
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }
                else
                {
                    _target.loadingOverlay = "";
                }
            }
            else
            {
                EditorGUILayout.LabelField("Disable inputs on the current view?");
                _target.disableInputsOnOverlay = EditorGUILayout.Toggle(_target.disableInputsOnOverlay);
            }

            EditorGUILayout.EndHorizontal();
        }
Пример #2
0
        private void GetButtonInputCamera()
        {
            EditorGUILayout.HelpBox("THIS BUTTON GETS ITS INPUT FROM", MessageType.None);
            Camera[]      cameras     = GameObject.FindObjectsOfType(typeof(Camera)) as Camera[];
            List <string> cameraNames = new List <string>();

            int i = 0, l = cameras.Length;

            if (!Application.isPlaying)
            {
                for (; i < l; ++i)
                {
                    cameraNames.Add(cameras[i].name);
                }

                if (cameras.Length > 0)
                {
                    _target.inputCameraIndex = EditorGUILayout.Popup(_target.inputCameraIndex, cameraNames.ToArray());
                    if (_target.inputCamera != null)
                    {
                        _target.inputCameraIndex  = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_target.inputCameraLength, _target.inputCameraIndex, cameraNames, _target.inputCamera);
                        _target.inputCameraLength = cameraNames.Count;
                    }
                    _target.inputCamera = cameras[_target.inputCameraIndex].name;
                }
            }
        }
Пример #3
0
 private void CloseView()
 {
     EditorGUILayout.HelpBox("THE OVERLAY CALLED", MessageType.None);
     LoadAllViews();
     _target.targetViewIndex = EditorGUILayout.Popup(_target.targetViewIndex, _viewNames.ToArray());
     _target.targetViewIndex = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_target.targetViewLength, _target.targetViewIndex, _viewNames, _target.targetView);
     _target.targetView      = _views[_target.targetViewIndex].name;
 }
Пример #4
0
        private void TellClass(int i)
        {
            //find all scripts in scene
            //                        _target.selectedScriptIndex = 1;
            OpenScriptFinder();
            _target.selectedScriptIndex[i] = EditorGUILayout.Popup(_target.selectedScriptIndex[i], componentNames.ToArray());
            SelectScript(components[_target.selectedScriptIndex[i]]);
            FindPublicMethodsInScript(components[_target.selectedScriptIndex[i]]);
            _target.selectedScriptIndex[i]  = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_target.selectedScriptLength[i], _target.selectedScriptIndex[i], componentNames, _target.selectedScript[i]);
            _target.selectedScript[i]       = componentNames[_target.selectedScriptIndex[i]];
            _target.selectedScriptLength[i] = componentNames.Count;


            //and then find all its methods
            EditorGUILayout.HelpBox("TO RUN THE FUNCTION", MessageType.None);
            _target.selectedMethodIndex[i]  = EditorGUILayout.Popup(_target.selectedMethodIndex[i], methodNames.ToArray());
            _target.selectedMethodIndex[i]  = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_target.selectedMethodLength[i], _target.selectedMethodIndex[i], methodNames, _target.selectedMethod[i]);
            _target.selectedMethod[i]       = methods[_target.selectedMethodIndex[i]].Name;
            _target.selectedMethodLength[i] = methodNames.Count;
        }
Пример #5
0
        void OnGUI()
        {
            CreateConfig();
            CreateAllViews();

            //toolbar GUI
            int i = 0, l = _viewNames.Count;

            //create search bar
            GUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
            GUIStyle toolbar = GUI.skin.FindStyle("ToolbarSeachTextField");

            toolbar.fixedWidth   = 80;
            toolbar.stretchWidth = true;
            searchString         = GUILayout.TextField(searchString, toolbar);

            GUIStyle cancel = GUI.skin.FindStyle("ToolbarSeachCancelButtonEmpty");

            if (searchString.Length > 0)
            {
                cancel = GUI.skin.FindStyle("ToolbarSeachCancelButton");
            }

            if (GUILayout.Button("", cancel))
            {
                CancelSearch();
            }

            toolbar.fixedWidth   = 0;
            toolbar.stretchWidth = true;

            //close all open views button
            if (GUILayout.Button("Save & Close All", EditorStyles.toolbarButton))
            {
                SaveAndCloseAll();
            }

            if (GUILayout.Button("Create New", EditorStyles.toolbarButton))
            {
                CreateNewView();
            }

            if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                EditorApplication.ExecuteMenuItem("Tools/Scaffolding/Preferences");
            }

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUI.skin.FindStyle("Box"));

            _startingViewIndex = EditorGUILayout.Popup("Starting View:", _startingViewIndex, _viewNames.ToArray());
            if (_scaffoldingConfig.StartingView != null)
            {
                _startingViewIndex = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_viewLength, _startingViewIndex, _viewNames, _scaffoldingConfig.StartingView);
            }
            _viewLength = _viewNames.Count;

            if (_startingViewIndex < _abstractViews.Count)
            {
                _scaffoldingConfig.StartingView = _abstractViews[_startingViewIndex].name;
            }


            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUI.skin.FindStyle("Box"));

            _scaffoldingConfig.StartingViewType = (ViewType)EditorGUILayout.EnumPopup("Open as:", _scaffoldingConfig.StartingViewType);

            GUILayout.EndHorizontal();

            //Setting up the library scroll area
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);


            GUILayout.BeginVertical();

            if (!EditorApplication.isPlaying)
            {
                if (!EditorApplication.isCompiling)
                {
                    //display all buttons for views
                    _backgroundImageHeight = 0;
                    i = 0;
                    int j = 0;
                    for (; i < l; ++i)
                    {
                        //handle searching
                        if (searchString.Length == 0 || (searchString.Length > 0 && _viewNames[i].IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0))
                        {
                            DrawBackgroundImage(j);
                            //handle individual buttons
                            EditorGUILayout.BeginHorizontal();
                            System.Type  t           = _abstractViews[i].GetType();
                            AbstractView sceneObject = GameObject.FindObjectOfType(t) as AbstractView;
                            if (sceneObject != null)
                            {
                                OpenViewButtons(_viewNames[i], sceneObject.gameObject);
                            }
                            else
                            {
                                ClosedViewButtons(_viewNames[i]);
                            }
                            EditorGUILayout.EndHorizontal();

                            GUILayout.Space(5);
                            j++;
                        }
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Updating view library...", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Best not fiddle with views while Unity is running.", MessageType.Info);
            }
            EditorGUILayout.EndScrollView();
            GUILayout.EndVertical();

            EditorUtility.SetDirty(_scaffoldingConfig);

            Repaint();
        }
Пример #6
0
        void OnGUI()
        {
            _applicationPlaying = Application.isPlaying;
            CreateConfig();
            CreateAllViews();

            //toolbar GUI
            //create search bar
            GUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
            GUIStyle toolbar = GUI.skin.FindStyle("ToolbarSeachTextField");

            toolbar.fixedWidth   = 80;
            toolbar.stretchWidth = true;
            searchString         = GUILayout.TextField(searchString, toolbar);

            GUIStyle cancel = GUI.skin.FindStyle("ToolbarSeachCancelButtonEmpty");

            if (searchString.Length > 0)
            {
                cancel = GUI.skin.FindStyle("ToolbarSeachCancelButton");
            }

            if (GUILayout.Button("", cancel))
            {
                CancelSearch();
            }

            toolbar.fixedWidth   = 0;
            toolbar.stretchWidth = true;

            //close all open views button
            if (GUILayout.Button("Save & Close All", EditorStyles.toolbarButton))
            {
                SaveAndCloseAll();
            }

            if (GUILayout.Button("Create New", EditorStyles.toolbarButton))
            {
                CreateNewView();
            }

            if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                EditorApplication.ExecuteMenuItem("Tools/Scaffolding/Preferences");
            }

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUI.skin.FindStyle("Box"));

            if (_scaffoldingConfig.StartingView == null)
            {
                _scaffoldingConfig.StartingView = new List <ScaffoldingStartingView>();
                _scaffoldingConfig.SetViewDataForScene(_scaffoldingConfig.GetDefaultStartingView());
            }

            string name = EditorApplication.currentScene;

            if (name != "")
            {
                name = name.Remove(0, name.LastIndexOf("/") + 1);
                int index = name.LastIndexOf(".unity");
                name = name.Remove(index, name.Length - index);

                ScaffoldingStartingView sv = _scaffoldingConfig.GetViewDataForScene(name);
                sv.StartingViewIndex = EditorGUILayout.Popup("Starting View:", sv.StartingViewIndex, _viewNames.ToArray());
                if (sv.StartingViewName != null)
                {
                    sv.StartingViewIndex = ScaffoldingUtilitiesEditor.CheckIfMenuItemChanged(_viewLength, sv.StartingViewIndex, _viewNames, sv.StartingViewName);
                }
                _viewLength         = _viewNames.Count;
                sv.StartingViewName = _viewNames[sv.StartingViewIndex];

                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(GUI.skin.FindStyle("Box"));

                sv.StartingViewType = (ViewType)EditorGUILayout.EnumPopup("Open as:", sv.StartingViewType);

                GUILayout.EndHorizontal();

                _scaffoldingConfig.SetViewDataForScene(sv);
                EditorUtility.SetDirty(_scaffoldingConfig);
            }
            else
            {
                GUILayout.Label("You need to save the scene first!");
                GUILayout.EndHorizontal();
            }

            //Setting up the library scroll area
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);


            GUILayout.BeginVertical();

            if (!EditorApplication.isPlaying)
            {
                if (!EditorApplication.isCompiling)
                {
                    //display all buttons for views
                    _backgroundImageHeight = 0;
                    int i = 0, l = _viewNames.Count;
                    int j = 0;

                    _scenesFoldout = EditorGUILayout.Foldout(_scenesFoldout, "Buildable Scenes");
                    if (_scenesFoldout)
                    {
                        GUILayout.Space(5);
                        _backgroundImageHeight += 23;

                        foreach (UnityEditor.EditorBuildSettingsScene S in UnityEditor.EditorBuildSettings.scenes)
                        {
                            DrawBackgroundImage(j);
                            EditorGUILayout.BeginHorizontal();
                            string n = S.path.Substring(S.path.LastIndexOf('/') + 1);
                            n = n.Substring(0, n.Length - 6);
                            GUIStyle skin = EditorStyles.boldLabel;
                            skin.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black;

                            GUILayout.Label(n, skin);
                            if (GUILayout.Button("Open", GUILayout.ExpandWidth(true), GUILayout.Width(218)))
                            {
                                EditorApplication.SaveCurrentSceneIfUserWantsTo();
                                EditorApplication.OpenScene(S.path);
                            }
                            EditorGUILayout.EndHorizontal();
                            GUILayout.Space(5);
                            j++;
                        }
                    }
                    else
                    {
                        GUILayout.Space(5);
                        _backgroundImageHeight += 23;
                    }

                    _viewsFoldout = EditorGUILayout.Foldout(_viewsFoldout, "Views");

                    if (_viewsFoldout)
                    {
                        GUILayout.Space(5);
                        _backgroundImageHeight += 23;

                        i = 0;
                        l = _viewNames.Count;

                        for (; i < l; ++i)
                        {
                            //handle searching
                            if (searchString.Length == 0 || (searchString.Length > 0 && _viewNames[i].IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0))
                            {
                                DrawBackgroundImage(j);
                                //handle individual buttons
                                EditorGUILayout.BeginHorizontal();
                                System.Type  t           = _abstractViews[i].GetType();
                                AbstractView sceneObject = GameObject.FindObjectOfType(t) as AbstractView;
                                if (sceneObject != null)
                                {
                                    OpenViewButtons(_viewNames[i], sceneObject.gameObject);
                                }
                                else
                                {
                                    ClosedViewButtons(_viewNames[i]);
                                }
                                EditorGUILayout.EndHorizontal();

                                GUILayout.Space(5);
                                j++;
                            }
                        }
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Updating view library...", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Best not fiddle with views while Unity is running.", MessageType.Info);
            }
            EditorGUILayout.EndScrollView();
            GUILayout.EndVertical();

            EditorUtility.SetDirty(_scaffoldingConfig);
        }