AFPSCounterEditor.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. #if UNITY_EDITOR
  2. namespace CodeStage.AdvancedFPSCounter.Editor
  3. {
  4. using UI;
  5. using Labels;
  6. using UnityEditor;
  7. using UnityEngine;
  8. [CustomEditor(typeof(AFPSCounter))]
  9. internal class AFPSCounterEditor: Editor
  10. {
  11. private AFPSCounter me;
  12. private SerializedProperty operationMode;
  13. private SerializedProperty fps;
  14. private SerializedProperty fpsEnabled;
  15. private SerializedProperty fpsAnchor;
  16. private SerializedProperty fpsInterval;
  17. private SerializedProperty realtimeFPSFoldout;
  18. private SerializedProperty fpsRealtime;
  19. private SerializedProperty fpsMilliseconds;
  20. private SerializedProperty averageFoldout;
  21. private SerializedProperty fpsAverage;
  22. private SerializedProperty fpsAverageMilliseconds;
  23. private SerializedProperty fpsAverageNewLine;
  24. private SerializedProperty fpsAverageSamples;
  25. private SerializedProperty fpsResetAverageOnNewScene;
  26. private SerializedProperty minMaxFoldout;
  27. private SerializedProperty fpsMinMax;
  28. private SerializedProperty fpsMinMaxMilliseconds;
  29. private SerializedProperty fpsMinMaxNewLine;
  30. private SerializedProperty fpsMinMaxTwoLines;
  31. private SerializedProperty fpsResetMinMaxOnNewScene;
  32. private SerializedProperty fpsMinMaxIntervalsToSkip;
  33. private SerializedProperty renderFoldout;
  34. private SerializedProperty fpsRender;
  35. private SerializedProperty fpsRenderNewLine;
  36. private SerializedProperty fpsRenderAutoAdd;
  37. private SerializedProperty fpsWarningLevelValue;
  38. private SerializedProperty fpsCriticalLevelValue;
  39. private SerializedProperty fpsColor;
  40. private SerializedProperty fpsColorWarning;
  41. private SerializedProperty fpsColorCritical;
  42. private SerializedProperty fpsColorRender;
  43. private SerializedProperty fpsStyle;
  44. private SerializedProperty memory;
  45. private SerializedProperty memoryEnabled;
  46. private SerializedProperty memoryAnchor;
  47. private SerializedProperty memoryColor;
  48. private SerializedProperty memoryStyle;
  49. private SerializedProperty memoryInterval;
  50. private SerializedProperty memoryPrecise;
  51. private SerializedProperty memoryTotal;
  52. private SerializedProperty memoryAllocated;
  53. private SerializedProperty memoryMonoUsage;
  54. private SerializedProperty memoryGfx;
  55. private SerializedProperty device;
  56. private SerializedProperty deviceEnabled;
  57. private SerializedProperty deviceAnchor;
  58. private SerializedProperty deviceColor;
  59. private SerializedProperty deviceStyle;
  60. private SerializedProperty deviceCpuModel;
  61. private SerializedProperty deviceCpuModelNewLine;
  62. private SerializedProperty devicePlatform;
  63. private SerializedProperty deviceGpuModel;
  64. private SerializedProperty deviceGpuModelNewLine;
  65. private SerializedProperty deviceGpuApi;
  66. private SerializedProperty deviceGpuApiNewLine;
  67. private SerializedProperty deviceGpuSpec;
  68. private SerializedProperty deviceGpuSpecNewLine;
  69. private SerializedProperty deviceRamSize;
  70. private SerializedProperty deviceRamSizeNewLine;
  71. private SerializedProperty deviceScreenData;
  72. private SerializedProperty deviceScreenDataNewLine;
  73. private SerializedProperty deviceModel;
  74. private SerializedProperty deviceModelNewLine;
  75. private SerializedProperty lookAndFeelFoldout;
  76. private SerializedProperty autoScale;
  77. private SerializedProperty scaleFactor;
  78. private SerializedProperty labelsFont;
  79. private SerializedProperty fontSize;
  80. private SerializedProperty lineSpacing;
  81. private SerializedProperty countersSpacing;
  82. private SerializedProperty paddingOffset;
  83. private SerializedProperty pixelPerfect;
  84. private SerializedProperty background;
  85. private SerializedProperty backgroundColor;
  86. private SerializedProperty backgroundPadding;
  87. private SerializedProperty shadow;
  88. private SerializedProperty shadowColor;
  89. private SerializedProperty shadowDistance;
  90. private SerializedProperty outline;
  91. private SerializedProperty outlineColor;
  92. private SerializedProperty outlineDistance;
  93. private SerializedProperty advancedFoldout;
  94. private SerializedProperty sortingOrder;
  95. private SerializedProperty hotKey;
  96. private SerializedProperty hotKeyCtrl;
  97. private SerializedProperty hotKeyShift;
  98. private SerializedProperty hotKeyAlt;
  99. private SerializedProperty circleGesture;
  100. private SerializedProperty keepAlive;
  101. private SerializedProperty forceFrameRate;
  102. private SerializedProperty forcedFrameRate;
  103. private LabelAnchor groupAnchor = LabelAnchor.UpperLeft;
  104. public void OnEnable()
  105. {
  106. me = target as AFPSCounter;
  107. operationMode = serializedObject.FindProperty("operationMode");
  108. hotKey = serializedObject.FindProperty("hotKey");
  109. hotKeyCtrl = serializedObject.FindProperty("hotKeyCtrl");
  110. hotKeyShift = serializedObject.FindProperty("hotKeyShift");
  111. hotKeyAlt = serializedObject.FindProperty("hotKeyAlt");
  112. circleGesture = serializedObject.FindProperty("circleGesture");
  113. keepAlive = serializedObject.FindProperty("keepAlive");
  114. forceFrameRate = serializedObject.FindProperty("forceFrameRate");
  115. forcedFrameRate = serializedObject.FindProperty("forcedFrameRate");
  116. lookAndFeelFoldout = serializedObject.FindProperty("lookAndFeelFoldout");
  117. autoScale = serializedObject.FindProperty("autoScale");
  118. scaleFactor = serializedObject.FindProperty("scaleFactor");
  119. labelsFont = serializedObject.FindProperty("labelsFont");
  120. fontSize = serializedObject.FindProperty("fontSize");
  121. lineSpacing = serializedObject.FindProperty("lineSpacing");
  122. countersSpacing = serializedObject.FindProperty("countersSpacing");
  123. paddingOffset = serializedObject.FindProperty("paddingOffset");
  124. pixelPerfect = serializedObject.FindProperty("pixelPerfect");
  125. background = serializedObject.FindProperty("background");
  126. backgroundColor = serializedObject.FindProperty("backgroundColor");
  127. backgroundPadding = serializedObject.FindProperty("backgroundPadding");
  128. shadow = serializedObject.FindProperty("shadow");
  129. shadowColor = serializedObject.FindProperty("shadowColor");
  130. shadowDistance = serializedObject.FindProperty("shadowDistance");
  131. outline = serializedObject.FindProperty("outline");
  132. outlineColor = serializedObject.FindProperty("outlineColor");
  133. outlineDistance = serializedObject.FindProperty("outlineDistance");
  134. advancedFoldout = serializedObject.FindProperty("advancedFoldout");
  135. sortingOrder = serializedObject.FindProperty("sortingOrder");
  136. fps = serializedObject.FindProperty("fpsCounter");
  137. fpsEnabled = fps.FindPropertyRelative("enabled");
  138. fpsInterval = fps.FindPropertyRelative("updateInterval");
  139. fpsAnchor = fps.FindPropertyRelative("anchor");
  140. realtimeFPSFoldout = fps.FindPropertyRelative("realtimeFPSFoldout");
  141. fpsRealtime = fps.FindPropertyRelative("realtimeFPS");
  142. fpsMilliseconds = fps.FindPropertyRelative("milliseconds");
  143. averageFoldout = fps.FindPropertyRelative("averageFoldout");
  144. fpsAverage = fps.FindPropertyRelative("average");
  145. fpsAverageMilliseconds = fps.FindPropertyRelative("averageMilliseconds");
  146. fpsAverageNewLine = fps.FindPropertyRelative("averageNewLine");
  147. fpsAverageSamples = fps.FindPropertyRelative("averageSamples");
  148. fpsResetAverageOnNewScene = fps.FindPropertyRelative("resetAverageOnNewScene");
  149. minMaxFoldout = fps.FindPropertyRelative("minMaxFoldout");
  150. fpsMinMax = fps.FindPropertyRelative("minMax");
  151. fpsMinMaxMilliseconds = fps.FindPropertyRelative("minMaxMilliseconds");
  152. fpsMinMaxNewLine = fps.FindPropertyRelative("minMaxNewLine");
  153. fpsMinMaxTwoLines = fps.FindPropertyRelative("minMaxTwoLines");
  154. fpsResetMinMaxOnNewScene = fps.FindPropertyRelative("resetMinMaxOnNewScene");
  155. fpsMinMaxIntervalsToSkip = fps.FindPropertyRelative("minMaxIntervalsToSkip");
  156. renderFoldout = fps.FindPropertyRelative("renderFoldout");
  157. fpsRender = fps.FindPropertyRelative("render");
  158. fpsRenderNewLine = fps.FindPropertyRelative("renderNewLine");
  159. fpsRenderAutoAdd = fps.FindPropertyRelative("renderAutoAdd");
  160. fpsWarningLevelValue = fps.FindPropertyRelative("warningLevelValue");
  161. fpsCriticalLevelValue = fps.FindPropertyRelative("criticalLevelValue");
  162. fpsColor = fps.FindPropertyRelative("color");
  163. fpsColorWarning = fps.FindPropertyRelative("colorWarning");
  164. fpsColorCritical = fps.FindPropertyRelative("colorCritical");
  165. fpsColorRender = fps.FindPropertyRelative("colorRender");
  166. fpsStyle = fps.FindPropertyRelative("style");
  167. memory = serializedObject.FindProperty("memoryCounter");
  168. memoryEnabled = memory.FindPropertyRelative("enabled");
  169. memoryInterval = memory.FindPropertyRelative("updateInterval");
  170. memoryAnchor = memory.FindPropertyRelative("anchor");
  171. memoryPrecise = memory.FindPropertyRelative("precise");
  172. memoryColor = memory.FindPropertyRelative("color");
  173. memoryStyle = memory.FindPropertyRelative("style");
  174. memoryTotal = memory.FindPropertyRelative("total");
  175. memoryAllocated = memory.FindPropertyRelative("allocated");
  176. memoryMonoUsage = memory.FindPropertyRelative("monoUsage");
  177. memoryGfx = memory.FindPropertyRelative("gfx");
  178. device = serializedObject.FindProperty("deviceInfoCounter");
  179. deviceEnabled = device.FindPropertyRelative("enabled");
  180. deviceAnchor = device.FindPropertyRelative("anchor");
  181. deviceColor = device.FindPropertyRelative("color");
  182. deviceStyle = device.FindPropertyRelative("style");
  183. devicePlatform = device.FindPropertyRelative("platform");
  184. deviceCpuModel = device.FindPropertyRelative("cpuModel");
  185. deviceCpuModelNewLine = device.FindPropertyRelative("cpuModelNewLine");
  186. deviceGpuModel = device.FindPropertyRelative("gpuModel");
  187. deviceGpuModelNewLine = device.FindPropertyRelative("gpuModelNewLine");
  188. deviceGpuApi = device.FindPropertyRelative("gpuApi");
  189. deviceGpuApiNewLine = device.FindPropertyRelative("gpuApiNewLine");
  190. deviceGpuSpec = device.FindPropertyRelative("gpuSpec");
  191. deviceGpuSpecNewLine = device.FindPropertyRelative("gpuSpecNewLine");
  192. deviceRamSize = device.FindPropertyRelative("ramSize");
  193. deviceRamSizeNewLine = device.FindPropertyRelative("ramSizeNewLine");
  194. deviceScreenData = device.FindPropertyRelative("screenData");
  195. deviceScreenDataNewLine = device.FindPropertyRelative("screenDataNewLine");
  196. deviceModel = device.FindPropertyRelative("deviceModel");
  197. deviceModelNewLine = device.FindPropertyRelative("deviceModelNewLine");
  198. }
  199. public override void OnInspectorGUI()
  200. {
  201. if (me == null) return;
  202. serializedObject.Update();
  203. EditorUIUtils.SetupStyles();
  204. GUILayout.Space(5);
  205. #region Main Settings
  206. EditorGUIUtility.labelWidth = 120;
  207. EditorUIUtils.DrawProperty(operationMode, () => me.OperationMode = (OperationMode)operationMode.enumValueIndex);
  208. EditorGUILayout.PropertyField(hotKey);
  209. EditorGUIUtility.labelWidth = 0;
  210. using (EditorUIUtils.Horizontal())
  211. {
  212. GUILayout.FlexibleSpace();
  213. EditorGUIUtility.labelWidth = 60;
  214. EditorGUILayout.PropertyField(hotKeyCtrl, new GUIContent("Ctrl / Cmd", hotKeyCtrl.tooltip), GUILayout.Width(85));
  215. EditorGUIUtility.labelWidth = 20;
  216. EditorGUILayout.PropertyField(hotKeyAlt, new GUIContent("Alt", hotKeyAlt.tooltip), GUILayout.Width(45));
  217. EditorGUIUtility.labelWidth = 35;
  218. EditorGUILayout.PropertyField(hotKeyShift, new GUIContent("Shift", hotKeyShift.tooltip), GUILayout.Width(50));
  219. EditorGUIUtility.labelWidth = 0;
  220. }
  221. EditorGUIUtility.labelWidth = 120;
  222. EditorGUILayout.PropertyField(circleGesture);
  223. EditorGUILayout.PropertyField(keepAlive);
  224. if (me.transform.parent != null)
  225. {
  226. EditorGUILayout.LabelField("Keep Alive option will keep alive root level object (" + me.transform.root.name + ")!", EditorStyles.wordWrappedMiniLabel);
  227. }
  228. using (EditorUIUtils.Horizontal(GUILayout.ExpandWidth(true)))
  229. {
  230. EditorUIUtils.DrawProperty(forceFrameRate, "Force FPS", () => me.ForceFrameRate = forceFrameRate.boolValue, GUILayout.ExpandWidth(false));
  231. GUILayout.Space(2);
  232. EditorUIUtils.DrawProperty(forcedFrameRate, GUIContent.none, () => me.ForcedFrameRate = forcedFrameRate.intValue);
  233. }
  234. #endregion
  235. #region Look & Feel
  236. EditorGUIUtility.labelWidth = 0;
  237. if (EditorUIUtils.Foldout(lookAndFeelFoldout, "Look & Feel"))
  238. {
  239. EditorGUIUtility.labelWidth = 130;
  240. EditorUIUtils.DrawProperty(autoScale, () => me.AutoScale = autoScale.boolValue);
  241. if (autoScale.boolValue)
  242. {
  243. GUI.enabled = false;
  244. }
  245. EditorUIUtils.DrawProperty(scaleFactor, () => me.ScaleFactor = scaleFactor.floatValue);
  246. GUI.enabled = true;
  247. EditorUIUtils.DrawProperty(labelsFont, () => me.LabelsFont = (Font)labelsFont.objectReferenceValue);
  248. EditorUIUtils.DrawProperty(fontSize, () => me.FontSize = fontSize.intValue);
  249. EditorUIUtils.DrawProperty(lineSpacing, () => me.LineSpacing = lineSpacing.floatValue);
  250. EditorUIUtils.DrawProperty(countersSpacing, () => me.CountersSpacing = countersSpacing.intValue);
  251. EditorUIUtils.DrawProperty(paddingOffset, () => me.PaddingOffset = paddingOffset.vector2Value);
  252. EditorUIUtils.DrawProperty(pixelPerfect, () => me.PixelPerfect = pixelPerfect.boolValue);
  253. EditorUIUtils.Header("Effects");
  254. EditorUIUtils.Separator();
  255. EditorUIUtils.DrawProperty(background, () => me.Background = background.boolValue);
  256. if (background.boolValue)
  257. {
  258. EditorUIUtils.Indent();
  259. EditorUIUtils.DrawProperty(backgroundColor, "Color", () => me.BackgroundColor = backgroundColor.colorValue);
  260. EditorUIUtils.DrawProperty(backgroundPadding, "Padding", () => me.BackgroundPadding = backgroundPadding.intValue);
  261. EditorUIUtils.UnIndent();
  262. }
  263. EditorUIUtils.DrawProperty(shadow, () => me.Shadow = shadow.boolValue);
  264. if (shadow.boolValue)
  265. {
  266. EditorUIUtils.Indent();
  267. EditorUIUtils.DrawProperty(shadowColor, "Color", () => me.ShadowColor = shadowColor.colorValue);
  268. EditorUIUtils.DrawProperty(shadowDistance, "Distance", () => me.ShadowDistance = shadowDistance.vector2Value);
  269. EditorGUILayout.LabelField(new GUIContent("<b>This effect is resource-heavy</b>", "Such effect increases resources usage on each text refresh."), EditorUIUtils.richMiniLabel);
  270. EditorUIUtils.UnIndent();
  271. }
  272. EditorUIUtils.DrawProperty(outline, () => me.Outline = outline.boolValue);
  273. if (outline.boolValue)
  274. {
  275. EditorUIUtils.Indent();
  276. EditorUIUtils.DrawProperty(outlineColor, "Color", () => me.OutlineColor = outlineColor.colorValue);
  277. EditorUIUtils.DrawProperty(outlineDistance, "Distance", () => me.OutlineDistance = outlineDistance.vector2Value);
  278. 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);
  279. EditorUIUtils.UnIndent();
  280. }
  281. EditorUIUtils.Header("Service Commands");
  282. using (EditorUIUtils.Horizontal())
  283. {
  284. groupAnchor = (LabelAnchor)EditorGUILayout.EnumPopup(
  285. new GUIContent("Move All To", "Use to explicitly move all counters to the specified anchor label.\n" +
  286. "Select anchor and press Apply."), groupAnchor);
  287. if (GUILayout.Button(new GUIContent("Apply", "Press to move all counters to the selected anchor label."),
  288. GUILayout.Width(45)))
  289. {
  290. Undo.RegisterCompleteObjectUndo(target, "Move all counters to anchor");
  291. me.fpsCounter.Anchor = groupAnchor;
  292. fpsAnchor.enumValueIndex = (int)groupAnchor;
  293. me.memoryCounter.Anchor = groupAnchor;
  294. memoryAnchor.enumValueIndex = (int)groupAnchor;
  295. me.deviceInfoCounter.Anchor = groupAnchor;
  296. deviceAnchor.enumValueIndex = (int)groupAnchor;
  297. }
  298. }
  299. EditorGUIUtility.labelWidth = 0;
  300. }
  301. #endregion
  302. #region Advanced Settings
  303. if (EditorUIUtils.Foldout(advancedFoldout, "Advanced Settings"))
  304. {
  305. EditorGUIUtility.labelWidth = 120;
  306. EditorUIUtils.DrawProperty(sortingOrder, () => me.SortingOrder = sortingOrder.intValue);
  307. EditorGUIUtility.labelWidth = 0;
  308. }
  309. #endregion
  310. #region FPS Counter
  311. GUI.enabled = EditorUIUtils.ToggleFoldout(fpsEnabled, fps, "FPS Counter");
  312. me.fpsCounter.Enabled = fpsEnabled.boolValue;
  313. if (fps.isExpanded)
  314. {
  315. GUILayout.Space(5);
  316. EditorGUIUtility.labelWidth = 100;
  317. EditorUIUtils.DrawProperty(fpsInterval, "Interval", () => me.fpsCounter.UpdateInterval = fpsInterval.floatValue);
  318. EditorUIUtils.DrawProperty(fpsAnchor, () => me.fpsCounter.Anchor = (LabelAnchor)fpsAnchor.enumValueIndex);
  319. GUILayout.Space(5);
  320. float minVal = fpsCriticalLevelValue.intValue;
  321. float maxVal = fpsWarningLevelValue.intValue;
  322. EditorGUILayout.MinMaxSlider(new GUIContent("Colors Range",
  323. "This range will be used to apply colors below on specific FPS:\n" +
  324. "Critical: 0 - min\n" +
  325. "Warning: min+1 - max-1\n" +
  326. "Normal: max+"),
  327. ref minVal, ref maxVal, 1, 60);
  328. fpsCriticalLevelValue.intValue = (int)minVal;
  329. fpsWarningLevelValue.intValue = (int)maxVal;
  330. using (EditorUIUtils.Horizontal())
  331. {
  332. EditorUIUtils.DrawProperty(fpsColor, "Normal", () => me.fpsCounter.Color = fpsColor.colorValue);
  333. GUILayout.Label(maxVal + "+ FPS", GUILayout.Width(75));
  334. }
  335. using (EditorUIUtils.Horizontal())
  336. {
  337. EditorUIUtils.DrawProperty(fpsColorWarning, "Warning", () => me.fpsCounter.ColorWarning = fpsColorWarning.colorValue);
  338. GUILayout.Label(minVal + 1 + " - " + (maxVal - 1) + " FPS", GUILayout.Width(75));
  339. }
  340. using (EditorUIUtils.Horizontal())
  341. {
  342. EditorUIUtils.DrawProperty(fpsColorCritical, "Critical", () => me.fpsCounter.ColorCritical = fpsColorCritical.colorValue);
  343. GUILayout.Label("0 - " + minVal + " FPS", GUILayout.Width(75));
  344. }
  345. GUILayout.Space(5);
  346. EditorUIUtils.DrawProperty(fpsStyle, () => me.fpsCounter.Style = (FontStyle)fpsStyle.enumValueIndex);
  347. EditorUIUtils.Separator(5);
  348. EditorGUIUtility.labelWidth = 120;
  349. GUI.enabled = EditorUIUtils.ToggleFoldout(fpsRealtime, realtimeFPSFoldout, "Realtime FPS", false, false, false);
  350. me.fpsCounter.RealtimeFPS = fpsRealtime.boolValue;
  351. if (realtimeFPSFoldout.isExpanded)
  352. {
  353. EditorUIUtils.DoubleIndent();
  354. EditorUIUtils.DrawProperty(fpsMilliseconds, () => me.fpsCounter.Milliseconds = fpsMilliseconds.boolValue);
  355. EditorUIUtils.DoubleUnIndent();
  356. }
  357. GUI.enabled = true;
  358. GUI.enabled = EditorUIUtils.ToggleFoldout(fpsAverage, averageFoldout, "Average FPS", false, false, false);
  359. me.fpsCounter.Average = fpsAverage.boolValue;
  360. if (averageFoldout.isExpanded)
  361. {
  362. EditorUIUtils.DoubleIndent();
  363. EditorUIUtils.DrawProperty(fpsAverageSamples, "Samples", () => me.fpsCounter.AverageSamples = fpsAverageSamples.intValue);
  364. EditorUIUtils.DrawProperty(fpsAverageMilliseconds, "Milliseconds", () => me.fpsCounter.AverageMilliseconds = fpsAverageMilliseconds.boolValue);
  365. EditorUIUtils.DrawProperty(fpsAverageNewLine, "New Line", () => me.fpsCounter.AverageNewLine = fpsAverageNewLine.boolValue);
  366. using (EditorUIUtils.Horizontal())
  367. {
  368. EditorGUILayout.PropertyField(fpsResetAverageOnNewScene, new GUIContent("Auto Reset"), GUILayout.ExpandWidth(false));
  369. if (GUILayout.Button("Reset", /*GUILayout.MaxWidth(200),*/ GUILayout.MinWidth(40)))
  370. {
  371. me.fpsCounter.ResetAverage();
  372. }
  373. }
  374. EditorUIUtils.DoubleUnIndent();
  375. }
  376. GUI.enabled = true;
  377. GUI.enabled = EditorUIUtils.ToggleFoldout(fpsMinMax, minMaxFoldout, "MinMax FPS", false, false, false);
  378. me.fpsCounter.MinMax = fpsMinMax.boolValue;
  379. if (minMaxFoldout.isExpanded)
  380. {
  381. EditorUIUtils.DoubleIndent();
  382. EditorGUILayout.PropertyField(fpsMinMaxIntervalsToSkip, new GUIContent("Delay"));
  383. EditorUIUtils.DrawProperty(fpsMinMaxMilliseconds, "Milliseconds", () => me.fpsCounter.MinMaxMilliseconds = fpsMinMaxMilliseconds.boolValue);
  384. EditorUIUtils.DrawProperty(fpsMinMaxNewLine, "New Line", () => me.fpsCounter.MinMaxNewLine = fpsMinMaxNewLine.boolValue);
  385. EditorUIUtils.DrawProperty(fpsMinMaxTwoLines, "Two Lines", () => me.fpsCounter.MinMaxTwoLines = fpsMinMaxTwoLines.boolValue);
  386. using (EditorUIUtils.Horizontal())
  387. {
  388. EditorGUILayout.PropertyField(fpsResetMinMaxOnNewScene, new GUIContent("Auto Reset"), GUILayout.ExpandWidth(false));
  389. if (GUILayout.Button("Reset", /*GUILayout.MaxWidth(200),*/ GUILayout.MinWidth(40)))
  390. {
  391. me.fpsCounter.ResetMinMax();
  392. }
  393. }
  394. EditorUIUtils.DoubleUnIndent();
  395. }
  396. GUI.enabled = true;
  397. GUI.enabled = EditorUIUtils.ToggleFoldout(fpsRender, renderFoldout, "Render Time", false, false, false);
  398. me.fpsCounter.Render = fpsRender.boolValue;
  399. if (renderFoldout.isExpanded)
  400. {
  401. EditorUIUtils.DoubleIndent();
  402. EditorUIUtils.DrawProperty(fpsColorRender, "Color", () => me.fpsCounter.ColorRender = fpsColorRender.colorValue);
  403. EditorUIUtils.DrawProperty(fpsRenderNewLine, "New Line", () => me.fpsCounter.RenderNewLine = fpsRenderNewLine.boolValue);
  404. EditorUIUtils.DrawProperty(fpsRenderAutoAdd, "Auto add", () => me.fpsCounter.RenderAutoAdd = fpsRenderAutoAdd.boolValue);
  405. EditorUIUtils.DoubleUnIndent();
  406. }
  407. GUI.enabled = true;
  408. EditorGUIUtility.labelWidth = 0;
  409. }
  410. GUI.enabled = true;
  411. #endregion
  412. #region Memory Counter
  413. GUI.enabled = EditorUIUtils.ToggleFoldout(memoryEnabled, memory, "Memory Counter");
  414. me.memoryCounter.Enabled = memoryEnabled.boolValue;
  415. if (memory.isExpanded)
  416. {
  417. GUILayout.Space(5);
  418. EditorGUIUtility.labelWidth = 100;
  419. EditorUIUtils.DrawProperty(memoryInterval, "Interval", () => me.memoryCounter.UpdateInterval = memoryInterval.floatValue);
  420. EditorUIUtils.DrawProperty(memoryAnchor, () => me.memoryCounter.Anchor = (LabelAnchor)memoryAnchor.enumValueIndex);
  421. EditorUIUtils.DrawProperty(memoryColor, () => me.memoryCounter.Color = memoryColor.colorValue);
  422. EditorUIUtils.DrawProperty(memoryStyle, () => me.memoryCounter.Style = (FontStyle)memoryStyle.enumValueIndex);
  423. EditorUIUtils.Separator(5);
  424. EditorUIUtils.DrawProperty(memoryPrecise, () => me.memoryCounter.Precise = memoryPrecise.boolValue);
  425. EditorUIUtils.Separator(5);
  426. EditorUIUtils.DrawProperty(memoryTotal, () => me.memoryCounter.Total = memoryTotal.boolValue);
  427. EditorUIUtils.DrawProperty(memoryAllocated, () => me.memoryCounter.Allocated = memoryAllocated.boolValue);
  428. EditorUIUtils.DrawProperty(memoryMonoUsage, "Mono", () => me.memoryCounter.MonoUsage = memoryMonoUsage.boolValue);
  429. using (EditorUIUtils.Horizontal())
  430. {
  431. EditorUIUtils.DrawProperty(memoryGfx, "GfxDriver", () => me.memoryCounter.Gfx = memoryGfx.boolValue, GUILayout.ExpandWidth(false));
  432. GUILayout.Space(0);
  433. string extraInfo = null;
  434. var color = EditorGUIUtility.isProSkin ? "#FF6060" : "#FF1010";
  435. extraInfo = "<color=\"" + color + "\">Unity 2018.1+ required</color>";
  436. if (!string.IsNullOrEmpty(extraInfo))
  437. {
  438. EditorGUILayout.LabelField(
  439. new GUIContent(extraInfo),
  440. EditorUIUtils.richMiniLabel, GUILayout.ExpandWidth(false));
  441. }
  442. }
  443. EditorGUIUtility.labelWidth = 0;
  444. }
  445. GUI.enabled = true;
  446. #endregion
  447. #region Device Information
  448. var deviceInfoEnabled = EditorUIUtils.ToggleFoldout(deviceEnabled, device, "Device Information");
  449. GUI.enabled = deviceInfoEnabled;
  450. me.deviceInfoCounter.Enabled = deviceEnabled.boolValue;
  451. if (device.isExpanded)
  452. {
  453. GUILayout.Space(5);
  454. EditorGUIUtility.labelWidth = 100;
  455. EditorUIUtils.DrawProperty(deviceAnchor, () => me.deviceInfoCounter.Anchor = (LabelAnchor)deviceAnchor.intValue);
  456. EditorUIUtils.DrawProperty(deviceColor, () => me.deviceInfoCounter.Color = deviceColor.colorValue);
  457. EditorUIUtils.DrawProperty(deviceStyle, () => me.deviceInfoCounter.Style = (FontStyle)deviceStyle.enumValueIndex);
  458. EditorUIUtils.Separator(5);
  459. EditorUIUtils.DrawProperty(devicePlatform, "Platform", () => me.deviceInfoCounter.Platform = devicePlatform.boolValue);
  460. using (EditorUIUtils.Horizontal())
  461. {
  462. EditorUIUtils.DrawProperty(deviceCpuModel, "CPU", () => me.deviceInfoCounter.CpuModel = deviceCpuModel.boolValue, GUILayout.ExpandWidth(false));
  463. GUI.enabled = deviceInfoEnabled && deviceCpuModel.boolValue;
  464. GUILayout.Space(10);
  465. EditorGUIUtility.labelWidth = 60;
  466. EditorUIUtils.DrawProperty(deviceCpuModelNewLine, "New Line", () => me.deviceInfoCounter.CpuModelNewLine = deviceCpuModelNewLine.boolValue);
  467. EditorGUIUtility.labelWidth = 100;
  468. GUI.enabled = deviceInfoEnabled;
  469. }
  470. using (EditorUIUtils.Horizontal())
  471. {
  472. EditorUIUtils.DrawProperty(deviceGpuModel, "GPU Model", () => me.deviceInfoCounter.GpuModel = deviceGpuModel.boolValue, GUILayout.ExpandWidth(false));
  473. GUI.enabled = deviceInfoEnabled && deviceGpuModel.boolValue;
  474. GUILayout.Space(10);
  475. EditorGUIUtility.labelWidth = 60;
  476. EditorUIUtils.DrawProperty(deviceGpuModelNewLine, "New Line", () => me.deviceInfoCounter.GpuModelNewLine = deviceGpuModelNewLine.boolValue);
  477. EditorGUIUtility.labelWidth = 100;
  478. GUI.enabled = deviceInfoEnabled;
  479. }
  480. using (EditorUIUtils.Horizontal())
  481. {
  482. EditorUIUtils.DrawProperty(deviceGpuApi, "GPU API", () => me.deviceInfoCounter.GpuApi = deviceGpuApi.boolValue, GUILayout.ExpandWidth(false));
  483. GUI.enabled = deviceInfoEnabled && deviceGpuApi.boolValue;
  484. GUILayout.Space(10);
  485. EditorGUIUtility.labelWidth = 60;
  486. EditorUIUtils.DrawProperty(deviceGpuApiNewLine, "New Line", () => me.deviceInfoCounter.GpuApiNewLine = deviceGpuApiNewLine.boolValue);
  487. EditorGUIUtility.labelWidth = 100;
  488. GUI.enabled = deviceInfoEnabled;
  489. }
  490. using (EditorUIUtils.Horizontal())
  491. {
  492. EditorUIUtils.DrawProperty(deviceGpuSpec, "GPU Spec", () => me.deviceInfoCounter.GpuSpec = deviceGpuSpec.boolValue, GUILayout.ExpandWidth(false));
  493. GUI.enabled = deviceInfoEnabled && deviceGpuSpec.boolValue;
  494. GUILayout.Space(10);
  495. EditorGUIUtility.labelWidth = 60;
  496. EditorUIUtils.DrawProperty(deviceGpuSpecNewLine, "New Line", () => me.deviceInfoCounter.GpuSpecNewLine = deviceGpuSpecNewLine.boolValue);
  497. EditorGUIUtility.labelWidth = 100;
  498. GUI.enabled = deviceInfoEnabled;
  499. }
  500. using (EditorUIUtils.Horizontal())
  501. {
  502. EditorUIUtils.DrawProperty(deviceRamSize, "RAM", () => me.deviceInfoCounter.RamSize = deviceRamSize.boolValue, GUILayout.ExpandWidth(false));
  503. GUI.enabled = deviceInfoEnabled && deviceRamSize.boolValue;
  504. GUILayout.Space(10);
  505. EditorGUIUtility.labelWidth = 60;
  506. EditorUIUtils.DrawProperty(deviceRamSizeNewLine, "New Line", () => me.deviceInfoCounter.RamSizeNewLine = deviceRamSizeNewLine.boolValue);
  507. EditorGUIUtility.labelWidth = 100;
  508. GUI.enabled = deviceInfoEnabled;
  509. }
  510. using (EditorUIUtils.Horizontal())
  511. {
  512. EditorUIUtils.DrawProperty(deviceScreenData, "Screen", () => me.deviceInfoCounter.ScreenData = deviceScreenData.boolValue, GUILayout.ExpandWidth(false));
  513. GUI.enabled = deviceInfoEnabled && deviceScreenData.boolValue;
  514. GUILayout.Space(10);
  515. EditorGUIUtility.labelWidth = 60;
  516. EditorUIUtils.DrawProperty(deviceScreenDataNewLine, "New Line", () => me.deviceInfoCounter.ScreenDataNewLine = deviceScreenDataNewLine.boolValue);
  517. EditorGUIUtility.labelWidth = 100;
  518. GUI.enabled = deviceInfoEnabled;
  519. }
  520. using (EditorUIUtils.Horizontal())
  521. {
  522. EditorUIUtils.DrawProperty(deviceModel, "Model", () => me.deviceInfoCounter.DeviceModel = deviceModel.boolValue, GUILayout.ExpandWidth(false));
  523. GUI.enabled = deviceInfoEnabled && deviceModel.boolValue;
  524. GUILayout.Space(10);
  525. EditorGUIUtility.labelWidth = 60;
  526. EditorUIUtils.DrawProperty(deviceModelNewLine, "New Line", () => me.deviceInfoCounter.DeviceModelNewLine = deviceModelNewLine.boolValue);
  527. EditorGUIUtility.labelWidth = 100;
  528. GUI.enabled = deviceInfoEnabled;
  529. }
  530. EditorGUIUtility.labelWidth = 0;
  531. }
  532. GUI.enabled = true;
  533. #endregion
  534. EditorGUILayout.Space();
  535. serializedObject.ApplyModifiedProperties();
  536. }
  537. }
  538. }
  539. #endif