Beispiel #1
0
        private void DrawSubscriptions()
        {
            SpiralEditor.BeginPanel("Subscriptions:", Color.grey);
            int             sandboxCount = Sandbox.sandboxTotalCount;
            int             fieldHeight  = GetSubscriptionsHeight(sandboxCount);
            GUILayoutOption option       = GUILayout.MaxHeight(fieldHeight);

            scrollPosSubscriptions = EditorGUILayout.BeginScrollView(scrollPosSubscriptions, option);
            if (sandboxCount == 0)
            {
                EditorGUI.indentLevel += 1;
                EditorGUILayout.LabelField("No subscription yet");
                EditorGUI.indentLevel -= 1;
            }
            else
            {
                for (int i = 0; i < sandboxCount; i++)
                {
                    var sandboxEventInfo = Sandbox.GetEventInfo(i);
                    DrawSanboxEvent(sandboxEventInfo);
                    if (i != sandboxCount - 1)
                    {
                        EditorGUILayout.Space(2);
                    }
                }
            }
            EditorGUILayout.EndScrollView();
            SpiralEditor.EndPanel();
        }
Beispiel #2
0
        private void DrawMainSettings()
        {
            SpiralEditor.BeginPanel("Global Editor Simulation params");
            EditorGUI.indentLevel += 1;

            Sandbox.isRunning       = EditorGUILayout.Toggle("Editor simulation", Sandbox.isRunning);
            Sandbox.minimalStepMode = (Sandbox.MinimalStep)EditorGUILayout.EnumPopup("Step mode", Sandbox.minimalStepMode);
            if (Sandbox.minimalStepMode == Sandbox.MinimalStep.Custom)
            {
                GUIContent contentMTS = new GUIContent("Minimal time step");
                Sandbox.customMinimalTimeStep = EditorGUILayout.FloatField(contentMTS, Sandbox.customMinimalTimeStep);
            }
            Sandbox.checkAverageDeltaEvery = EditorGUILayout.FloatField("Check average every", Sandbox.checkAverageDeltaEvery);

            Sandbox.autoClearReferences = EditorGUILayout.Toggle("Clear references", Sandbox.autoClearReferences);
            Sandbox.secureMode          = EditorGUILayout.Toggle("Secure mode", Sandbox.secureMode);
            EditorGUI.indentLevel      -= 1;

            if (SpiralEditor.CenteredButton("Save current prefs"))
            {
                SandboxPrefs.SaveSettings();
            }

            EditorGUILayout.Space();
            SpiralEditor.EndPanel();
        }
Beispiel #3
0
        private void ShowDeadGUIDs()
        {
            GUILayoutOption labelOption = GUILayout.Height(20);

            SpiralEditor.BeginPanel(strFoundGUIDs + $"{DeadScripts.deadGUIDs.Count}", true, labelOption);

            if (DeadScripts.deadGUIDs.Count != 0)
            {
                EditorGUI.indentLevel += 1;
                foldoutDeads           = EditorGUILayout.Foldout(foldoutDeads,
                                                                 strShowList,
                                                                 true, SpiralStyles.foldoutNormal);
                EditorGUI.indentLevel -= 1;
            }
            else
            {
                foldoutDeads = false;
            }

            if (foldoutDeads)
            {
                for (int i = 0; i < DeadScripts.deadGUIDs.Count; i++)
                {
                    ComponentGUID dead = DeadScripts.deadGUIDs[i];
                    DrawDeadGUIDEntry(dead);
                }
            }
            SpiralEditor.EndPanel();
        }
 public static void DrawSceneReloadButton()
 {
     SpiralEditor.BeginPanel(GroupType.Vertical);
     if (SpiralEditor.Button(strSceneFile_ReuploadCurrentSceneText))
     {
         ReloadCurrentSceneFile();
     }
     SpiralEditor.EndPanel();
 }
Beispiel #5
0
 private void DrawSimpleMode()
 {
     SpiralEditor.BeginPanel(strObjectsOnly);
     if (SpiralEditor.Button(strObjectsOnlyButton))
     {
         DeadScripts.UpdateDeadList();
         DeadScripts.SelectDeads();
     }
     SpiralEditor.EndPanel();
 }
Beispiel #6
0
 // DRAWING FUNCTIONS ======================================================================
 // Draw interface block-by-block
 //=========================================================================================
 private void DrawDebugMode()
 {
     SpiralEditor.BeginPanel(GroupType.Vertical);
     DeadScripts.isDebugMode = EditorGUILayout.Toggle(strDeadScriptSearcher_DebugMode, DeadScripts.isDebugMode);
     if (DeadScripts.isDebugMode)
     {
         EditorGUILayout.HelpBox(strDeadScriptSearcher_DebugModeHelp, MessageType.Warning);
     }
     SpiralEditor.EndPanel();
 }
Beispiel #7
0
        private void OnGUI()
        {
            titleContent.text = "Editor Sandbox";
            scrollPos         = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(position.height));
            OpenStandartBack();
            SpiralEditor.DrawScriptField(typeof(Sandbox));

            DrawMainSettings();
            DrawHealthMonitor();
            DrawSubscriptions();

            CloseStandartBack();
            EditorGUILayout.EndScrollView();
        }
Beispiel #8
0
        private void DrawDeadGUIDEntry(ComponentGUID dead)
        {
            GUILayoutOption labelOption = GUILayout.Height(20);

            SpiralEditor.BeginPanel(GroupType.Vertical);

            EditorGUILayout.SelectableLabel($"GUID: {dead.guid}", GUILayout.MinWidth(250), labelOption);

            string strDeadCount = strDeadObjectsCount + $" {dead.oids.Count}";

            dead.showInfo = EditorGUILayout.Foldout(dead.showInfo, strDeadCount);
            if (dead.showInfo)
            {
                for (int i = 0; i < dead.gids.Count; i++)
                {
                    var dgid   = dead.gids[i];
                    var dgidID = dgid.fileID;

                    string strGID        = $"{dgidID}";
                    string strButtonName = $"#{i} MonoBehaviour ID: {strGID}";
                    if (EditorGUILayout.DropdownButton(new GUIContent(strButtonName), FocusType.Passive))
                    {
                        dgid.showInfo = !dgid.showInfo;
                    }
                    if (dgid.showInfo)
                    {
                        SpiralEditor.BeginPanel(GroupType.Vertical);
                        EditorGUILayout.SelectableLabel(strGID);
                        if (SpiralEditor.Button(strSelectObject))
                        {
                            Selection.objects = new Object[1] {
                                dead.oids[i].gameObject
                            };
                        }
                        GUI.enabled = false;
                        EditorGUILayout.TextArea(dgid.fileEntry);
                        GUI.enabled = true;
                        EditorGUILayout.Space();
                        SpiralEditor.EndPanel();
                    }
                }
            }

            if (SpiralEditor.Button(strSelectObjects))
            {
                ObjectID.Select(dead.oids);
            }

            EditorGUILayout.EndVertical();
        }
        private void DrawDebugPhotos()
        {
            SpiralEditor.BeginPanel("Debug Photos");
            EditorGUI.indentLevel += 1;

            makeScreenShotOnGameStart = EditorGUILayout.Toggle("Screenshot on start", makeScreenShotOnGameStart);
            if (makeScreenShotOnGameStart)
            {
                EditorGUI.indentLevel += 1;
                secondsAfter           = EditorGUILayout.FloatField("After (.s)", secondsAfter);
                EditorGUI.indentLevel -= 1;
            }

            EditorGUI.indentLevel -= 1;
            SpiralEditor.EndPanel();
        }
Beispiel #10
0
        private void DrawComponentList(ObjectID oid)
        {
            if (oid.componentIDs != null)
            {
                for (int comIDX = 0; comIDX < oid.componentIDs.Count; comIDX++)
                {
                    var cid = oid.componentIDs[comIDX];
                    SpiralEditor.BeginPanel(GroupType.Vertical, cid.alive ? colorNormal : colorAlert);

                    ulong  fileID = oid.componentFileIDs[comIDX]; // соответствует cid.fileID
                    string guid   = oid.componentGUIDs[comIDX];
                    // TODO: эта замена временная, так как функционал ещё не перенесён в ComponentID

                    if (cid.component == null)
                    {
                        EditorGUILayout.SelectableLabel($"Component #{comIDX} is missing!", labelOption);
                    }
                    else
                    {
                        EditorGUILayout.SelectableLabel($"Component #{comIDX}: {cid.type.Name}", labelOption);
                    }

                    EditorGUILayout.SelectableLabel($"Fild ID: {fileID}", labelOption);
                    if (!string.IsNullOrEmpty(guid))
                    {
                        EditorGUILayout.SelectableLabel($"Script GUID: {guid}", labelOption);
                    }
                    else
                    {
                        bool   isPrefabed = oid.isPartOfPrefab;
                        string message    = "No GUID found";
                        if (cid.mScript == null)
                        {
                            message += " [Is not MonoBehaviour]";
                        }
                        if (isPrefabed)
                        {
                            message += " [Prefabed]"; // может одновременно быть и то, и то
                        }
                        EditorGUILayout.LabelField(message, labelOption);
                    }

                    SpiralEditor.EndPanel();
                }
            }
        }
Beispiel #11
0
        private void DrawBoxSceneState()
        {
            SpiralEditor.BeginPanel(strSceneFileCheckout);

            SpiralEditor.BeginPanel(GroupType.Vertical);

            SpiralEditor.BeginPanel(GroupType.Horizontal);
            GUIStyle styleSceneIsDirty = new GUIStyle(SpiralStyles.labelBold);
            string   sceneIsDirty      = DeadScripts.isDirty ?
                                         strSceneWasChanged :
                                         strSceneClear;

            styleSceneIsDirty.normal.textColor = DeadScripts.isDirty ? new Color(0.8f, 0.0f, 0.0f) : Color.gray;
            EditorGUILayout.LabelField(sceneIsDirty, styleSceneIsDirty);
            SpiralEditor.EndPanel();

            SpiralEditor.BeginPanel(GroupType.Vertical);
            EditorGUI.indentLevel += 1;
            foldoutSceneSearchHelp = EditorGUILayout.Foldout(foldoutSceneSearchHelp,
                                                             strShowHelp,
                                                             true, SpiralStyles.foldoutNormal);
            EditorGUI.indentLevel -= 1;
            if (foldoutSceneSearchHelp)
            {
                EditorGUILayout.HelpBox(strSceneHelpWarning, MessageType.Warning);
                EditorGUILayout.HelpBox(strSceneHelpExplanation, MessageType.Info);
            }
            SpiralEditor.EndPanel();
            SpiralEditor.EndPanel();

            if (SpiralEditor.Button(strFindDeadGUIDs))
            {
                DeadScripts.SearchForDeads();
                if (DeadScripts.deadGUIDs.Count > 0)
                {
                    foldoutDeads = true;
                }
            }
            ShowDeadGUIDs();

            SpiralEditor.EndPanel();
        }
        private void DrawSnapshotPanel()
        {
            SpiralEditor.BeginPanel("Last snapshot preview");
            SpiralEditor.SetGUIEnabled(false);
            SpiralEditor.DrawObjectField("Snapshot", lastSnapshot, false);
            if (lastSnapshot != null)
            {
                SpiralEditor.BoldLabel($"{lastSnapshot.width}x{lastSnapshot.height}", true);
            }
            SpiralEditor.RestoreGUIEnabled();

            bool snapShotEnabled = GameViewUtils.gameView != null && !waiting;

            SpiralEditor.SetGUIEnabled(snapShotEnabled);
            try
            {
                bool makescreen = SpiralEditor.CenteredButton("Make a photo");
                if (makescreen)
                {
                    EditorCoroutineUtility.StartCoroutine(WaitForEditor(), this);
                }
            }
            catch
            {
                SpiralEditor.EndPanel();
                return;
            } // welcome to the silence null
            SpiralEditor.RestoreGUIEnabled();
            if (!snapShotEnabled)
            {
                if (waiting)
                {
                    SpiralEditor.MessagePanel("Wait...", MessageType.Info);
                }
                else
                {
                    SpiralEditor.MessagePanel("If disabled, try to open or restart GameView", MessageType.Warning);
                }
            }
            SpiralEditor.EndPanel();
        }
        // DRAW INSPECTOR WINDOW ==================================================================
        // Рисуем инспектор
        //=========================================================================================
        private void DrawSettings()
        {
            SpiralEditor.BeginPanel("Settings");
            EditorGUI.indentLevel += 1;

            path                = SpiralEditor.SelectPathField("Where to save", path);
            namePrefix          = EditorGUILayout.TextField("Name prefix", namePrefix);
            useNativeResolution = EditorGUILayout.Toggle("Use native resolution", useNativeResolution);
            if (!useNativeResolution)
            {
                EditorGUI.indentLevel += 1;
                fixedResolution        = EditorGUILayout.Vector2IntField("Fixed resolution", fixedResolution);
                EditorGUI.indentLevel -= 1;
                if (fixedResolution.x > 2000 || fixedResolution.y > 2000)
                {
                    SpiralEditor.MessagePanel("High resolution screenshot can freeze Unity for some seconds!", MessageType.Warning);
                }
            }

            EditorGUI.indentLevel -= 1;
            SpiralEditor.EndPanel();
        }
Beispiel #14
0
        private void DrawObject(ObjectID oid)
        {
            bool dead = oid.missingScriptsCount > 0;

            SpiralEditor.BeginPanel($"Game Object: {oid.gameObject.name}", dead ? colorAlert : colorGood, labelOption);
            EditorGUILayout.SelectableLabel($"File ID: {oid.globalID.targetObjectId}", labelOption);

            string captionIDX;

            if (oid.fileCaptionStringIDX > 0)
            {
                captionIDX = oid.fileCaptionStringIDX.ToString();
            }
            else
            {
                if (oid.isPartOfPrefab)
                {
                    captionIDX = "[prefabed]";
                }
                else
                {
                    captionIDX = "[not found]";
                }
            }

            EditorGUILayout.SelectableLabel($"File caption IDX: {captionIDX}", labelOption);

            string strShowInfo = oid.showInfo ? strMonoView_HideObjectInfo : strMonoView_ShowObjectInfo;

            oid.showInfo = EditorGUILayout.Foldout(oid.showInfo, strShowInfo);
            if (oid.showInfo)
            {
                DrawComponentList(oid);
            }

            SpiralEditor.EndPanel();
        }
Beispiel #15
0
        private void DrawHealthMonitor()
        {
            SpiralEditor.BeginPanel("Simulator's Health Monitor", SpiralStyles.colorLightRed);
            EditorGUI.indentLevel += 1;

            float  average    = Sandbox.averageDeltaTime;
            string strAverage = average.ToString("F4");

            EditorGUILayout.LabelField("Average real time step: ",
                                       $"{strAverage} s.",
                                       SpiralStyles.labelNormal);
            EditorGUILayout.LabelField("Events count: ",
                                       $"{Sandbox.sandboxCurrentCount} / {Sandbox.sandboxTotalCount}",
                                       SpiralStyles.labelNormal);
            EditorGUI.indentLevel -= 1;

            if (SpiralEditor.CenteredButton("Kill all events"))
            {
                Sandbox.RemoveAll();
            }

            EditorGUILayout.Space();
            SpiralEditor.EndPanel();
        }
Beispiel #16
0
        private void DrawSanboxEvent(Sandbox.SandboxEventInfo sandboxInfo)
        {
            GUILayoutOption buttonWidth = GUILayout.Width(100);

            if (sandboxInfo == null)
            {
                SpiralEditor.BeginPanel(GroupType.Vertical, SpiralStyles.colorLightRed);
                EditorGUILayout.LabelField($"IDX {sandboxInfo.idx} broken entry", SpiralStyles.panel);
                if (SpiralEditor.Button("Kill callback", buttonWidth))
                {
                    Sandbox.RemoveCallback(sandboxInfo.idx);
                }
                EditorGUILayout.Space(2);
                SpiralEditor.EndPanel();
            }
            else
            {
                bool  good = CheckEventHealth(sandboxInfo);
                Color color;
                if (good)
                {
                    color = sandboxInfo.paused ? SpiralStyles.colorLightYellow : SpiralStyles.colorLightGreen;
                }
                else
                {
                    color = sandboxInfo.paused ? SpiralStyles.colorLightOrange : SpiralStyles.colorLightRed;
                }

                SpiralEditor.BeginPanel(GroupType.Vertical, color);
                string isPaused = sandboxInfo.paused ? "PAUSED" : "IS RUNNING";
                EditorGUILayout.LabelField($"IDX {sandboxInfo.idx} {isPaused}", SpiralStyles.panel);

                EditorGUI.indentLevel += 1;
                GUI.enabled            = false;
                if (sandboxInfo.hasReference)                // имеет опорный объект
                {
                    if (sandboxInfo.referenceObject != null) // опорный объект существует
                    {
                        if (sandboxInfo.isReferenceUnityObject)
                        {
                            _ = EditorGUILayout.ObjectField("UnityObject: ",
                                                            sandboxInfo.referenceObject as UnityEngine.Object,
                                                            sandboxInfo.referenceObjectType,
                                                            true);
                        }
                        else
                        {
                            string name = "System.Object";
                            string data = $"{sandboxInfo.referenceObject} [{sandboxInfo.referenceObjectType}]";
                            EditorGUILayout.LabelField(name, data);
                        }
                    }
                    else // опорный объект утерян
                    {
                        if (sandboxInfo.isReferenceUnityObject)
                        {
                            _ = EditorGUILayout.ObjectField("UnityObject: ", null, sandboxInfo.referenceObjectType, true);
                        }
                        else
                        {
                            string name = "System.Object";
                            string data = $"<missing> [{sandboxInfo.referenceObjectType}]";
                            EditorGUILayout.LabelField(name, data);
                        }
                    }
                }
                else // запуск без опорного объекта
                {
                    EditorGUILayout.LabelField("No reference object");
                }

                EditorGUILayout.LabelField("Sender Type", $"[{sandboxInfo.senderType}]");

                string callbackName;
                object target = sandboxInfo.callback.Target;
                string parent = $"[{target}]";
                callbackName = $"{sandboxInfo.callback.Method.Name} {parent}";

                EditorGUILayout.LabelField("Method", $"{callbackName}");

                EditorGUI.indentLevel -= 1;
                GUI.enabled            = true;

                SpiralEditor.BeginGroup(GroupType.Horizontal);
                EditorGUILayout.Space(2);
                GUI.enabled = sandboxInfo.idx != Sandbox.sandboxTotalCount - 1;
                if (SpiralEditor.Button("Move Down", buttonWidth))
                {
                    Sandbox.MoveDown(sandboxInfo.idx);
                }
                GUI.enabled = true;
                EditorGUILayout.Space(2);
                if (SpiralEditor.Button("Kill callback", buttonWidth))
                {
                    Sandbox.RemoveCallback(sandboxInfo.idx);
                }
                string pause = sandboxInfo.paused ? "Unpause" : "Pause";
                if (SpiralEditor.Button(pause, buttonWidth))
                {
                    if (sandboxInfo.paused)
                    {
                        Sandbox.UnpauseCallback(sandboxInfo.idx);
                    }
                    else
                    {
                        Sandbox.PauseCallback(sandboxInfo.idx);
                    }
                }
                EditorGUILayout.Space(2);
                GUI.enabled = sandboxInfo.idx != 0;
                if (SpiralEditor.Button("Move Up", buttonWidth))
                {
                    Sandbox.MoveUp(sandboxInfo.idx);
                }
                GUI.enabled = true;
                EditorGUILayout.Space(2);
                SpiralEditor.EndGroup();

                EditorGUILayout.Space(2);
                SpiralEditor.EndPanel();
            }
        }