ChartEditorHelper.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /************************************************/
  2. /* */
  3. /* Copyright (c) 2018 - 2021 monitor1394 */
  4. /* https://github.com/monitor1394 */
  5. /* */
  6. /************************************************/
  7. using UnityEngine;
  8. using UnityEditor;
  9. using System.Collections.Generic;
  10. namespace XCharts
  11. {
  12. public class ChartEditorHelper
  13. {
  14. #if UNITY_2019_3_OR_NEWER
  15. public const float INDENT_WIDTH = 15;
  16. public const float BOOL_WIDTH = 15;
  17. public const float ARROW_WIDTH = 20;
  18. public const float BLOCK_WIDTH = 4;
  19. public const float GAP_WIDTH = 2;
  20. #else
  21. public const float INDENT_WIDTH = 15;
  22. public const float BOOL_WIDTH = 15;
  23. public const float ARROW_WIDTH = 17.2f;
  24. public const float BLOCK_WIDTH = 0;
  25. public const float GAP_WIDTH = 0;
  26. #endif
  27. public class Styles
  28. {
  29. public static readonly GUIStyle headerStyle = EditorStyles.boldLabel;
  30. public static readonly GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout)
  31. {
  32. font = headerStyle.font,
  33. fontStyle = headerStyle.fontStyle,
  34. };
  35. public static readonly GUIContent iconAdd = new GUIContent("+", "Add");
  36. public static readonly GUIContent iconRemove = new GUIContent("-", "Remove");
  37. public static readonly GUIContent iconUp = new GUIContent("↑", "Up");
  38. public static readonly GUIContent iconDown = new GUIContent("↓", "Down");
  39. public static readonly GUIStyle invisibleButton = "InvisibleButton";
  40. }
  41. public static void SecondField(Rect drawRect, SerializedProperty prop)
  42. {
  43. RectOffset offset = new RectOffset(-(int)EditorGUIUtility.labelWidth, 0, 0, 0);
  44. drawRect = offset.Add(drawRect);
  45. EditorGUI.PropertyField(drawRect, prop, GUIContent.none);
  46. drawRect = offset.Remove(drawRect);
  47. }
  48. public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp,
  49. string name)
  50. {
  51. while (arrayProp.arraySize < 2) arrayProp.arraySize++;
  52. var prop1 = arrayProp.GetArrayElementAtIndex(0);
  53. var prop2 = arrayProp.GetArrayElementAtIndex(1);
  54. MakeTwoField(ref drawRect, rectWidth, prop1, prop2, name);
  55. }
  56. public static void MakeDivideList(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp,
  57. string name, int showNum)
  58. {
  59. while (arrayProp.arraySize < showNum) arrayProp.arraySize++;
  60. EditorGUI.LabelField(drawRect, name);
  61. #if UNITY_2019_3_OR_NEWER
  62. var gap = 2;
  63. #else
  64. var gap = 0;
  65. #endif
  66. var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + gap;
  67. var dataWidTotal = (rectWidth - (startX + INDENT_WIDTH + 1));
  68. EditorGUI.DrawRect(new Rect(startX, drawRect.y, dataWidTotal, drawRect.height), Color.grey);
  69. var dataWid = dataWidTotal / showNum;
  70. var xWid = dataWid - gap;
  71. for (int i = 0; i < 1; i++)
  72. {
  73. drawRect.x = startX + i * xWid;
  74. drawRect.width = dataWid + (EditorGUI.indentLevel - 2) * 40.5f;
  75. EditorGUI.PropertyField(drawRect, arrayProp.GetArrayElementAtIndex(i), GUIContent.none);
  76. }
  77. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  78. }
  79. public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty prop1,
  80. SerializedProperty prop2, string name)
  81. {
  82. EditorGUI.LabelField(drawRect, name);
  83. var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
  84. var diff = 14 + EditorGUI.indentLevel * 14;
  85. var offset = diff - INDENT_WIDTH;
  86. var tempWidth = (rectWidth - startX + diff) / 2;
  87. var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
  88. var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height);
  89. EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
  90. EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
  91. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  92. }
  93. public static void MakeVector2(ref Rect drawRect, float rectWidth, SerializedProperty prop, string name)
  94. {
  95. EditorGUI.LabelField(drawRect, name);
  96. var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
  97. var diff = 14 + EditorGUI.indentLevel * 14;
  98. var offset = diff - INDENT_WIDTH;
  99. var tempWidth = (rectWidth - startX + diff) / 2;
  100. var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
  101. var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height);
  102. var x = EditorGUI.FloatField(centerXRect, prop.vector3Value.x);
  103. var y = EditorGUI.FloatField(centerYRect, prop.vector3Value.y);
  104. prop.vector3Value = new Vector3(x, y);
  105. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  106. }
  107. public static void MakeJsonData(ref Rect drawRect, ref bool showTextArea, ref string inputString,
  108. SerializedProperty prop, float currentWidth, float diff = 0)
  109. {
  110. SerializedProperty stringDataProp = prop.FindPropertyRelative("m_JsonData");
  111. SerializedProperty needParseProp = prop.FindPropertyRelative("m_DataFromJson");
  112. float defalutX = drawRect.x;
  113. drawRect.x = EditorGUIUtility.labelWidth + ARROW_WIDTH + diff;
  114. drawRect.width = currentWidth - EditorGUIUtility.labelWidth - GAP_WIDTH - diff;
  115. if (GUI.Button(drawRect, new GUIContent("Parse JsonData", "Parse data from input json")))
  116. {
  117. showTextArea = !showTextArea;
  118. bool needParse = !showTextArea;
  119. if (needParse)
  120. {
  121. stringDataProp.stringValue = inputString;
  122. needParseProp.boolValue = true;
  123. }
  124. }
  125. drawRect.x = defalutX;
  126. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  127. if (showTextArea)
  128. {
  129. drawRect.width = currentWidth;
  130. drawRect.height = EditorGUIUtility.singleLineHeight * 4;
  131. inputString = EditorGUI.TextArea(drawRect, inputString);
  132. drawRect.y += EditorGUIUtility.singleLineHeight * 4 + EditorGUIUtility.standardVerticalSpacing;
  133. drawRect.height = EditorGUIUtility.singleLineHeight;
  134. }
  135. }
  136. public static bool MakeFoldout(ref Rect drawRect, ref bool moduleToggle, string content,
  137. SerializedProperty prop = null, bool bold = false)
  138. {
  139. float defaultWidth = drawRect.width;
  140. float defaultX = drawRect.x;
  141. var style = bold ? Styles.foldoutStyle : EditorStyles.foldout;
  142. drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH;
  143. moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, true, style);
  144. MakeBool(drawRect, prop);
  145. drawRect.width = defaultWidth;
  146. drawRect.x = defaultX;
  147. return moduleToggle;
  148. }
  149. public static bool MakeFoldout(ref Rect drawRect, Dictionary<string, float> heights,
  150. Dictionary<string, bool> moduleToggle, string key, string content, SerializedProperty prop, bool bold = false)
  151. {
  152. float defaultWidth = drawRect.width;
  153. float defaultX = drawRect.x;
  154. var style = bold ? Styles.foldoutStyle : EditorStyles.foldout;
  155. drawRect.width = EditorGUIUtility.labelWidth;
  156. moduleToggle[key] = EditorGUI.Foldout(drawRect, moduleToggle[key], content, true, style);
  157. if (prop != null)
  158. {
  159. if (prop.propertyType == SerializedPropertyType.Boolean)
  160. {
  161. MakeBool(drawRect, prop);
  162. }
  163. else
  164. {
  165. drawRect.x = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + ARROW_WIDTH;
  166. drawRect.width = defaultWidth - drawRect.x + ARROW_WIDTH - 2;
  167. if (XChartsSettings.editorBlockEnable)
  168. {
  169. drawRect.x += BLOCK_WIDTH;
  170. }
  171. EditorGUI.PropertyField(drawRect, prop, GUIContent.none);
  172. }
  173. }
  174. drawRect.width = defaultWidth;
  175. drawRect.x = defaultX;
  176. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  177. heights[key] += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  178. return moduleToggle[key];
  179. }
  180. public static void MakeBool(Rect drawRect, SerializedProperty boolProp, int index = 0, string name = null)
  181. {
  182. float defaultWidth = drawRect.width;
  183. float defaultX = drawRect.x;
  184. float boolWidth = index * (BOOL_WIDTH + GAP_WIDTH);
  185. drawRect.x = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + ARROW_WIDTH + boolWidth;
  186. if (XChartsSettings.editorBlockEnable)
  187. {
  188. drawRect.x += BLOCK_WIDTH;
  189. }
  190. drawRect.width = (EditorGUI.indentLevel + 1) * BOOL_WIDTH + index * 110;
  191. if (boolProp != null)
  192. {
  193. EditorGUI.PropertyField(drawRect, boolProp, GUIContent.none);
  194. if (!string.IsNullOrEmpty(name))
  195. {
  196. drawRect.x += BOOL_WIDTH;
  197. drawRect.width = 200;
  198. EditorGUI.LabelField(drawRect, name);
  199. }
  200. }
  201. drawRect.width = defaultWidth;
  202. drawRect.x = defaultX;
  203. }
  204. public static bool MakeFoldout(ref Rect drawRect, ref float height, ref Dictionary<string, bool> moduleToggle,
  205. SerializedProperty prop, string moduleName, string showPropName, bool bold = false)
  206. {
  207. var relativeProp = prop.FindPropertyRelative(showPropName);
  208. var flag = MakeFoldout(ref drawRect, ref moduleToggle, prop, moduleName, relativeProp, bold);
  209. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  210. height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  211. return flag;
  212. }
  213. public static bool MakeFoldout(ref Rect drawRect, ref Dictionary<string, bool> moduleToggle, SerializedProperty prop,
  214. string moduleName, SerializedProperty showProp = null, bool bold = false)
  215. {
  216. var key = prop.propertyPath;
  217. if (!moduleToggle.ContainsKey(key))
  218. {
  219. moduleToggle.Add(key, false);
  220. }
  221. var toggle = moduleToggle[key];
  222. float defaultWidth = drawRect.width;
  223. float defaultX = drawRect.x;
  224. #if UNITY_2019_3_OR_NEWER
  225. drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH;
  226. #else
  227. drawRect.width = EditorGUIUtility.labelWidth;
  228. #endif
  229. var displayName = string.IsNullOrEmpty(moduleName) ? prop.displayName : moduleName;
  230. var foldoutStyle = bold ? Styles.foldoutStyle : EditorStyles.foldout;
  231. toggle = EditorGUI.Foldout(drawRect, toggle, displayName, true, foldoutStyle);
  232. if (moduleToggle[key] != toggle)
  233. {
  234. moduleToggle[key] = toggle;
  235. }
  236. if (showProp != null)
  237. {
  238. drawRect.x = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + ARROW_WIDTH;
  239. if (showProp.propertyType == SerializedPropertyType.Boolean)
  240. {
  241. drawRect.width = (EditorGUI.indentLevel + 1) * BOOL_WIDTH;
  242. }
  243. else
  244. {
  245. drawRect.width = defaultWidth - drawRect.x + ARROW_WIDTH - GAP_WIDTH;
  246. }
  247. if (XChartsSettings.editorBlockEnable)
  248. {
  249. drawRect.x += BLOCK_WIDTH;
  250. }
  251. EditorGUI.PropertyField(drawRect, showProp, GUIContent.none);
  252. }
  253. drawRect.width = defaultWidth;
  254. drawRect.x = defaultX;
  255. return toggle;
  256. }
  257. public static bool MakeListWithFoldout(ref Rect drawRect, SerializedProperty listProp, bool foldout,
  258. bool showOrder = false, bool showSize = true)
  259. {
  260. var height = 0f;
  261. return MakeListWithFoldout(ref drawRect, ref height, listProp, foldout, showOrder, showSize);
  262. }
  263. public static bool MakeListWithFoldout(ref Rect drawRect, ref float height, SerializedProperty listProp,
  264. bool foldout, bool showOrder = false, bool showSize = true)
  265. {
  266. var rawWidth = drawRect.width;
  267. drawRect.width = EditorGUIUtility.labelWidth + 10;
  268. bool flag = EditorGUI.Foldout(drawRect, foldout, listProp.displayName, true);
  269. height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  270. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  271. drawRect.width = rawWidth;
  272. if (flag)
  273. {
  274. MakeList(ref drawRect, ref height, listProp, showOrder, showSize);
  275. }
  276. return flag;
  277. }
  278. public static void MakeList(ref Rect drawRect, SerializedProperty listProp, bool showOrder = false,
  279. bool showSize = true)
  280. {
  281. var height = 0f;
  282. MakeList(ref drawRect, ref height, listProp, showOrder, showSize);
  283. }
  284. public static void MakeList(ref Rect drawRect, ref float height, SerializedProperty listProp,
  285. bool showOrder = false, bool showSize = true)
  286. {
  287. EditorGUI.indentLevel++;
  288. var listSize = listProp.arraySize;
  289. var iconWidth = 14;
  290. var iconGap = 3f;
  291. if (showSize)
  292. {
  293. if (showOrder)
  294. {
  295. var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
  296. var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth + 2, drawRect.height);
  297. var iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
  298. if (XChartsSettings.editorBlockEnable)
  299. {
  300. iconRect.x += BLOCK_WIDTH;
  301. }
  302. var oldColor = GUI.contentColor;
  303. GUI.contentColor = Color.black;
  304. if (GUI.Button(iconRect, Styles.iconAdd, Styles.invisibleButton))
  305. {
  306. if (listProp.displayName.Equals("Series"))
  307. {
  308. AddSerieEditor.chart = listProp.serializedObject.targetObject as BaseChart;
  309. AddSerieEditor.ShowWindow();
  310. }
  311. else
  312. {
  313. listProp.arraySize++;
  314. }
  315. }
  316. GUI.contentColor = oldColor;
  317. listSize = listProp.arraySize;
  318. listSize = EditorGUI.IntField(elementRect, "Size", listSize);
  319. }
  320. else
  321. {
  322. listSize = EditorGUI.IntField(drawRect, "Size", listSize);
  323. }
  324. if (listSize < 0) listSize = 0;
  325. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  326. height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  327. if (listSize != listProp.arraySize)
  328. {
  329. while (listSize > listProp.arraySize) listProp.arraySize++;
  330. while (listSize < listProp.arraySize) listProp.arraySize--;
  331. }
  332. }
  333. if (listSize > 30 && !XChartsSettings.editorShowAllListData)
  334. {
  335. SerializedProperty element;
  336. int num = listSize > 10 ? 10 : listSize;
  337. for (int i = 0; i < num; i++)
  338. {
  339. element = listProp.GetArrayElementAtIndex(i);
  340. EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i));
  341. drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  342. height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  343. }
  344. if (num >= 10)
  345. {
  346. EditorGUI.LabelField(drawRect, "...");
  347. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  348. height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  349. element = listProp.GetArrayElementAtIndex(listSize - 1);
  350. EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + (listSize - 1)));
  351. drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  352. height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  353. }
  354. }
  355. else
  356. {
  357. for (int i = 0; i < listProp.arraySize; i++)
  358. {
  359. SerializedProperty element = listProp.GetArrayElementAtIndex(i);
  360. if (showOrder)
  361. {
  362. var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
  363. var isSerie = "Serie".Equals(element.type);
  364. var elementRect = isSerie
  365. ? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * iconGap, drawRect.height)
  366. : new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height);
  367. EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i));
  368. var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
  369. if (XChartsSettings.editorBlockEnable)
  370. {
  371. iconRect.x += BLOCK_WIDTH;
  372. }
  373. var oldColor = GUI.contentColor;
  374. GUI.contentColor = Color.black;
  375. if (GUI.Button(iconRect, Styles.iconUp, Styles.invisibleButton))
  376. {
  377. if (i > 0) listProp.MoveArrayElement(i, i - 1);
  378. }
  379. iconRect = new Rect(drawRect.width - 2 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
  380. if (XChartsSettings.editorBlockEnable)
  381. {
  382. iconRect.x += BLOCK_WIDTH;
  383. }
  384. if (GUI.Button(iconRect, Styles.iconDown, Styles.invisibleButton))
  385. {
  386. if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
  387. }
  388. iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
  389. if (XChartsSettings.editorBlockEnable)
  390. {
  391. iconRect.x += BLOCK_WIDTH;
  392. }
  393. if (GUI.Button(iconRect, Styles.iconRemove, Styles.invisibleButton))
  394. {
  395. if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
  396. }
  397. else
  398. {
  399. drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  400. height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  401. }
  402. GUI.contentColor = oldColor;
  403. }
  404. else
  405. {
  406. EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i));
  407. drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  408. height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
  409. }
  410. }
  411. }
  412. EditorGUI.indentLevel--;
  413. }
  414. public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key,
  415. SerializedProperty prop)
  416. {
  417. if (prop == null) return false;
  418. EditorGUI.PropertyField(drawRect, prop, true);
  419. var hig = EditorGUI.GetPropertyHeight(prop);
  420. drawRect.y += hig;
  421. heights[key] += hig;
  422. return true;
  423. }
  424. public static bool PropertyFieldWithMinValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
  425. SerializedProperty prop, float minValue)
  426. {
  427. if (prop == null) return false;
  428. EditorGUI.PropertyField(drawRect, prop, true);
  429. if (prop.propertyType == SerializedPropertyType.Float && prop.floatValue < minValue)
  430. prop.floatValue = minValue;
  431. if (prop.propertyType == SerializedPropertyType.Integer && prop.intValue < minValue)
  432. prop.intValue = (int)minValue;
  433. var hig = EditorGUI.GetPropertyHeight(prop);
  434. drawRect.y += hig;
  435. heights[key] += hig;
  436. return true;
  437. }
  438. public static bool PropertyFieldWithMaxValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
  439. SerializedProperty prop, float maxValue)
  440. {
  441. if (prop == null) return false;
  442. EditorGUI.PropertyField(drawRect, prop, true);
  443. if (prop.propertyType == SerializedPropertyType.Float && prop.floatValue > maxValue)
  444. prop.floatValue = maxValue;
  445. if (prop.propertyType == SerializedPropertyType.Integer && prop.intValue > maxValue)
  446. prop.intValue = (int)maxValue;
  447. var hig = EditorGUI.GetPropertyHeight(prop);
  448. drawRect.y += hig;
  449. heights[key] += hig;
  450. return true;
  451. }
  452. public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key,
  453. SerializedProperty parentProp, string relativeName)
  454. {
  455. return PropertyField(ref drawRect, heights, key, parentProp.FindPropertyRelative(relativeName));
  456. }
  457. public static bool PropertyFieldWithMinValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
  458. SerializedProperty parentProp, string relativeName, float minValue)
  459. {
  460. var relativeProp = parentProp.FindPropertyRelative(relativeName);
  461. return PropertyFieldWithMinValue(ref drawRect, heights, key, relativeProp, minValue);
  462. }
  463. public static bool PropertyFieldWithMaxValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
  464. SerializedProperty parentProp, string relativeName, float maxValue)
  465. {
  466. var relativeProp = parentProp.FindPropertyRelative(relativeName);
  467. return PropertyFieldWithMaxValue(ref drawRect, heights, key, relativeProp, maxValue);
  468. }
  469. }
  470. }