Пример #1
0
        public override void OnInspectorGUI()
        {
            if (me == null)
            {
                return;
            }
            serializedObject.Update();

            EditorUIUtils.SetupStyles();

            GUILayout.Space(5);

            EditorGUIUtility.labelWidth = 120;

            EditorUIUtils.DrawProperty(operationMode, () => me.OperationMode = (OperationMode)operationMode.enumValueIndex);
            EditorGUILayout.PropertyField(hotKey);

            EditorGUIUtility.labelWidth = 0;

            using (EditorUIUtils.Horizontal())
            {
                GUILayout.FlexibleSpace();

                EditorGUIUtility.labelWidth = 70;
                EditorGUILayout.PropertyField(hotKeyCtrl, new GUIContent("Ctrl / Cmd", hotKeyCtrl.tooltip), GUILayout.Width(85));

                EditorGUIUtility.labelWidth = 20;
                EditorGUILayout.PropertyField(hotKeyAlt, new GUIContent("Alt", hotKeyAlt.tooltip), GUILayout.Width(35));

                EditorGUIUtility.labelWidth = 35;
                EditorGUILayout.PropertyField(hotKeyShift, new GUIContent("Shift", hotKeyShift.tooltip), GUILayout.Width(50));

                EditorGUIUtility.labelWidth = 0;
            }

            EditorGUIUtility.labelWidth = 120;
            EditorGUILayout.PropertyField(circleGesture);

            EditorGUILayout.PropertyField(keepAlive);
            if (me.transform.parent != null)
            {
                EditorGUILayout.LabelField("Keep Alive option will keep alive root level object (" + me.transform.root.name + ")!", EditorStyles.wordWrappedMiniLabel);
            }

            using (EditorUIUtils.Horizontal(GUILayout.ExpandWidth(true)))
            {
                EditorUIUtils.DrawProperty(forceFrameRate, "Force FPS", () => me.ForceFrameRate = forceFrameRate.boolValue, GUILayout.ExpandWidth(false));
                GUILayout.Space(2);
                EditorUIUtils.DrawProperty(forcedFrameRate, GUIContent.none, () => me.ForcedFrameRate = forcedFrameRate.intValue);
            }

            EditorGUIUtility.labelWidth = 0;

            if (EditorUIUtils.Foldout(lookAndFeelFoldout, "Look & Feel"))
            {
                EditorGUIUtility.labelWidth = 130;

                EditorUIUtils.DrawProperty(autoScale, () => me.AutoScale = autoScale.boolValue);

                if (autoScale.boolValue)
                {
                    GUI.enabled = false;
                }
                EditorUIUtils.DrawProperty(scaleFactor, () => me.ScaleFactor = scaleFactor.floatValue);
                GUI.enabled = true;
                EditorUIUtils.DrawProperty(labelsFont, () => me.LabelsFont           = (Font)labelsFont.objectReferenceValue);
                EditorUIUtils.DrawProperty(fontSize, () => me.FontSize               = fontSize.intValue);
                EditorUIUtils.DrawProperty(lineSpacing, () => me.LineSpacing         = lineSpacing.floatValue);
                EditorUIUtils.DrawProperty(countersSpacing, () => me.CountersSpacing = countersSpacing.intValue);
                EditorUIUtils.DrawProperty(paddingOffset, () => me.PaddingOffset     = paddingOffset.vector2Value);
                EditorUIUtils.DrawProperty(pixelPerfect, () => me.PixelPerfect       = pixelPerfect.boolValue);

                EditorUIUtils.Header("Effects");
                EditorUIUtils.Separator();

                EditorUIUtils.DrawProperty(background, () => me.Background = background.boolValue);
                if (background.boolValue)
                {
                    EditorUIUtils.Indent();
                    EditorUIUtils.DrawProperty(backgroundColor, "Color", () => me.BackgroundColor       = backgroundColor.colorValue);
                    EditorUIUtils.DrawProperty(backgroundPadding, "Padding", () => me.BackgroundPadding = backgroundPadding.intValue);
                    EditorUIUtils.UnIndent();
                }

                EditorUIUtils.DrawProperty(shadow, () => me.Shadow = shadow.boolValue);
                if (shadow.boolValue)
                {
                    EditorUIUtils.Indent();
                    EditorUIUtils.DrawProperty(shadowColor, () => me.ShadowColor       = shadowColor.colorValue);
                    EditorUIUtils.DrawProperty(shadowDistance, () => me.ShadowDistance = shadowDistance.vector2Value);
                    EditorGUILayout.LabelField(new GUIContent("<b>This effect is resource-heavy</b>", "Such effect increases resources usage on each text refresh."), EditorUIUtils.richMiniLabel);
                    EditorUIUtils.UnIndent();
                }

                EditorUIUtils.DrawProperty(outline, () => me.Outline = outline.boolValue);
                if (outline.boolValue)
                {
                    EditorUIUtils.Indent();
                    EditorUIUtils.DrawProperty(outlineColor, () => me.OutlineColor       = outlineColor.colorValue);
                    EditorUIUtils.DrawProperty(outlineDistance, () => me.OutlineDistance = outlineDistance.vector2Value);
                    EditorGUILayout.LabelField(new GUIContent("<b>This effect is <color=#FF4040ff>very</color> resource-heavy!</b>", "Such effect significantly increases resources usage on each text refresh. Use only if really necessary."), EditorUIUtils.richMiniLabel);
                    EditorUIUtils.UnIndent();
                }

                EditorUIUtils.Header("Service Commands");

                using (EditorUIUtils.Horizontal())
                {
                    groupAnchor = (LabelAnchor)EditorGUILayout.EnumPopup(
                        new GUIContent("Move All To", "Use to explicitly move all counters to the specified anchor label.\n" +
                                       "Select anchor and press Apply."), groupAnchor);

                    if (GUILayout.Button(new GUIContent("Apply", "Press to move all counters to the selected anchor label."),
                                         GUILayout.Width(45)))
                    {
                        Undo.RegisterCompleteObjectUndo(target, "Move all counters to anchor");

                        me.fpsCounter.Anchor     = groupAnchor;
                        fpsAnchor.enumValueIndex = (int)groupAnchor;

                        me.memoryCounter.Anchor     = groupAnchor;
                        memoryAnchor.enumValueIndex = (int)groupAnchor;

                        me.deviceInfoCounter.Anchor = groupAnchor;
                        deviceAnchor.enumValueIndex = (int)groupAnchor;
                    }
                }
                EditorGUIUtility.labelWidth = 0;
            }

            if (EditorUIUtils.Foldout(advancedFoldout, "Advanced Settings"))
            {
                EditorGUIUtility.labelWidth = 120;
                EditorUIUtils.DrawProperty(sortingOrder, () => me.SortingOrder = sortingOrder.intValue);
                EditorGUIUtility.labelWidth = 0;
            }

            GUI.enabled           = EditorUIUtils.ToggleFoldout(fpsEnabled, fps, "FPS Counter");
            me.fpsCounter.Enabled = fpsEnabled.boolValue;

            if (fps.isExpanded)
            {
                EditorGUIUtility.labelWidth = 120;

                EditorUIUtils.DrawProperty(fpsInterval, "Interval", () => me.fpsCounter.UpdateInterval = fpsInterval.floatValue);
                EditorUIUtils.DrawProperty(fpsAnchor, () => me.fpsCounter.Anchor = (LabelAnchor)fpsAnchor.enumValueIndex);
                EditorUIUtils.Separator(5);

                float minVal = fpsCriticalLevelValue.intValue;
                float maxVal = fpsWarningLevelValue.intValue;

                EditorGUILayout.MinMaxSlider(new GUIContent("Colors Range",
                                                            "This range will be used to apply colors below on specific FPS:\n" +
                                                            "Critical: 0 - min\n" +
                                                            "Warning: min+1 - max-1\n" +
                                                            "Normal: max+"),
                                             ref minVal, ref maxVal, 1, 60);

                fpsCriticalLevelValue.intValue = (int)minVal;
                fpsWarningLevelValue.intValue  = (int)maxVal;

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(fpsColor, "Normal", () => me.fpsCounter.Color = fpsColor.colorValue);
                    GUILayout.Label(maxVal + "+ FPS", GUILayout.Width(75));
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(fpsColorWarning, "Warning", () => me.fpsCounter.ColorWarning = fpsColorWarning.colorValue);
                    GUILayout.Label((minVal + 1) + " - " + (maxVal - 1) + " FPS", GUILayout.Width(75));
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(fpsColorCritical, "Critical", () => me.fpsCounter.ColorCritical = fpsColorCritical.colorValue);
                    GUILayout.Label("0 - " + minVal + " FPS", GUILayout.Width(75));
                }

                EditorUIUtils.Separator(5);

                EditorUIUtils.DrawProperty(fpsStyle, () => me.fpsCounter.Style = (FontStyle)fpsStyle.enumValueIndex);

                EditorUIUtils.Separator(5);
                EditorUIUtils.DrawProperty(fpsMilliseconds, () => me.fpsCounter.Milliseconds      = fpsMilliseconds.boolValue);
                EditorUIUtils.DrawProperty(fpsAverage, "Average FPS", () => me.fpsCounter.Average = fpsAverage.boolValue);

                if (fpsAverage.boolValue)
                {
                    EditorUIUtils.Indent();
                    EditorUIUtils.DrawProperty(fpsAverageSamples, "Samples", () => me.fpsCounter.AverageSamples = fpsAverageSamples.intValue);
                    EditorUIUtils.DrawProperty(fpsAverageMilliseconds, "Milliseconds", () => me.fpsCounter.AverageMilliseconds = fpsAverageMilliseconds.boolValue);
                    EditorUIUtils.DrawProperty(fpsAverageNewLine, "New Line", () => me.fpsCounter.AverageNewLine = fpsAverageNewLine.boolValue);
                    using (EditorUIUtils.Horizontal())
                    {
                        EditorGUILayout.PropertyField(fpsResetAverageOnNewScene, new GUIContent("Auto Reset"), GUILayout.ExpandWidth(false));
                        if (GUILayout.Button("Reset", /*GUILayout.MaxWidth(200),*/ GUILayout.MinWidth(40)))
                        {
                            me.fpsCounter.ResetAverage();
                        }
                    }

                    EditorUIUtils.UnIndent();
                }

                EditorUIUtils.DrawProperty(fpsMinMax, "MinMax FPS", () => me.fpsCounter.MinMax = fpsMinMax.boolValue);

                if (fpsMinMax.boolValue)
                {
                    EditorUIUtils.Indent();
                    EditorGUILayout.PropertyField(fpsMinMaxIntervalsToSkip, new GUIContent("Delay"));
                    EditorUIUtils.DrawProperty(fpsMinMaxMilliseconds, "Milliseconds", () => me.fpsCounter.MinMaxMilliseconds = fpsMinMaxMilliseconds.boolValue);
                    EditorUIUtils.DrawProperty(fpsMinMaxNewLine, "New Line", () => me.fpsCounter.MinMaxNewLine    = fpsMinMaxNewLine.boolValue);
                    EditorUIUtils.DrawProperty(fpsMinMaxTwoLines, "Two Lines", () => me.fpsCounter.MinMaxTwoLines = fpsMinMaxTwoLines.boolValue);
                    using (EditorUIUtils.Horizontal())
                    {
                        EditorGUILayout.PropertyField(fpsResetMinMaxOnNewScene, new GUIContent("Auto Reset"), GUILayout.ExpandWidth(false));
                        if (GUILayout.Button("Reset", /*GUILayout.MaxWidth(200),*/ GUILayout.MinWidth(40)))
                        {
                            me.fpsCounter.ResetMinMax();
                        }
                    }
                    EditorUIUtils.UnIndent();
                }

                EditorUIUtils.DrawProperty(fpsRender, "Render Time", () => me.fpsCounter.Render = fpsRender.boolValue);
                if (fpsRender.boolValue)
                {
                    EditorUIUtils.Indent();
                    EditorUIUtils.DrawProperty(fpsColorRender, "Color", () => me.fpsCounter.ColorRender        = fpsColorRender.colorValue);
                    EditorUIUtils.DrawProperty(fpsRenderNewLine, "New Line", () => me.fpsCounter.RenderNewLine = fpsRenderNewLine.boolValue);
                    EditorUIUtils.DrawProperty(fpsRenderAutoAdd, "Auto add", () => me.fpsCounter.RenderAutoAdd = fpsRenderAutoAdd.boolValue);
                    EditorUIUtils.UnIndent();
                }

                EditorGUIUtility.labelWidth = 0;
            }
            GUI.enabled = true;

            GUI.enabled = EditorUIUtils.ToggleFoldout(memoryEnabled, memory, "Memory Counter");
            me.memoryCounter.Enabled = memoryEnabled.boolValue;
            if (memory.isExpanded)
            {
                EditorGUIUtility.labelWidth = 100;

                EditorUIUtils.DrawProperty(memoryInterval, "Interval", () => me.memoryCounter.UpdateInterval = memoryInterval.floatValue);
                EditorUIUtils.DrawProperty(memoryAnchor, () => me.memoryCounter.Anchor = (LabelAnchor)memoryAnchor.enumValueIndex);
                EditorUIUtils.DrawProperty(memoryColor, () => me.memoryCounter.Color   = memoryColor.colorValue);
                EditorUIUtils.DrawProperty(memoryStyle, () => me.memoryCounter.Style   = (FontStyle)memoryStyle.enumValueIndex);
                EditorGUILayout.Space();
                EditorUIUtils.DrawProperty(memoryPrecise, () => me.memoryCounter.Precise             = memoryPrecise.boolValue);
                EditorUIUtils.DrawProperty(memoryTotal, () => me.memoryCounter.Total                 = memoryTotal.boolValue);
                EditorUIUtils.DrawProperty(memoryAllocated, () => me.memoryCounter.Allocated         = memoryAllocated.boolValue);
                EditorUIUtils.DrawProperty(memoryMonoUsage, "Mono", () => me.memoryCounter.MonoUsage = memoryMonoUsage.boolValue);
#if UNITY_2018_1_OR_NEWER
                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(memoryGfx, "GfxDriver", () => me.memoryCounter.Gfx = memoryGfx.boolValue, GUILayout.ExpandWidth(false));
                    GUILayout.Space(0);
                    if (!EditorUserBuildSettings.development)
                    {
                        EditorGUILayout.LabelField(
                            new GUIContent("works in <b>Development builds</b> only"),
                            EditorUIUtils.richMiniLabel, GUILayout.ExpandWidth(false));
                    }
                }
#endif
                EditorGUIUtility.labelWidth = 0;
            }
            GUI.enabled = true;


            var deviceInfoEnabled = EditorUIUtils.ToggleFoldout(deviceEnabled, device, "Device Information");
            GUI.enabled = deviceInfoEnabled;
            me.deviceInfoCounter.Enabled = deviceEnabled.boolValue;
            if (device.isExpanded)
            {
                EditorGUIUtility.labelWidth = 100;

                EditorUIUtils.DrawProperty(deviceAnchor, () => me.deviceInfoCounter.Anchor = (LabelAnchor)deviceAnchor.intValue);
                EditorUIUtils.DrawProperty(deviceColor, () => me.deviceInfoCounter.Color   = deviceColor.colorValue);
                EditorUIUtils.DrawProperty(deviceStyle, () => me.deviceInfoCounter.Style   = (FontStyle)deviceStyle.enumValueIndex);
                EditorGUILayout.Space();


                EditorUIUtils.DrawProperty(devicePlatform, "Platform", () => me.deviceInfoCounter.Platform = devicePlatform.boolValue);

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(deviceCpuModel, "CPU", () => me.deviceInfoCounter.CpuModel = deviceCpuModel.boolValue, GUILayout.ExpandWidth(false));
                    GUI.enabled = deviceInfoEnabled && deviceCpuModel.boolValue;
                    EditorUIUtils.DrawProperty(deviceCpuModelNewLine, "New Line", () => me.deviceInfoCounter.CpuModelNewLine = deviceCpuModelNewLine.boolValue);
                    GUI.enabled = deviceInfoEnabled;
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(deviceGpuModel, "GPU Model", () => me.deviceInfoCounter.GpuModel = deviceGpuModel.boolValue, GUILayout.ExpandWidth(false));
                    GUI.enabled = deviceInfoEnabled && deviceGpuModel.boolValue;
                    EditorUIUtils.DrawProperty(deviceGpuModelNewLine, "New Line", () => me.deviceInfoCounter.GpuModelNewLine = deviceGpuModelNewLine.boolValue);
                    GUI.enabled = deviceInfoEnabled;
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(deviceGpuApi, "GPU API", () => me.deviceInfoCounter.GpuApi = deviceGpuApi.boolValue, GUILayout.ExpandWidth(false));
                    GUI.enabled = deviceInfoEnabled && deviceGpuApi.boolValue;
                    EditorUIUtils.DrawProperty(deviceGpuApiNewLine, "New Line", () => me.deviceInfoCounter.GpuApiNewLine = deviceGpuApiNewLine.boolValue);
                    GUI.enabled = deviceInfoEnabled;
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(deviceGpuSpec, "GPU Spec", () => me.deviceInfoCounter.GpuSpec = deviceGpuSpec.boolValue, GUILayout.ExpandWidth(false));
                    GUI.enabled = deviceInfoEnabled && deviceGpuSpec.boolValue;
                    EditorUIUtils.DrawProperty(deviceGpuSpecNewLine, "New Line", () => me.deviceInfoCounter.GpuSpecNewLine = deviceGpuSpecNewLine.boolValue);
                    GUI.enabled = deviceInfoEnabled;
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(deviceRamSize, "RAM", () => me.deviceInfoCounter.RamSize = deviceRamSize.boolValue, GUILayout.ExpandWidth(false));
                    GUI.enabled = deviceInfoEnabled && deviceRamSize.boolValue;
                    EditorUIUtils.DrawProperty(deviceRamSizeNewLine, "New Line", () => me.deviceInfoCounter.RamSizeNewLine = deviceRamSizeNewLine.boolValue);
                    GUI.enabled = deviceInfoEnabled;
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(deviceScreenData, "Screen", () => me.deviceInfoCounter.ScreenData = deviceScreenData.boolValue, GUILayout.ExpandWidth(false));
                    GUI.enabled = deviceInfoEnabled && deviceScreenData.boolValue;
                    EditorUIUtils.DrawProperty(deviceScreenDataNewLine, "New Line", () => me.deviceInfoCounter.ScreenDataNewLine = deviceScreenDataNewLine.boolValue);
                    GUI.enabled = deviceInfoEnabled;
                }

                using (EditorUIUtils.Horizontal())
                {
                    EditorUIUtils.DrawProperty(deviceModel, "Model", () => me.deviceInfoCounter.DeviceModel = deviceModel.boolValue, GUILayout.ExpandWidth(false));
                    GUI.enabled = deviceInfoEnabled && deviceModel.boolValue;
                    EditorUIUtils.DrawProperty(deviceModelNewLine, "New Line", () => me.deviceInfoCounter.DeviceModelNewLine = deviceModelNewLine.boolValue);
                    GUI.enabled = deviceInfoEnabled;
                }

                EditorGUIUtility.labelWidth = 0;
            }
            GUI.enabled = true;
            EditorGUILayout.Space();
            serializedObject.ApplyModifiedProperties();
        }
 public override void OnInspectorGUI()
 {
     DrawDefaultInspector();
     EditorUIUtils.SetupStyles();
     GUILayout.Label("This component is used by <b>Advanced FPS Counter</b> to measure camera <b>Render Time</b>.", EditorUIUtils.richMiniLabel);
 }