// ---------------------------------------------------------------------------- // internal methods // ---------------------------------------------------------------------------- internal void MakeDrawableLabelDirty(LabelAnchor anchor) { if (operationMode == OperationMode.Normal) { labels[(int)anchor].dirty = true; } }
internal void MakeDrawableLabelDirty(LabelAnchor anchor) { if (this.operationMode == AFPSCounterOperationMode.Normal) { this.labels[(int)anchor].dirty = true; } }
public DrawableLabel(LabelAnchor anchor, Vector2 pixelOffset, Font font, int fontSize, float lineSpacing) { this.anchor = anchor; this.pixelOffset = pixelOffset; this.font = font; this.fontSize = fontSize; this.lineSpacing = lineSpacing; this.NormalizeOffset(); this.newText = new StringBuilder(1000); }
internal void CheckAndUpdate() { if (this.newText.Length > 0) { if (this.guiText == null) { GameObject gameObject = new GameObject(this.anchor.ToString(), new Type[] { typeof(GUIText) }); this.guiText = gameObject.guiText; if (this.anchor == LabelAnchor.UpperLeft) { gameObject.transform.position = new Vector3(0f, 1f); this.guiText.anchor = TextAnchor.UpperLeft; this.guiText.alignment = TextAlignment.Left; } else if (this.anchor == LabelAnchor.UpperRight) { gameObject.transform.position = new Vector3(1f, 1f); this.guiText.anchor = TextAnchor.UpperRight; this.guiText.alignment = TextAlignment.Right; } else if (this.anchor == LabelAnchor.LowerLeft) { gameObject.transform.position = new Vector3(0f, 0f); this.guiText.anchor = TextAnchor.LowerLeft; this.guiText.alignment = TextAlignment.Left; } else if (this.anchor == LabelAnchor.LowerRight) { gameObject.transform.position = new Vector3(1f, 0f); this.guiText.anchor = TextAnchor.LowerRight; this.guiText.alignment = TextAlignment.Right; } this.guiText.pixelOffset = this.pixelOffset; this.guiText.font = this.font; this.guiText.fontSize = this.fontSize; this.guiText.lineSpacing = this.lineSpacing; gameObject.layer = AFPSCounter.Instance.gameObject.layer; gameObject.tag = AFPSCounter.Instance.gameObject.tag; gameObject.transform.parent = AFPSCounter.Instance.transform; } if (this.dirty) { this.guiText.text = this.newText.ToString(); this.dirty = false; } this.newText.Length = 0; } else if (this.guiText != null) { UnityEngine.Object.DestroyImmediate(this.guiText.gameObject); } }
// ---------------------------------------------------------------------------- // constructor // ---------------------------------------------------------------------------- internal DrawableLabel(Canvas canvas, LabelAnchor anchor, Vector2 pixelOffset, Font font, int fontSize, float lineSpacing) { this.canvas = canvas; this.anchor = anchor; this.pixelOffset = pixelOffset; this.font = font; this.fontSize = fontSize; this.lineSpacing = lineSpacing; NormalizeOffset(); newText = new StringBuilder(1000); }
// ---------------------------------------------------------------------------- // constructor // ---------------------------------------------------------------------------- internal DrawableLabel(GameObject container, LabelAnchor anchor, LabelEffect shadow, LabelEffect outline, Font font, int fontSize, float lineSpacing, Vector2 pixelOffset) { this.container = container; this.anchor = anchor; this.shadow = shadow; this.outline = outline; this.font = font; this.fontSize = fontSize; this.lineSpacing = lineSpacing; this.pixelOffset = pixelOffset; NormalizeOffset(); newText = new StringBuilder(1000); }
static LabelAnchor MoveAnchorToBottom(LabelAnchor anchor) { switch (anchor) { case LabelAnchor.UpperCenter: return(LabelAnchor.LowerCenter); case LabelAnchor.UpperLeft: return(LabelAnchor.LowerLeft); case LabelAnchor.UpperRight: return(LabelAnchor.LowerRight); default: return(anchor); } }
void InternalOpen() { if (!open) { open = true; inputField.enabled = true; ClearTildeKeyInput(); inputField.ActivateInputField(); inputField.MoveTextEnd(false); var fpsCounter = Bowhead.GameManager.instance.fpsCounter; if (fpsCounter != null) { fpsAnchor = fpsCounter.fpsCounter.Anchor; memAnchor = fpsCounter.memoryCounter.Anchor; gpuAnchor = fpsCounter.deviceInfoCounter.Anchor; fpsCounter.fpsCounter.Anchor = MoveAnchorToBottom(fpsCounter.fpsCounter.Anchor); fpsCounter.memoryCounter.Anchor = MoveAnchorToBottom(fpsCounter.memoryCounter.Anchor); fpsCounter.deviceInfoCounter.Anchor = MoveAnchorToBottom(fpsCounter.deviceInfoCounter.Anchor); } } }
public override void OnInspectorGUI() { if (me == null) { return; } serializedObject.Update(); EditorUIUtils.SetupStyles(); GUILayout.Space(5); #region Main Settings EditorGUIUtility.labelWidth = 120; EditorUIUtils.DrawProperty(operationMode, () => me.OperationMode = (OperationMode)operationMode.enumValueIndex); EditorGUILayout.PropertyField(hotKey); EditorGUIUtility.labelWidth = 0; using (EditorUIUtils.Horizontal()) { GUILayout.FlexibleSpace(); EditorGUIUtility.labelWidth = 60; 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(45)); 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); } #endregion #region Look & Feel 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, "Color", () => me.ShadowColor = shadowColor.colorValue); EditorUIUtils.DrawProperty(shadowDistance, "Distance", () => 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, "Color", () => me.OutlineColor = outlineColor.colorValue); EditorUIUtils.DrawProperty(outlineDistance, "Distance", () => 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; } #endregion #region Advanced Settings if (EditorUIUtils.Foldout(advancedFoldout, "Advanced Settings")) { EditorGUIUtility.labelWidth = 120; EditorUIUtils.DrawProperty(sortingOrder, () => me.SortingOrder = sortingOrder.intValue); EditorGUIUtility.labelWidth = 0; } #endregion #region FPS Counter GUI.enabled = EditorUIUtils.ToggleFoldout(fpsEnabled, fps, "FPS Counter"); me.fpsCounter.Enabled = fpsEnabled.boolValue; if (fps.isExpanded) { GUILayout.Space(5); EditorGUIUtility.labelWidth = 100; EditorUIUtils.DrawProperty(fpsInterval, "Interval", () => me.fpsCounter.UpdateInterval = fpsInterval.floatValue); EditorUIUtils.DrawProperty(fpsAnchor, () => me.fpsCounter.Anchor = (LabelAnchor)fpsAnchor.enumValueIndex); GUILayout.Space(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)); } GUILayout.Space(5); EditorUIUtils.DrawProperty(fpsStyle, () => me.fpsCounter.Style = (FontStyle)fpsStyle.enumValueIndex); EditorUIUtils.Separator(5); EditorGUIUtility.labelWidth = 120; GUI.enabled = EditorUIUtils.ToggleFoldout(fpsRealtime, realtimeFPSFoldout, "Realtime FPS", false, false, false); me.fpsCounter.RealtimeFPS = fpsRealtime.boolValue; if (realtimeFPSFoldout.isExpanded) { EditorUIUtils.DoubleIndent(); EditorUIUtils.DrawProperty(fpsMilliseconds, () => me.fpsCounter.Milliseconds = fpsMilliseconds.boolValue); EditorUIUtils.DoubleUnIndent(); } GUI.enabled = true; GUI.enabled = EditorUIUtils.ToggleFoldout(fpsAverage, averageFoldout, "Average FPS", false, false, false); me.fpsCounter.Average = fpsAverage.boolValue; if (averageFoldout.isExpanded) { EditorUIUtils.DoubleIndent(); 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.DoubleUnIndent(); } GUI.enabled = true; GUI.enabled = EditorUIUtils.ToggleFoldout(fpsMinMax, minMaxFoldout, "MinMax FPS", false, false, false); me.fpsCounter.MinMax = fpsMinMax.boolValue; if (minMaxFoldout.isExpanded) { EditorUIUtils.DoubleIndent(); 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.DoubleUnIndent(); } GUI.enabled = true; GUI.enabled = EditorUIUtils.ToggleFoldout(fpsRender, renderFoldout, "Render Time", false, false, false); me.fpsCounter.Render = fpsRender.boolValue; if (renderFoldout.isExpanded) { EditorUIUtils.DoubleIndent(); 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.DoubleUnIndent(); } GUI.enabled = true; EditorGUIUtility.labelWidth = 0; } GUI.enabled = true; #endregion #region Memory Counter GUI.enabled = EditorUIUtils.ToggleFoldout(memoryEnabled, memory, "Memory Counter"); me.memoryCounter.Enabled = memoryEnabled.boolValue; if (memory.isExpanded) { GUILayout.Space(5); 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); EditorUIUtils.Separator(5); EditorUIUtils.DrawProperty(memoryPrecise, () => me.memoryCounter.Precise = memoryPrecise.boolValue); EditorUIUtils.Separator(5); 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); using (EditorUIUtils.Horizontal()) { EditorUIUtils.DrawProperty(memoryGfx, "GfxDriver", () => me.memoryCounter.Gfx = memoryGfx.boolValue, GUILayout.ExpandWidth(false)); GUILayout.Space(0); string extraInfo = null; var color = EditorGUIUtility.isProSkin ? "#FF6060" : "#FF1010"; extraInfo = "<color=\"" + color + "\">Unity 2018.1+ required</color>"; if (!string.IsNullOrEmpty(extraInfo)) { EditorGUILayout.LabelField( new GUIContent(extraInfo), EditorUIUtils.richMiniLabel, GUILayout.ExpandWidth(false)); } } EditorGUIUtility.labelWidth = 0; } GUI.enabled = true; #endregion #region Device Information var deviceInfoEnabled = EditorUIUtils.ToggleFoldout(deviceEnabled, device, "Device Information"); GUI.enabled = deviceInfoEnabled; me.deviceInfoCounter.Enabled = deviceEnabled.boolValue; if (device.isExpanded) { GUILayout.Space(5); 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); EditorUIUtils.Separator(5); 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; GUILayout.Space(10); EditorGUIUtility.labelWidth = 60; EditorUIUtils.DrawProperty(deviceCpuModelNewLine, "New Line", () => me.deviceInfoCounter.CpuModelNewLine = deviceCpuModelNewLine.boolValue); EditorGUIUtility.labelWidth = 100; GUI.enabled = deviceInfoEnabled; } using (EditorUIUtils.Horizontal()) { EditorUIUtils.DrawProperty(deviceGpuModel, "GPU Model", () => me.deviceInfoCounter.GpuModel = deviceGpuModel.boolValue, GUILayout.ExpandWidth(false)); GUI.enabled = deviceInfoEnabled && deviceGpuModel.boolValue; GUILayout.Space(10); EditorGUIUtility.labelWidth = 60; EditorUIUtils.DrawProperty(deviceGpuModelNewLine, "New Line", () => me.deviceInfoCounter.GpuModelNewLine = deviceGpuModelNewLine.boolValue); EditorGUIUtility.labelWidth = 100; GUI.enabled = deviceInfoEnabled; } using (EditorUIUtils.Horizontal()) { EditorUIUtils.DrawProperty(deviceGpuApi, "GPU API", () => me.deviceInfoCounter.GpuApi = deviceGpuApi.boolValue, GUILayout.ExpandWidth(false)); GUI.enabled = deviceInfoEnabled && deviceGpuApi.boolValue; GUILayout.Space(10); EditorGUIUtility.labelWidth = 60; EditorUIUtils.DrawProperty(deviceGpuApiNewLine, "New Line", () => me.deviceInfoCounter.GpuApiNewLine = deviceGpuApiNewLine.boolValue); EditorGUIUtility.labelWidth = 100; GUI.enabled = deviceInfoEnabled; } using (EditorUIUtils.Horizontal()) { EditorUIUtils.DrawProperty(deviceGpuSpec, "GPU Spec", () => me.deviceInfoCounter.GpuSpec = deviceGpuSpec.boolValue, GUILayout.ExpandWidth(false)); GUI.enabled = deviceInfoEnabled && deviceGpuSpec.boolValue; GUILayout.Space(10); EditorGUIUtility.labelWidth = 60; EditorUIUtils.DrawProperty(deviceGpuSpecNewLine, "New Line", () => me.deviceInfoCounter.GpuSpecNewLine = deviceGpuSpecNewLine.boolValue); EditorGUIUtility.labelWidth = 100; GUI.enabled = deviceInfoEnabled; } using (EditorUIUtils.Horizontal()) { EditorUIUtils.DrawProperty(deviceRamSize, "RAM", () => me.deviceInfoCounter.RamSize = deviceRamSize.boolValue, GUILayout.ExpandWidth(false)); GUI.enabled = deviceInfoEnabled && deviceRamSize.boolValue; GUILayout.Space(10); EditorGUIUtility.labelWidth = 60; EditorUIUtils.DrawProperty(deviceRamSizeNewLine, "New Line", () => me.deviceInfoCounter.RamSizeNewLine = deviceRamSizeNewLine.boolValue); EditorGUIUtility.labelWidth = 100; GUI.enabled = deviceInfoEnabled; } using (EditorUIUtils.Horizontal()) { EditorUIUtils.DrawProperty(deviceScreenData, "Screen", () => me.deviceInfoCounter.ScreenData = deviceScreenData.boolValue, GUILayout.ExpandWidth(false)); GUI.enabled = deviceInfoEnabled && deviceScreenData.boolValue; GUILayout.Space(10); EditorGUIUtility.labelWidth = 60; EditorUIUtils.DrawProperty(deviceScreenDataNewLine, "New Line", () => me.deviceInfoCounter.ScreenDataNewLine = deviceScreenDataNewLine.boolValue); EditorGUIUtility.labelWidth = 100; GUI.enabled = deviceInfoEnabled; } using (EditorUIUtils.Horizontal()) { EditorUIUtils.DrawProperty(deviceModel, "Model", () => me.deviceInfoCounter.DeviceModel = deviceModel.boolValue, GUILayout.ExpandWidth(false)); GUI.enabled = deviceInfoEnabled && deviceModel.boolValue; GUILayout.Space(10); EditorGUIUtility.labelWidth = 60; EditorUIUtils.DrawProperty(deviceModelNewLine, "New Line", () => me.deviceInfoCounter.DeviceModelNewLine = deviceModelNewLine.boolValue); EditorGUIUtility.labelWidth = 100; GUI.enabled = deviceInfoEnabled; } EditorGUIUtility.labelWidth = 0; } GUI.enabled = true; #endregion EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (self == null) { return; } serializedObject.Update(); int indent = EditorGUI.indentLevel; if (PropertyFieldChanged(operationMode, new GUIContent("Operation Mode", "Disabled: removes labels and stops all internal processes except Hot Key listener\n\nBackground: removes labels keeping counters alive; use for hidden performance monitoring\n\nNormal: shows labels and runs all internal processes as usual"))) { self.OperationMode = (OperationMode)operationMode.enumValueIndex; } EditorGUILayout.PropertyField(hotKey, new GUIContent("Hot Key", "Used to enable / disable plugin. Set to None to disable")); EditorGUILayout.PropertyField(keepAlive, new GUIContent("Keep Alive", "Prevent current Game Object from destroying on level (scene) load")); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (PropertyFieldChanged(forceFrameRate, new GUIContent("Force FPS", "Allows to see how your game performs on specified frame rate.\nDoes not guarantee selected frame rate. Set -1 to render as fast as possible in current conditions.\nIMPORTANT: this option disables VSync while enabled!"))) { self.ForceFrameRate = forceFrameRate.boolValue; } //EditorGUI.indentLevel = 1; if (PropertyFieldChanged(forcedFrameRate, new GUIContent(""))) { self.ForcedFrameRate = forcedFrameRate.intValue; } //EditorGUI.indentLevel = indent; EditorGUILayout.EndHorizontal(); if (Foldout(lookAndFeelToggle, "Look and feel")) { EditorGUI.indentLevel = 1; EditorGUIUtility.fieldWidth = 70; if (PropertyFieldChanged(labelsFont, new GUIContent("Labels font", "Leave blank to use default font"))) { self.LabelsFont = (Font)labelsFont.objectReferenceValue; } if (PropertyFieldChanged(fontSize, new GUIContent("Font size", "Set to 0 to use font size specified in the font importer"))) { self.FontSize = fontSize.intValue; } if (PropertyFieldChanged(lineSpacing, new GUIContent("Line spacing", "Space between lines in labels"))) { self.LineSpacing = lineSpacing.floatValue; } if (PropertyFieldChanged(countersSpacing, new GUIContent("Counters spacing", "Lines count between different counters in a single label"))) { self.CountersSpacing = countersSpacing.intValue; } EditorGUIUtility.wideMode = true; if (PropertyFieldChanged(anchorsOffset, new GUIContent("Pixel offset", "Offset in pixels, will be applied to all 4 corners automatically"))) { self.AnchorsOffset = anchorsOffset.vector2Value; } EditorGUIUtility.wideMode = false; GUILayout.BeginHorizontal(); groupAnchor = (LabelAnchor)EditorGUILayout.EnumPopup(new GUIContent("Move all to", "Use to explicitly move all counters to the specified anchor label.\nSelect anchor and press Apply"), groupAnchor); if (GUILayout.Button(new GUIContent("Apply", "Press to move all counters to the selected anchor label"), GUILayout.Width(45))) { self.fpsCounter.Anchor = groupAnchor; fpsCounterAnchor.enumValueIndex = (int)groupAnchor; self.memoryCounter.Anchor = groupAnchor; memoryCounterAnchor.enumValueIndex = (int)groupAnchor; self.deviceInfoCounter.Anchor = groupAnchor; deviceCounterAnchor.enumValueIndex = (int)groupAnchor; } GUILayout.EndHorizontal(); EditorGUIUtility.fieldWidth = 0; EditorGUI.indentLevel = indent; EditorGUILayout.Space(); } if (ToggleFoldout(fpsGroupToggle, "FPS Counter", fpsCounterEnabled)) { self.fpsCounter.Enabled = fpsCounterEnabled.boolValue; } if (fpsGroupToggle.boolValue) { EditorGUI.indentLevel = 2; if (PropertyFieldChanged(fpsCounterUpdateInterval, new GUIContent("Interval", "Update interval in seconds"))) { self.fpsCounter.UpdateInterval = fpsCounterUpdateInterval.floatValue; } if (PropertyFieldChanged(fpsCounterAnchor)) { self.fpsCounter.Anchor = (LabelAnchor)fpsCounterAnchor.enumValueIndex; } float minVal = fpsCounterCriticalLevelValue.intValue; float maxVal = fpsCounterWarningLevelValue.intValue; EditorGUILayout.MinMaxSlider(new GUIContent("Colors range", "This range will be used to apply colors below on specific FPS:\nCritical: 0 - min\nWarning: min+1 - max-1\nNormal: max+"), ref minVal, ref maxVal, 1, 60); fpsCounterCriticalLevelValue.intValue = (int)minVal; fpsCounterWarningLevelValue.intValue = (int)maxVal; GUILayout.BeginHorizontal(); if (PropertyFieldChanged(fpsCounterColor, new GUIContent("Normal"))) { self.fpsCounter.Color = fpsCounterColor.colorValue; } GUILayout.Label(maxVal + "+ FPS", GUILayout.Width(75)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (PropertyFieldChanged(fpsCounterColorWarning, new GUIContent("Warning"))) { self.fpsCounter.ColorWarning = fpsCounterColorWarning.colorValue; } GUILayout.Label((minVal + 1) + " - " + (maxVal - 1) + " FPS", GUILayout.Width(75)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (PropertyFieldChanged(fpsCounterColorCritical, new GUIContent("Critical"))) { self.fpsCounter.ColorCritical = fpsCounterColorCritical.colorValue; } GUILayout.Label("0 - " + minVal + " FPS", GUILayout.Width(75)); GUILayout.EndHorizontal(); EditorGUILayout.Space(); if (PropertyFieldChanged(fpsCounterShowMilliseconds, new GUIContent("Milliseconds", "Shows average time in milliseconds spent to process 1 frame"))) { self.fpsCounter.ShowMilliseconds = fpsCounterShowMilliseconds.boolValue; } if (PropertyFieldChanged(fpsCounterShowAverage, new GUIContent("Average FPS", "Shows Average FPS calculated from specified Samples amount or since game or scene start, depending on Samples value and 'Reset On Load' toggle"))) { self.fpsCounter.ShowAverage = fpsCounterShowAverage.boolValue; } if (fpsCounterShowAverage.boolValue) { EditorGUI.indentLevel = 3; if (PropertyFieldChanged(fpsCounterAverageFromSamples, new GUIContent("Samples", "Amount of last samples to get average from. Set 0 to get average from all samples since startup or level load. One Sample recodred per Interval"))) { self.fpsCounter.AverageFromSamples = fpsCounterAverageFromSamples.intValue; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(fpsCounterResetAverageOnNewScene, new GUIContent("Auto reset", "Average FPS counter accumulative data will be reset on new scene load if enabled")); if (GUILayout.Button("Reset now")) { self.fpsCounter.ResetAverage(); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 2; } if (PropertyFieldChanged(fpsCounterShowMinMax, new GUIContent("MinMax FPS", "Shows minimum and maximum FPS readouts since game or scene start, depending on 'Reset On Load' toggle"))) { self.fpsCounter.ShowMinMax = fpsCounterShowMinMax.boolValue; } if (fpsCounterShowMinMax.boolValue) { EditorGUI.indentLevel = 3; EditorGUILayout.PropertyField(fpsCounterMinMaxIntervalsToSkip, new GUIContent("Delay", "Amount of update intervals to skip before recording minimum and maximum FPS, use it to skip initialization performance spikes and drops")); if (PropertyFieldChanged(fpsCounterMinMaxOnNewLine, new GUIContent("On new line", "Controls placing Min Max on the new line"))) { self.fpsCounter.MinMaxOnNewLine = fpsCounterMinMaxOnNewLine.boolValue; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(fpsCounterResetMinMaxOnNewScene, new GUIContent("Auto reset", "Minimum and maximum FPS readouts will be reset on new scene load if enabled")); if (GUILayout.Button("Reset now")) { self.fpsCounter.ResetMinMax(); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 2; } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } if (ToggleFoldout(memoryGroupToggle, "Memory Counter", memoryCounterEnabled)) { self.memoryCounter.Enabled = memoryCounterEnabled.boolValue; } if (memoryGroupToggle.boolValue) { EditorGUI.indentLevel = 2; if (PropertyFieldChanged(memoryCounterUpdateInterval, new GUIContent("Interval", "Update interval in seconds"))) { self.memoryCounter.UpdateInterval = memoryCounterUpdateInterval.floatValue; } if (PropertyFieldChanged(memoryCounterAnchor)) { self.memoryCounter.Anchor = (LabelAnchor)memoryCounterAnchor.enumValueIndex; } if (PropertyFieldChanged(memoryCounterColor, new GUIContent("Color"))) { self.memoryCounter.Color = memoryCounterColor.colorValue; } EditorGUILayout.Space(); if (PropertyFieldChanged(memoryCounterPreciseValues, new GUIContent("Precise", "Maked memory usage output more precise thus using more system resources (not recommended)"))) { self.memoryCounter.PreciseValues = memoryCounterPreciseValues.boolValue; } if (PropertyFieldChanged(memoryCounterTotalReserved, new GUIContent("Total", "Total reserved memory size"))) { self.memoryCounter.TotalReserved = memoryCounterTotalReserved.boolValue; } if (PropertyFieldChanged(memoryCounterAllocated, new GUIContent("Allocated", "Amount of allocated memory"))) { self.memoryCounter.Allocated = memoryCounterAllocated.boolValue; } if (PropertyFieldChanged(memoryCounterMonoUsage, new GUIContent("Mono", "Amount of memory used by managed Mono objects"))) { self.memoryCounter.MonoUsage = memoryCounterMonoUsage.boolValue; } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } if (ToggleFoldout(deviceGroupToggle, "Device Information", deviceCounterEnabled)) { self.deviceInfoCounter.Enabled = deviceCounterEnabled.boolValue; } if (deviceGroupToggle.boolValue) { EditorGUI.indentLevel = 2; if (PropertyFieldChanged(deviceCounterAnchor)) { self.deviceInfoCounter.Anchor = (LabelAnchor)deviceCounterAnchor.intValue; } if (PropertyFieldChanged(deviceCounterColor, new GUIContent("Color"))) { self.deviceInfoCounter.Color = deviceCounterColor.colorValue; } EditorGUILayout.Space(); if (PropertyFieldChanged(deviceCounterCpuModel, new GUIContent("CPU", "CPU model and cores (including virtual cores from Intel's Hyper Threading) count"))) { self.deviceInfoCounter.CpuModel = deviceCounterCpuModel.boolValue; } if (PropertyFieldChanged(deviceCounterGpuModel, new GUIContent("GPU", "GPU model, graphics API version, supported shader model (if possible), approximate pixel fill-rate in megapixels per second (if possible) and total Video RAM size (if possible)"))) { self.deviceInfoCounter.GpuModel = deviceCounterGpuModel.boolValue; } if (PropertyFieldChanged(deviceCounterRamSize, new GUIContent("RAM", "Total RAM size"))) { self.deviceInfoCounter.RamSize = deviceCounterRamSize.boolValue; } if (PropertyFieldChanged(deviceCounterScreenData, new GUIContent("Screen", "Screen resolution, size and DPI (if possible)"))) { self.deviceInfoCounter.ScreenData = deviceCounterScreenData.boolValue; } EditorGUI.indentLevel = indent; } EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
internal void CheckAndUpdate() { if (newText.Length > 0) { if (guiText == null) { GameObject anchorObject = new GameObject(anchor.ToString()); guiText = anchorObject.AddComponent <GUIText>(); if (anchor == LabelAnchor.UpperLeft) { anchorObject.transform.position = new Vector3(0f, 1f); guiText.anchor = TextAnchor.UpperLeft; guiText.alignment = TextAlignment.Left; } else if (anchor == LabelAnchor.UpperRight) { anchorObject.transform.position = new Vector3(1f, 1f); guiText.anchor = TextAnchor.UpperRight; guiText.alignment = TextAlignment.Right; } else if (anchor == LabelAnchor.LowerLeft) { anchorObject.transform.position = new Vector3(0f, 0f); guiText.anchor = TextAnchor.LowerLeft; guiText.alignment = TextAlignment.Left; } else if (anchor == LabelAnchor.LowerRight) { anchorObject.transform.position = new Vector3(1f, 0f); guiText.anchor = TextAnchor.LowerRight; guiText.alignment = TextAlignment.Right; } else if (anchor == LabelAnchor.UpperCenter) { anchorObject.transform.position = new Vector3(0.5f, 1f); guiText.anchor = TextAnchor.UpperCenter; guiText.alignment = TextAlignment.Center; } else if (anchor == LabelAnchor.LowerCenter) { anchorObject.transform.position = new Vector3(0.5f, 0f); guiText.anchor = TextAnchor.LowerCenter; guiText.alignment = TextAlignment.Center; } else { Debug.LogWarning("[AFPSCounter] Unknown label anchor for " + this); anchor = LabelAnchor.UpperLeft; anchorObject.transform.position = new Vector3(0f, 1f); guiText.anchor = TextAnchor.UpperLeft; guiText.alignment = TextAlignment.Left; } guiText.pixelOffset = pixelOffset; guiText.font = font; guiText.fontSize = fontSize; guiText.lineSpacing = lineSpacing; anchorObject.layer = AFPSCounter.Instance.gameObject.layer; anchorObject.tag = AFPSCounter.Instance.gameObject.tag; anchorObject.transform.parent = AFPSCounter.Instance.transform; } if (dirty) { guiText.text = newText.ToString(); dirty = false; } newText.Length = 0; } else if (guiText != null) { Object.DestroyImmediate(guiText.gameObject); } }
public override void OnInspectorGUI() { if (me == null) { return; } serializedObject.Update(); EditorUIUtils.SetupStyles(); GUILayout.Space(5); EditorUIUtils.DrawProperty(operationMode, () => me.OperationMode = (OperationMode)operationMode.enumValueIndex); EditorGUILayout.PropertyField(hotKey); EditorGUILayout.PropertyField(keepAlive); using (new EditorUIUtils.HorizontalBlock(GUILayout.ExpandWidth(true))) { EditorUIUtils.DrawProperty(forceFrameRate, "Force FPS", () => me.ForceFrameRate = forceFrameRate.boolValue); EditorUIUtils.DrawProperty(forcedFrameRate, GUIContent.none, () => me.ForcedFrameRate = forcedFrameRate.intValue); } if (EditorUIUtils.Foldout(lookAndFeelFoldout, "Look & Feel")) { EditorUIUtils.Indent(); EditorUIUtils.DrawProperty(scaleFactor, () => me.ScaleFactor = scaleFactor.floatValue); 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.Header("Service Commands"); using (new EditorUIUtils.HorizontalBlock()) { 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))) { me.fpsCounter.Anchor = groupAnchor; fpsAnchor.enumValueIndex = (int)groupAnchor; me.memoryCounter.Anchor = groupAnchor; memoryAnchor.enumValueIndex = (int)groupAnchor; me.deviceInfoCounter.Anchor = groupAnchor; deviceAnchor.enumValueIndex = (int)groupAnchor; } } EditorUIUtils.Unindent(); } if (EditorUIUtils.Foldout(advancedFoldout, "Advanced Settings")) { EditorUIUtils.Indent(); EditorUIUtils.DrawProperty(sortingOrder, () => me.SortingOrder = sortingOrder.intValue); EditorUIUtils.Unindent(); } GUI.enabled = EditorUIUtils.ToggleFoldout(fpsEnabled, fpsGroupFoldout, "FPS Counter"); me.fpsCounter.Enabled = fpsEnabled.boolValue; if (fpsGroupFoldout.boolValue) { EditorUIUtils.Indent(); 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 (new EditorUIUtils.HorizontalBlock()) { EditorUIUtils.DrawProperty(fpsColor, "Normal", () => me.fpsCounter.Color = fpsColor.colorValue); GUILayout.Label(maxVal + "+ FPS", GUILayout.Width(75)); } using (new EditorUIUtils.HorizontalBlock()) { EditorUIUtils.DrawProperty(fpsColorWarning, "Warning", () => me.fpsCounter.ColorWarning = fpsColorWarning.colorValue); GUILayout.Label((minVal + 1) + " - " + (maxVal - 1) + " FPS", GUILayout.Width(75)); } using (new EditorUIUtils.HorizontalBlock()) { EditorUIUtils.DrawProperty(fpsColorCritical, "Critical", () => me.fpsCounter.ColorCritical = fpsColorCritical.colorValue); GUILayout.Label("0 - " + minVal + " FPS", GUILayout.Width(75)); } 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); using (new EditorUIUtils.HorizontalBlock()) { EditorGUILayout.PropertyField(fpsResetAverageOnNewScene, new GUIContent("Auto Reset")); if (GUILayout.Button("Reset Now")) { 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(fpsMinMaxNewLine, "New Line", () => me.fpsCounter.MinMaxNewLine = fpsMinMaxNewLine.boolValue); using (new EditorUIUtils.HorizontalBlock()) { EditorGUILayout.PropertyField(fpsResetMinMaxOnNewScene, new GUIContent("Auto Reset")); if (GUILayout.Button("Reset Now")) { me.fpsCounter.ResetMinMax(); } } EditorUIUtils.Unindent(); } EditorUIUtils.Unindent(); } GUI.enabled = true; GUI.enabled = EditorUIUtils.ToggleFoldout(memoryEnabled, memoryGroupFoldout, "Memory Counter"); me.memoryCounter.Enabled = memoryEnabled.boolValue; if (memoryGroupFoldout.boolValue) { EditorUIUtils.Indent(); 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); 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); EditorUIUtils.Unindent(); } GUI.enabled = true; GUI.enabled = EditorUIUtils.ToggleFoldout(deviceEnabled, deviceGroupFoldout, "Device Information"); me.deviceInfoCounter.Enabled = deviceEnabled.boolValue; if (deviceGroupFoldout.boolValue) { EditorUIUtils.Indent(); EditorUIUtils.DrawProperty(deviceAnchor, () => me.deviceInfoCounter.Anchor = (LabelAnchor)deviceAnchor.intValue); EditorUIUtils.DrawProperty(deviceColor, () => me.deviceInfoCounter.Color = deviceColor.colorValue); EditorGUILayout.Space(); EditorUIUtils.DrawProperty(deviceCpuModel, "CPU", () => me.deviceInfoCounter.CpuModel = deviceCpuModel.boolValue); EditorUIUtils.DrawProperty(deviceGpuModel, "GPU", () => me.deviceInfoCounter.GpuModel = deviceGpuModel.boolValue); EditorUIUtils.DrawProperty(deviceRamSize, "RAM", () => me.deviceInfoCounter.RamSize = deviceRamSize.boolValue); EditorUIUtils.DrawProperty(deviceScreenData, "Screen", () => me.deviceInfoCounter.ScreenData = deviceScreenData.boolValue); EditorUIUtils.Unindent(); } GUI.enabled = true; EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (me == null) { return; } serializedObject.Update(); EditorUIUtils.SetupStyles(); GUILayout.Space(5); EditorUIUtils.DrawProperty(operationMode, () => me.OperationMode = (OperationMode)operationMode.enumValueIndex); EditorGUILayout.PropertyField(hotKey); 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; 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); EditorUIUtils.DrawProperty(forcedFrameRate, GUIContent.none, () => me.ForcedFrameRate = forcedFrameRate.intValue); } if (EditorUIUtils.Foldout(lookAndFeelFoldout, "Look & Feel")) { EditorUIUtils.Indent(); EditorUIUtils.DrawProperty(scaleFactor, () => me.ScaleFactor = scaleFactor.floatValue); 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.Header("Effects"); EditorUIUtils.Separator(); 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); 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); 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; } } EditorUIUtils.UnIndent(); } if (EditorUIUtils.Foldout(advancedFoldout, "Advanced Settings")) { EditorUIUtils.Indent(); EditorUIUtils.DrawProperty(sortingOrder, () => me.SortingOrder = sortingOrder.intValue); EditorUIUtils.UnIndent(); } GUI.enabled = EditorUIUtils.ToggleFoldout(fpsEnabled, fps, "FPS Counter"); me.fpsCounter.Enabled = fpsEnabled.boolValue; if (fps.isExpanded) { EditorUIUtils.Indent(); 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(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")); if (GUILayout.Button("Reset Now")) { 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); using (EditorUIUtils.Horizontal()) { EditorGUILayout.PropertyField(fpsResetMinMaxOnNewScene, new GUIContent("Auto Reset")); if (GUILayout.Button("Reset Now")) { me.fpsCounter.ResetMinMax(); } } EditorUIUtils.UnIndent(); } EditorUIUtils.UnIndent(); } GUI.enabled = true; GUI.enabled = EditorUIUtils.ToggleFoldout(memoryEnabled, memory, "Memory Counter"); me.memoryCounter.Enabled = memoryEnabled.boolValue; if (memory.isExpanded) { EditorUIUtils.Indent(); 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); 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); EditorUIUtils.UnIndent(); } GUI.enabled = true; GUI.enabled = EditorUIUtils.ToggleFoldout(deviceEnabled, device, "Device Information"); me.deviceInfoCounter.Enabled = deviceEnabled.boolValue; if (device.isExpanded) { EditorUIUtils.Indent(); EditorUIUtils.DrawProperty(deviceAnchor, () => me.deviceInfoCounter.Anchor = (LabelAnchor)deviceAnchor.intValue); EditorUIUtils.DrawProperty(deviceColor, () => me.deviceInfoCounter.Color = deviceColor.colorValue); EditorGUILayout.Space(); EditorUIUtils.DrawProperty(devicePlatform, "Platform", () => me.deviceInfoCounter.Platform = devicePlatform.boolValue); EditorUIUtils.DrawProperty(deviceCpuModel, "CPU", () => me.deviceInfoCounter.CpuModel = deviceCpuModel.boolValue); EditorUIUtils.DrawProperty(deviceGpuModel, "GPU Model", () => me.deviceInfoCounter.GpuModel = deviceGpuModel.boolValue); EditorUIUtils.DrawProperty(deviceGpuApi, "GPU API", () => me.deviceInfoCounter.GpuApi = deviceGpuApi.boolValue); EditorUIUtils.DrawProperty(deviceGpuSpec, "GPU Spec", () => me.deviceInfoCounter.GpuSpec = deviceGpuSpec.boolValue); EditorUIUtils.DrawProperty(deviceRamSize, "RAM", () => me.deviceInfoCounter.RamSize = deviceRamSize.boolValue); EditorUIUtils.DrawProperty(deviceScreenData, "Screen", () => me.deviceInfoCounter.ScreenData = deviceScreenData.boolValue); EditorUIUtils.UnIndent(); } GUI.enabled = true; EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// For internal usage! /// </summary> internal void MakeDrawableLabelDirty(LabelAnchor anchor) { labels[(int)anchor].dirty = true; }