SteamVR_Skeleton_PoserEditor.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEditor;
  6. using UnityEngine;
  7. namespace Valve.VR
  8. {
  9. [CustomEditor(typeof(SteamVR_Skeleton_Poser))]
  10. public class SteamVR_Skeleton_PoserEditor : Editor
  11. {
  12. private SerializedProperty skeletonMainPoseProperty;
  13. private SerializedProperty skeletonAdditionalPosesProperty;
  14. private SerializedProperty showLeftPreviewProperty;
  15. private SerializedProperty showRightPreviewProperty;
  16. private SerializedProperty previewLeftInstanceProperty;
  17. private SerializedProperty previewRightInstanceProperty;
  18. private SerializedProperty previewLeftHandPrefab;
  19. private SerializedProperty previewRightHandPrefab;
  20. private SerializedProperty previewPoseSelection;
  21. private SerializedProperty poseEditorExpanded;
  22. private SerializedProperty blendEditorExpanded;
  23. private SerializedProperty poserScale;
  24. private SerializedProperty blendingBehaviourArray;
  25. Texture handTexL;
  26. Texture handTexR;
  27. private SteamVR_Skeleton_Poser poser;
  28. private bool PoseChanged = false;
  29. protected void OnEnable()
  30. {
  31. skeletonMainPoseProperty = serializedObject.FindProperty("skeletonMainPose");
  32. skeletonAdditionalPosesProperty = serializedObject.FindProperty("skeletonAdditionalPoses");
  33. showLeftPreviewProperty = serializedObject.FindProperty("showLeftPreview");
  34. showRightPreviewProperty = serializedObject.FindProperty("showRightPreview");
  35. previewLeftInstanceProperty = serializedObject.FindProperty("previewLeftInstance");
  36. previewRightInstanceProperty = serializedObject.FindProperty("previewRightInstance");
  37. previewLeftHandPrefab = serializedObject.FindProperty("overridePreviewLeftHandPrefab");
  38. previewRightHandPrefab = serializedObject.FindProperty("overridePreviewRightHandPrefab");
  39. previewPoseSelection = serializedObject.FindProperty("previewPoseSelection");
  40. poseEditorExpanded = serializedObject.FindProperty("poseEditorExpanded");
  41. blendEditorExpanded = serializedObject.FindProperty("blendEditorExpanded");
  42. poserScale = serializedObject.FindProperty("scale");
  43. blendingBehaviourArray = serializedObject.FindProperty("blendingBehaviours");
  44. poser = (SteamVR_Skeleton_Poser)target;
  45. }
  46. protected void LoadDefaultPreviewHands()
  47. {
  48. if (previewLeftHandPrefab.objectReferenceValue == null)
  49. {
  50. previewLeftHandPrefab.objectReferenceValue = SteamVR_Settings.instance.previewHandLeft;
  51. }
  52. if (previewRightHandPrefab.objectReferenceValue == null)
  53. {
  54. previewRightHandPrefab.objectReferenceValue = SteamVR_Settings.instance.previewHandRight;
  55. }
  56. }
  57. protected void UpdatePreviewHand(SerializedProperty instanceProperty, SerializedProperty showPreviewProperty, GameObject previewPrefab, SteamVR_Skeleton_Pose_Hand handData, SteamVR_Skeleton_Pose sourcePose, bool forceUpdate)
  58. {
  59. GameObject preview = instanceProperty.objectReferenceValue as GameObject;
  60. //EditorGUILayout.PropertyField(showPreviewProperty);
  61. if (showPreviewProperty.boolValue)
  62. {
  63. if (forceUpdate && preview != null)
  64. {
  65. DestroyImmediate(preview);
  66. }
  67. if (preview == null)
  68. {
  69. preview = GameObject.Instantiate<GameObject>(previewPrefab);
  70. preview.transform.localScale = Vector3.one * poserScale.floatValue;
  71. preview.transform.parent = poser.transform;
  72. preview.transform.localPosition = Vector3.zero;
  73. preview.transform.localRotation = Quaternion.identity;
  74. SteamVR_Behaviour_Skeleton previewSkeleton = null;
  75. if (preview != null)
  76. previewSkeleton = preview.GetComponent<SteamVR_Behaviour_Skeleton>();
  77. if (previewSkeleton != null)
  78. {
  79. if (handData.bonePositions == null || handData.bonePositions.Length == 0)
  80. {
  81. SteamVR_Skeleton_Pose poseResource = (SteamVR_Skeleton_Pose)Resources.Load("ReferencePose_OpenHand");
  82. DeepCopyPose(poseResource, sourcePose);
  83. EditorUtility.SetDirty(sourcePose);
  84. }
  85. preview.transform.localPosition = Vector3.zero;
  86. preview.transform.localRotation = Quaternion.identity;
  87. preview.transform.parent = null;
  88. preview.transform.localScale = Vector3.one * poserScale.floatValue;
  89. preview.transform.parent = poser.transform;
  90. preview.transform.localRotation = Quaternion.Inverse(handData.rotation);
  91. preview.transform.position = preview.transform.TransformPoint(-handData.position);
  92. for (int boneIndex = 0; boneIndex < handData.bonePositions.Length; boneIndex++)
  93. {
  94. Transform bone = previewSkeleton.GetBone(boneIndex);
  95. bone.localPosition = handData.bonePositions[boneIndex];
  96. bone.localRotation = handData.boneRotations[boneIndex];
  97. }
  98. }
  99. SceneView.RepaintAll();
  100. instanceProperty.objectReferenceValue = preview;
  101. }
  102. }
  103. else
  104. {
  105. if (preview != null)
  106. {
  107. DestroyImmediate(preview);
  108. SceneView.RepaintAll();
  109. }
  110. }
  111. }
  112. protected void ZeroTransformParents(Transform toZero, Transform stopAt)
  113. {
  114. if (toZero == null)
  115. return;
  116. toZero.localPosition = Vector3.zero;
  117. toZero.localRotation = Quaternion.identity;
  118. if (toZero == stopAt)
  119. return;
  120. ZeroTransformParents(toZero.parent, stopAt);
  121. }
  122. protected EVRSkeletalReferencePose defaultReferencePose = EVRSkeletalReferencePose.OpenHand;
  123. protected EVRSkeletalReferencePose forceToReferencePose = EVRSkeletalReferencePose.OpenHand;
  124. protected void SaveHandData(SteamVR_Skeleton_Pose_Hand handData, SteamVR_Behaviour_Skeleton thisSkeleton)
  125. {
  126. handData.position = thisSkeleton.transform.InverseTransformPoint(poser.transform.position);
  127. //handData.position = thisSkeleton.transform.localPosition;
  128. handData.rotation = Quaternion.Inverse(thisSkeleton.transform.localRotation);
  129. handData.bonePositions = new Vector3[SteamVR_Action_Skeleton.numBones];
  130. handData.boneRotations = new Quaternion[SteamVR_Action_Skeleton.numBones];
  131. for (int boneIndex = 0; boneIndex < SteamVR_Action_Skeleton.numBones; boneIndex++)
  132. {
  133. Transform bone = thisSkeleton.GetBone(boneIndex);
  134. handData.bonePositions[boneIndex] = bone.localPosition;
  135. handData.boneRotations[boneIndex] = bone.localRotation;
  136. }
  137. EditorUtility.SetDirty(activePose);
  138. }
  139. protected void DrawHand(bool showHand, SteamVR_Skeleton_Pose_Hand handData, SteamVR_Skeleton_Pose_Hand otherData, bool getFromOpposite, SerializedProperty showPreviewProperty)
  140. {
  141. SteamVR_Behaviour_Skeleton thisSkeleton;
  142. SteamVR_Behaviour_Skeleton oppositeSkeleton;
  143. string thisSourceString;
  144. string oppositeSourceString;
  145. if (handData.inputSource == SteamVR_Input_Sources.LeftHand)
  146. {
  147. thisSkeleton = leftSkeleton;
  148. thisSourceString = "Left Hand";
  149. oppositeSourceString = "Right Hand";
  150. oppositeSkeleton = rightSkeleton;
  151. }
  152. else
  153. {
  154. thisSkeleton = rightSkeleton;
  155. thisSourceString = "Right Hand";
  156. oppositeSourceString = "Left Hand";
  157. oppositeSkeleton = leftSkeleton;
  158. }
  159. if (showHand)
  160. {
  161. if (getFromOpposite)
  162. {
  163. bool confirm = EditorUtility.DisplayDialog("SteamVR", string.Format("This will overwrite your current {0} skeleton data. (with data from the {1} skeleton)", thisSourceString, oppositeSourceString), "Overwrite", "Cancel");
  164. if (confirm)
  165. {
  166. Vector3 reflectedPosition = new Vector3(-oppositeSkeleton.transform.localPosition.x, oppositeSkeleton.transform.localPosition.y, oppositeSkeleton.transform.localPosition.z);
  167. thisSkeleton.transform.localPosition = reflectedPosition;
  168. Quaternion oppositeRotation = oppositeSkeleton.transform.localRotation;
  169. Quaternion reflectedRotation = new Quaternion(-oppositeRotation.x, oppositeRotation.y, oppositeRotation.z, -oppositeRotation.w);
  170. thisSkeleton.transform.localRotation = reflectedRotation;
  171. for (int boneIndex = 0; boneIndex < SteamVR_Action_Skeleton.numBones; boneIndex++)
  172. {
  173. Transform boneThis = thisSkeleton.GetBone(boneIndex);
  174. Transform boneOpposite = oppositeSkeleton.GetBone(boneIndex);
  175. boneThis.localPosition = boneOpposite.localPosition;
  176. boneThis.localRotation = boneOpposite.localRotation;
  177. }
  178. handData.thumbFingerMovementType = otherData.thumbFingerMovementType;
  179. handData.indexFingerMovementType = otherData.indexFingerMovementType;
  180. handData.middleFingerMovementType = otherData.middleFingerMovementType;
  181. handData.ringFingerMovementType = otherData.ringFingerMovementType;
  182. handData.pinkyFingerMovementType = otherData.pinkyFingerMovementType;
  183. EditorUtility.SetDirty(poser.skeletonMainPose);
  184. }
  185. }
  186. }
  187. EditorGUIUtility.labelWidth = 120;
  188. SteamVR_Skeleton_FingerExtensionTypes newThumb = (SteamVR_Skeleton_FingerExtensionTypes)EditorGUILayout.EnumPopup("Thumb movement", handData.thumbFingerMovementType);
  189. SteamVR_Skeleton_FingerExtensionTypes newIndex = (SteamVR_Skeleton_FingerExtensionTypes)EditorGUILayout.EnumPopup("Index movement", handData.indexFingerMovementType);
  190. SteamVR_Skeleton_FingerExtensionTypes newMiddle = (SteamVR_Skeleton_FingerExtensionTypes)EditorGUILayout.EnumPopup("Middle movement", handData.middleFingerMovementType);
  191. SteamVR_Skeleton_FingerExtensionTypes newRing = (SteamVR_Skeleton_FingerExtensionTypes)EditorGUILayout.EnumPopup("Ring movement", handData.ringFingerMovementType);
  192. SteamVR_Skeleton_FingerExtensionTypes newPinky = (SteamVR_Skeleton_FingerExtensionTypes)EditorGUILayout.EnumPopup("Pinky movement", handData.pinkyFingerMovementType);
  193. EditorGUILayout.Space();
  194. EditorGUILayout.PropertyField(showPreviewProperty);
  195. EditorGUIUtility.labelWidth = 0;
  196. if (newThumb != handData.thumbFingerMovementType || newIndex != handData.indexFingerMovementType ||
  197. newMiddle != handData.middleFingerMovementType || newRing != handData.ringFingerMovementType ||
  198. newPinky != handData.pinkyFingerMovementType)
  199. {
  200. handData.thumbFingerMovementType = newThumb;
  201. handData.indexFingerMovementType = newIndex;
  202. handData.middleFingerMovementType = newMiddle;
  203. handData.ringFingerMovementType = newRing;
  204. handData.pinkyFingerMovementType = newPinky;
  205. EditorUtility.SetDirty(poser.skeletonMainPose);
  206. }
  207. }
  208. protected void DrawPoseControlButtons()
  209. {
  210. GameObject leftInstance = previewLeftInstanceProperty.objectReferenceValue as GameObject;
  211. leftSkeleton = null;
  212. if (leftInstance != null)
  213. leftSkeleton = leftInstance.GetComponent<SteamVR_Behaviour_Skeleton>();
  214. GameObject rightInstance = previewRightInstanceProperty.objectReferenceValue as GameObject;
  215. rightSkeleton = null;
  216. if (rightInstance != null)
  217. rightSkeleton = rightInstance.GetComponent<SteamVR_Behaviour_Skeleton>();
  218. //only allow saving if a hand is opened for editing
  219. EditorGUI.BeginDisabledGroup(showRightPreviewProperty.boolValue == false && showLeftPreviewProperty.boolValue == false);
  220. GUI.color = new Color(0.9f, 1.0f, 0.9f);
  221. // save both hands at once, or whichever are being edited
  222. bool save = GUILayout.Button(string.Format("Save Pose"));
  223. if (save)
  224. {
  225. if (showRightPreviewProperty.boolValue)
  226. SaveHandData(activePose.rightHand, rightSkeleton);
  227. if (showLeftPreviewProperty.boolValue)
  228. SaveHandData(activePose.leftHand, leftSkeleton);
  229. }
  230. GUI.color = Color.white;
  231. EditorGUI.EndDisabledGroup();
  232. //MIRRORING
  233. //only allow mirroring if both hands are opened for editing
  234. EditorGUI.BeginDisabledGroup(showRightPreviewProperty.boolValue == false || showLeftPreviewProperty.boolValue == false);
  235. EditorGUILayout.Space();
  236. if (GUILayout.Button("Import Pose"))
  237. {
  238. CopyPoseSelect();
  239. }
  240. EditorGUI.EndDisabledGroup();
  241. GUILayout.Space(32);
  242. GUILayout.Label("Reference Pose:");
  243. EditorGUILayout.Space();
  244. forceToReferencePose = (EVRSkeletalReferencePose)EditorGUILayout.EnumPopup(forceToReferencePose);
  245. GUI.color = new Color(1.0f, 0.73f, 0.7f);
  246. bool forcePose = GUILayout.Button("RESET TO REFERENCE POSE");
  247. GUI.color = Color.white;
  248. if (forcePose)
  249. {
  250. bool confirm = EditorUtility.DisplayDialog("SteamVR", string.Format("This will overwrite your current skeleton data. (with data from the {0} reference pose)", forceToReferencePose.ToString()), "Overwrite", "Cancel");
  251. if (confirm)
  252. {
  253. if (forceToReferencePose == EVRSkeletalReferencePose.GripLimit)
  254. {
  255. // grip limit is controller-specific, the rest use a baked pose
  256. if (showLeftPreviewProperty.boolValue)
  257. leftSkeleton.ForceToReferencePose(forceToReferencePose);
  258. if (showRightPreviewProperty.boolValue)
  259. rightSkeleton.ForceToReferencePose(forceToReferencePose);
  260. }
  261. else
  262. {
  263. SteamVR_Skeleton_Pose poseResource = null;
  264. if (forceToReferencePose == EVRSkeletalReferencePose.OpenHand)
  265. poseResource = (SteamVR_Skeleton_Pose)Resources.Load("ReferencePose_OpenHand");
  266. if (forceToReferencePose == EVRSkeletalReferencePose.Fist)
  267. poseResource = (SteamVR_Skeleton_Pose)Resources.Load("ReferencePose_Fist");
  268. if (forceToReferencePose == EVRSkeletalReferencePose.BindPose)
  269. poseResource = (SteamVR_Skeleton_Pose)Resources.Load("ReferencePose_BindPose");
  270. DeepCopyPose(poseResource, activePose);
  271. }
  272. }
  273. }
  274. }
  275. void CopyPoseSelect()
  276. {
  277. string selected = EditorUtility.OpenFilePanel("Open Skeleton Pose ScriptableObject", Application.dataPath, "asset");
  278. selected = selected.Replace(Application.dataPath, "Assets");
  279. if (selected == null) return;
  280. SteamVR_Skeleton_Pose newPose = (SteamVR_Skeleton_Pose)AssetDatabase.LoadAssetAtPath(selected, typeof(SteamVR_Skeleton_Pose));
  281. if (newPose == null)
  282. {
  283. EditorUtility.DisplayDialog("WARNING", "Asset could not be loaded. Is it not a SteamVR_Skeleton_Pose?", "ok");
  284. return;
  285. }
  286. DeepCopyPose(newPose, activePose);
  287. }
  288. void DeepCopyPose(SteamVR_Skeleton_Pose source, SteamVR_Skeleton_Pose dest)
  289. {
  290. int boneNum = SteamVR_Action_Skeleton.numBones;
  291. if (dest.rightHand.bonePositions == null) dest.rightHand.bonePositions = new Vector3[boneNum];
  292. if (dest.rightHand.boneRotations == null) dest.rightHand.boneRotations = new Quaternion[boneNum];
  293. if (dest.leftHand.bonePositions == null) dest.leftHand.bonePositions = new Vector3[boneNum];
  294. if (dest.leftHand.boneRotations == null) dest.leftHand.boneRotations = new Quaternion[boneNum];
  295. EditorUtility.SetDirty(dest);
  296. // RIGHT HAND COPY
  297. dest.rightHand.position = source.rightHand.position;
  298. dest.rightHand.rotation = source.rightHand.rotation;
  299. for (int boneIndex = 0; boneIndex < boneNum; boneIndex++)
  300. {
  301. dest.rightHand.bonePositions[boneIndex] = source.rightHand.bonePositions[boneIndex];
  302. dest.rightHand.boneRotations[boneIndex] = source.rightHand.boneRotations[boneIndex];
  303. EditorUtility.DisplayProgressBar("Copying...", "Copying right hand pose", (float)boneIndex / (float)boneNum / 2f);
  304. }
  305. dest.rightHand.thumbFingerMovementType = source.rightHand.thumbFingerMovementType;
  306. dest.rightHand.indexFingerMovementType = source.rightHand.indexFingerMovementType;
  307. dest.rightHand.middleFingerMovementType = source.rightHand.middleFingerMovementType;
  308. dest.rightHand.ringFingerMovementType = source.rightHand.ringFingerMovementType;
  309. dest.rightHand.pinkyFingerMovementType = source.rightHand.pinkyFingerMovementType;
  310. // LEFT HAND COPY
  311. dest.leftHand.position = source.leftHand.position;
  312. dest.leftHand.rotation = source.leftHand.rotation;
  313. for (int boneIndex = 0; boneIndex < boneNum; boneIndex++)
  314. {
  315. dest.leftHand.bonePositions[boneIndex] = source.leftHand.bonePositions[boneIndex];
  316. dest.leftHand.boneRotations[boneIndex] = source.leftHand.boneRotations[boneIndex];
  317. EditorUtility.DisplayProgressBar("Copying...", "Copying left hand pose", (float)boneIndex / (float)boneNum / 2f);
  318. }
  319. dest.leftHand.thumbFingerMovementType = source.leftHand.thumbFingerMovementType;
  320. dest.leftHand.indexFingerMovementType = source.leftHand.indexFingerMovementType;
  321. dest.leftHand.middleFingerMovementType = source.leftHand.middleFingerMovementType;
  322. dest.leftHand.ringFingerMovementType = source.leftHand.ringFingerMovementType;
  323. dest.leftHand.pinkyFingerMovementType = source.leftHand.pinkyFingerMovementType;
  324. EditorUtility.SetDirty(dest);
  325. forceUpdateHands = true;
  326. EditorUtility.ClearProgressBar();
  327. }
  328. int activePoseIndex = 0;
  329. SerializedProperty activePoseProp;
  330. SteamVR_Skeleton_Pose activePose;
  331. bool forceUpdateHands = false;
  332. public override void OnInspectorGUI()
  333. {
  334. serializedObject.Update();
  335. DrawPoseEditorMenu();
  336. DrawBlendingBehaviourMenu();
  337. serializedObject.ApplyModifiedProperties();
  338. }
  339. bool getRightFromOpposite = false;
  340. bool getLeftFromOpposite = false;
  341. SteamVR_Behaviour_Skeleton leftSkeleton = null;
  342. SteamVR_Behaviour_Skeleton rightSkeleton = null;
  343. void DrawPoseEditorMenu()
  344. {
  345. if (Application.isPlaying)
  346. {
  347. EditorGUILayout.LabelField("Cannot modify pose while in play mode.");
  348. }
  349. else
  350. {
  351. bool createNew = false;
  352. LoadDefaultPreviewHands();
  353. activePoseIndex = previewPoseSelection.intValue;
  354. if (activePoseIndex == 0)
  355. activePoseProp = skeletonMainPoseProperty;
  356. else
  357. activePoseProp = skeletonAdditionalPosesProperty.GetArrayElementAtIndex(activePoseIndex - 1);
  358. //box containing all pose editing controls
  359. GUILayout.BeginVertical("box");
  360. poseEditorExpanded.boolValue = IndentedFoldoutHeader(poseEditorExpanded.boolValue, "Pose Editor");
  361. if (poseEditorExpanded.boolValue)
  362. {
  363. //show selectable menu of all poses, highlighting the one that is selected
  364. EditorGUILayout.Space();
  365. poser.poseNames = new string[skeletonAdditionalPosesProperty.arraySize + 1];
  366. for (int i = 0; i < skeletonAdditionalPosesProperty.arraySize + 1; i++)
  367. {
  368. if (i == 0)
  369. // main pose special case
  370. poser.poseNames[i] = skeletonMainPoseProperty.objectReferenceValue == null ? "[not set]" : skeletonMainPoseProperty.objectReferenceValue.name + " (MAIN)";
  371. else
  372. // additional poses from array
  373. poser.poseNames[i] = skeletonAdditionalPosesProperty.GetArrayElementAtIndex(i - 1).objectReferenceValue == null ? "[not set]" : skeletonAdditionalPosesProperty.GetArrayElementAtIndex(i - 1).objectReferenceValue.name;
  374. }
  375. EditorGUILayout.BeginHorizontal();
  376. int poseSelected = GUILayout.Toolbar(activePoseIndex, poser.poseNames);
  377. if (poseSelected != activePoseIndex)
  378. {
  379. forceUpdateHands = true;
  380. activePoseIndex = poseSelected;
  381. PoseChanged = true;
  382. previewPoseSelection.intValue = activePoseIndex;
  383. serializedObject.ApplyModifiedProperties();
  384. }
  385. EditorGUILayout.BeginVertical(GUILayout.MaxWidth(32));
  386. if (GUILayout.Button("+", GUILayout.MaxWidth(32)))
  387. {
  388. skeletonAdditionalPosesProperty.InsertArrayElementAtIndex(skeletonAdditionalPosesProperty.arraySize);
  389. }
  390. //only allow deletion of additional poses
  391. EditorGUI.BeginDisabledGroup(skeletonAdditionalPosesProperty.arraySize == 0 || activePoseIndex == 0);
  392. if (GUILayout.Button("-", GUILayout.MaxWidth(32)) && skeletonAdditionalPosesProperty.arraySize > 0)
  393. {
  394. skeletonAdditionalPosesProperty.DeleteArrayElementAtIndex(activePoseIndex - 1);
  395. skeletonAdditionalPosesProperty.DeleteArrayElementAtIndex(activePoseIndex - 1);
  396. if (activePoseIndex >= skeletonAdditionalPosesProperty.arraySize + 1)
  397. {
  398. activePoseIndex = skeletonAdditionalPosesProperty.arraySize;
  399. previewPoseSelection.intValue = activePoseIndex;
  400. return;
  401. }
  402. }
  403. EditorGUI.EndDisabledGroup();
  404. EditorGUILayout.EndVertical();
  405. GUILayout.FlexibleSpace();
  406. EditorGUILayout.EndHorizontal();
  407. GUILayout.BeginVertical("box");
  408. // sides of pose editor
  409. GUILayout.BeginHorizontal();
  410. //pose controls
  411. GUILayout.BeginVertical(GUILayout.MaxWidth(200));
  412. GUILayout.Label("Current Pose:");
  413. if (PoseChanged)
  414. {
  415. PoseChanged = false;
  416. forceUpdateHands = true;
  417. if (activePoseIndex == 0)
  418. activePoseProp = skeletonMainPoseProperty;
  419. else
  420. activePoseProp = skeletonAdditionalPosesProperty.GetArrayElementAtIndex(activePoseIndex - 1);
  421. activePose = (SteamVR_Skeleton_Pose)activePoseProp.objectReferenceValue;
  422. }
  423. activePose = (SteamVR_Skeleton_Pose)activePoseProp.objectReferenceValue;
  424. if (activePoseProp.objectReferenceValue == null)
  425. {
  426. if (previewLeftInstanceProperty.objectReferenceValue != null)
  427. DestroyImmediate(previewLeftInstanceProperty.objectReferenceValue);
  428. if (previewRightInstanceProperty.objectReferenceValue != null)
  429. DestroyImmediate(previewRightInstanceProperty.objectReferenceValue);
  430. EditorGUILayout.BeginHorizontal();
  431. activePoseProp.objectReferenceValue = EditorGUILayout.ObjectField(activePoseProp.objectReferenceValue, typeof(SteamVR_Skeleton_Pose), false);
  432. if (GUILayout.Button("Create")) createNew = true;
  433. EditorGUILayout.EndHorizontal();
  434. if (createNew)
  435. {
  436. string fullPath = EditorUtility.SaveFilePanelInProject("Create New Skeleton Pose", "newPose", "asset", "Save file");
  437. if (string.IsNullOrEmpty(fullPath) == false)
  438. {
  439. SteamVR_Skeleton_Pose newPose = ScriptableObject.CreateInstance<SteamVR_Skeleton_Pose>();
  440. AssetDatabase.CreateAsset(newPose, fullPath);
  441. AssetDatabase.SaveAssets();
  442. activePoseProp.objectReferenceValue = newPose;
  443. serializedObject.ApplyModifiedProperties();
  444. }
  445. }
  446. }
  447. else
  448. {
  449. activePoseProp.objectReferenceValue = EditorGUILayout.ObjectField(activePoseProp.objectReferenceValue, typeof(SteamVR_Skeleton_Pose), false);
  450. DrawPoseControlButtons();
  451. UpdatePreviewHand(previewLeftInstanceProperty, showLeftPreviewProperty, SteamVR_Settings.instance.previewHandLeft, activePose.leftHand, activePose, forceUpdateHands);
  452. UpdatePreviewHand(previewRightInstanceProperty, showRightPreviewProperty, SteamVR_Settings.instance.previewHandRight, activePose.rightHand, activePose, forceUpdateHands);
  453. forceUpdateHands = false;
  454. GUILayout.EndVertical();
  455. GUILayout.Space(10);
  456. if (handTexL == null)
  457. handTexL = (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/HandLeftIcon.png");
  458. if (handTexR == null)
  459. handTexR = (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/HandRightIcon.png");
  460. //Left Hand
  461. GUILayout.Space(32);
  462. EditorGUILayout.BeginVertical();
  463. EditorGUILayout.BeginVertical("box");
  464. EditorGUILayout.BeginHorizontal();
  465. GUI.color = new Color(1, 1, 1, showLeftPreviewProperty.boolValue ? 1 : 0.25f);
  466. if (GUILayout.Button(handTexL, GUI.skin.label, GUILayout.Width(64), GUILayout.Height(64)))
  467. {
  468. showLeftPreviewProperty.boolValue = !showLeftPreviewProperty.boolValue;
  469. //forceUpdateHands = true;
  470. }
  471. GUI.color = Color.white;
  472. EditorGUIUtility.labelWidth = 48;
  473. EditorGUILayout.LabelField("Left Hand", EditorStyles.boldLabel);
  474. EditorGUIUtility.labelWidth = 0;
  475. GUILayout.FlexibleSpace();
  476. EditorGUILayout.EndHorizontal();
  477. bool showLeft = showLeftPreviewProperty.boolValue;
  478. DrawHand(showLeft, activePose.leftHand, activePose.rightHand, getLeftFromOpposite, showLeftPreviewProperty);
  479. EditorGUILayout.EndVertical();
  480. EditorGUI.BeginDisabledGroup((showLeftPreviewProperty.boolValue && showRightPreviewProperty.boolValue) == false);
  481. getRightFromOpposite = GUILayout.Button("Copy Left pose to Right hand");
  482. EditorGUI.EndDisabledGroup();
  483. EditorGUILayout.EndVertical();
  484. EditorGUILayout.BeginVertical();
  485. EditorGUILayout.BeginVertical("box");
  486. EditorGUILayout.BeginHorizontal();
  487. GUILayout.FlexibleSpace();
  488. EditorGUIUtility.labelWidth = 48;
  489. EditorGUILayout.LabelField("Right Hand", EditorStyles.boldLabel);
  490. EditorGUIUtility.labelWidth = 0;
  491. GUI.color = new Color(1, 1, 1, showRightPreviewProperty.boolValue ? 1 : 0.25f);
  492. if (GUILayout.Button(handTexR, GUI.skin.label, GUILayout.Width(64), GUILayout.Height(64)))
  493. {
  494. showRightPreviewProperty.boolValue = !showRightPreviewProperty.boolValue;
  495. //forceUpdateHands = true;
  496. }
  497. GUI.color = Color.white;
  498. EditorGUILayout.EndHorizontal();
  499. bool showRight = showLeftPreviewProperty.boolValue;
  500. DrawHand(showRight, activePose.rightHand, activePose.leftHand, getRightFromOpposite, showRightPreviewProperty);
  501. EditorGUILayout.EndVertical();
  502. EditorGUI.BeginDisabledGroup((showLeftPreviewProperty.boolValue && showRightPreviewProperty.boolValue) == false);
  503. getLeftFromOpposite = GUILayout.Button("Copy Right pose to Left hand");
  504. EditorGUI.EndDisabledGroup();
  505. }
  506. /*
  507. if (activePoseProp.objectReferenceValue == null)
  508. {
  509. EditorGUILayout.BeginHorizontal();
  510. EditorGUILayout.PropertyField(activePoseProp);
  511. createNew = GUILayout.Button("Create");
  512. EditorGUILayout.EndHorizontal();
  513. }
  514. else
  515. {
  516. EditorGUILayout.PropertyField(activePoseProp);
  517. DrawDivider();
  518. DrawSaveButtons();
  519. if (PoseChanged)
  520. {
  521. PoseChanged = false;
  522. forceUpdateHands = true;
  523. }
  524. UpdatePreviewHand(previewLeftInstanceProperty, showLeftPreviewProperty, previewLeftHandPrefab, activePose.leftHand, forceUpdateHands);
  525. UpdatePreviewHand(previewRightInstanceProperty, showRightPreviewProperty, previewRightHandPrefab, activePose.rightHand, forceUpdateHands);
  526. }
  527. activePoseProp.objectReferenceValue = newPose;
  528. serializedObject.ApplyModifiedProperties();
  529. }
  530. }
  531. */
  532. GUILayout.EndVertical();
  533. EditorGUILayout.EndVertical();
  534. GUILayout.EndHorizontal();
  535. EditorGUI.BeginChangeCheck();
  536. EditorGUILayout.BeginHorizontal();
  537. EditorGUIUtility.labelWidth = 120;
  538. poserScale.floatValue = EditorGUILayout.FloatField("Preview Pose Scale", poserScale.floatValue);
  539. if (poserScale.floatValue <= 0) poserScale.floatValue = 1;
  540. EditorGUIUtility.labelWidth = 0;
  541. GUILayout.FlexibleSpace();
  542. EditorGUILayout.EndHorizontal();
  543. if (EditorGUI.EndChangeCheck())
  544. {
  545. forceUpdateHands = true;
  546. }
  547. }
  548. GUILayout.EndVertical();
  549. }
  550. }
  551. bool SelectablePoseButton(string name, bool selected)
  552. {
  553. if (selected)
  554. {
  555. GUI.color = new Color(0.7f, 0.73f, 0.8f);
  556. GUILayout.Button(name, GUILayout.ExpandWidth(false));
  557. GUI.color = Color.white;
  558. return false;
  559. }
  560. else
  561. {
  562. return GUILayout.Button(name, GUILayout.ExpandWidth(false));
  563. }
  564. }
  565. Texture[] handMaskTextures;
  566. void DrawBlendingBehaviourMenu()
  567. {
  568. if (handMaskTextures == null)
  569. {
  570. handMaskTextures = new Texture[] { (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/handmask_Palm.png"),
  571. (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/handmask_Thumb.png"),
  572. (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/handmask_Index.png"),
  573. (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/handmask_Middle.png"),
  574. (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/handmask_Ring.png"),
  575. (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/handmask_Pinky.png")
  576. };
  577. }
  578. GUILayout.Space(10);
  579. GUILayout.BeginVertical("box");
  580. blendEditorExpanded.boolValue = IndentedFoldoutHeader(blendEditorExpanded.boolValue, "Blending Editor");
  581. if (blendEditorExpanded.boolValue)
  582. {
  583. //show selectable menu of all poses, highlighting the one that is selected
  584. EditorGUILayout.Space();
  585. for (int i = 0; i < blendingBehaviourArray.arraySize; i++)
  586. {
  587. SerializedProperty blender = blendingBehaviourArray.GetArrayElementAtIndex(i);
  588. SerializedProperty blenderName = blender.FindPropertyRelative("name");
  589. SerializedProperty blenderEnabled = blender.FindPropertyRelative("enabled");
  590. SerializedProperty blenderInfluence = blender.FindPropertyRelative("influence");
  591. SerializedProperty blenderPose = blender.FindPropertyRelative("pose");
  592. SerializedProperty blenderType = blender.FindPropertyRelative("type");
  593. SerializedProperty blenderUseMask = blender.FindPropertyRelative("useMask");
  594. SerializedProperty blenderValue = blender.FindPropertyRelative("value");
  595. SerializedProperty blenderMask = blender.FindPropertyRelative("mask").FindPropertyRelative("values");
  596. SerializedProperty blenderPreview = blender.FindPropertyRelative("previewEnabled");
  597. GUILayout.Space(10);
  598. float bright = blenderEnabled.boolValue ? 0.6f : 0.9f; // grey out box when disabled
  599. if (EditorGUIUtility.isProSkin) bright = 1;
  600. GUI.color = new Color(bright, bright, bright);
  601. GUILayout.BeginVertical("box");
  602. GUI.color = Color.white;
  603. blenderPreview.boolValue = IndentedFoldoutHeader(blenderPreview.boolValue, blenderName.stringValue, 1);
  604. //SerializedProperty blenderValue = blender.FindProperty("value");
  605. EditorGUIUtility.labelWidth = 64;
  606. EditorGUILayout.BeginHorizontal();
  607. DrawBlenderLogo(blenderType);
  608. EditorGUILayout.PropertyField(blenderEnabled);
  609. GUILayout.FlexibleSpace();
  610. EditorGUI.BeginDisabledGroup(i == 0);
  611. if (GUILayout.Button("Move Up"))
  612. {
  613. blendingBehaviourArray.MoveArrayElement(i, i - 1);
  614. }
  615. EditorGUI.EndDisabledGroup();
  616. EditorGUI.BeginDisabledGroup(i == blendingBehaviourArray.arraySize - 1);
  617. if (GUILayout.Button("Move Down"))
  618. {
  619. blendingBehaviourArray.MoveArrayElement(i, i + 1);
  620. }
  621. EditorGUI.EndDisabledGroup();
  622. GUILayout.Space(6);
  623. GUI.color = new Color(0.9f, 0.8f, 0.78f);
  624. if (GUILayout.Button("Delete"))
  625. {
  626. if (EditorUtility.DisplayDialog("", "Do you really want to delete this Blend Behaviour?", "Yes", "Cancel"))
  627. {
  628. blendingBehaviourArray.DeleteArrayElementAtIndex(i);
  629. return;
  630. }
  631. }
  632. GUI.color = Color.white;
  633. EditorGUILayout.EndHorizontal();
  634. if (blenderPreview.boolValue)
  635. {
  636. EditorGUILayout.PropertyField(blenderName);
  637. EditorGUILayout.BeginHorizontal();
  638. //EditorGUILayout.BeginVertical();
  639. EditorGUILayout.BeginVertical();
  640. EditorGUILayout.Slider(blenderInfluence, 0, 1);
  641. blenderPose.intValue = EditorGUILayout.Popup("Pose", blenderPose.intValue, poser.poseNames);
  642. GUILayout.Space(20);
  643. EditorGUILayout.PropertyField(blenderType);
  644. if (Application.isPlaying)
  645. {
  646. GUILayout.Space(10);
  647. GUI.color = new Color(0, 0, 0, 0.3f);
  648. EditorGUILayout.LabelField("", GUI.skin.box, GUILayout.Height(20), GUILayout.ExpandWidth(true));
  649. GUI.color = Color.white;
  650. Rect fillRect = GUILayoutUtility.GetLastRect();
  651. EditorGUI.DrawRect(fillRectHorizontal(fillRect, blenderValue.floatValue), Color.green);
  652. }
  653. EditorGUILayout.EndVertical();
  654. EditorGUILayout.BeginVertical(GUILayout.MaxWidth(100));
  655. EditorGUILayout.PropertyField(blenderUseMask);
  656. if (blenderUseMask.boolValue)
  657. {
  658. DrawMaskEnabled(blenderMask);
  659. }
  660. else
  661. {
  662. DrawMaskDisabled(blenderMask);
  663. }
  664. EditorGUILayout.EndVertical();
  665. EditorGUILayout.EndHorizontal();
  666. DrawDivider();
  667. EditorGUIUtility.labelWidth = 0;
  668. if (blenderType.intValue == (int)SteamVR_Skeleton_Poser.PoseBlendingBehaviour.BlenderTypes.Manual)
  669. {
  670. EditorGUILayout.Slider(blenderValue, 0, 1);
  671. }
  672. if (blenderType.intValue == (int)SteamVR_Skeleton_Poser.PoseBlendingBehaviour.BlenderTypes.AnalogAction)
  673. {
  674. SerializedProperty blenderAction = blender.FindPropertyRelative("action_single");
  675. SerializedProperty blenderSmooth = blender.FindPropertyRelative("smoothingSpeed");
  676. EditorGUILayout.PropertyField(blenderAction);
  677. EditorGUILayout.PropertyField(blenderSmooth);
  678. }
  679. if (blenderType.intValue == (int)SteamVR_Skeleton_Poser.PoseBlendingBehaviour.BlenderTypes.BooleanAction)
  680. {
  681. SerializedProperty blenderAction = blender.FindPropertyRelative("action_bool");
  682. SerializedProperty blenderSmooth = blender.FindPropertyRelative("smoothingSpeed");
  683. EditorGUILayout.PropertyField(blenderAction);
  684. EditorGUILayout.PropertyField(blenderSmooth);
  685. }
  686. }
  687. GUILayout.EndVertical();
  688. }
  689. EditorGUILayout.BeginHorizontal();
  690. if (GUILayout.Button("+", GUILayout.MaxWidth(32)))
  691. {
  692. int i = blendingBehaviourArray.arraySize;
  693. blendingBehaviourArray.InsertArrayElementAtIndex(i);
  694. blendingBehaviourArray.GetArrayElementAtIndex(i).FindPropertyRelative("name").stringValue = "New Behaviour";
  695. blendingBehaviourArray.GetArrayElementAtIndex(i).FindPropertyRelative("enabled").boolValue = true;
  696. blendingBehaviourArray.GetArrayElementAtIndex(i).FindPropertyRelative("influence").floatValue = 1;
  697. blendingBehaviourArray.GetArrayElementAtIndex(i).FindPropertyRelative("previewEnabled").boolValue = true;
  698. serializedObject.ApplyModifiedProperties();
  699. poser.blendingBehaviours[i].mask.Reset();
  700. }
  701. GUILayout.FlexibleSpace();
  702. EditorGUILayout.EndHorizontal();
  703. }
  704. GUILayout.EndVertical();
  705. }
  706. Rect fillRectHorizontal(Rect r, float f)
  707. {
  708. r.xMax--;
  709. r.yMax--;
  710. r.xMin++;
  711. r.yMin++;
  712. r.width *= f;
  713. return r;
  714. }
  715. void DrawBlenderLogo(SerializedProperty blenderType)
  716. {
  717. Texture icon = null;
  718. if (blenderType.intValue == (int)SteamVR_Skeleton_Poser.PoseBlendingBehaviour.BlenderTypes.Manual)
  719. {
  720. icon = (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/BlenderBehaviour_Manual_Icon.png");
  721. }
  722. if (blenderType.intValue == (int)SteamVR_Skeleton_Poser.PoseBlendingBehaviour.BlenderTypes.AnalogAction)
  723. {
  724. icon = (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/BlenderBehaviour_Analog_Icon.png");
  725. }
  726. if (blenderType.intValue == (int)SteamVR_Skeleton_Poser.PoseBlendingBehaviour.BlenderTypes.BooleanAction)
  727. {
  728. icon = (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/BlenderBehaviour_Boolean_Icon.png");
  729. }
  730. GUILayout.Label(icon, GUILayout.MaxHeight(32), GUILayout.MaxWidth(32));
  731. }
  732. Color maskColorEnabled = new Color(0.3f, 1.0f, 0.3f, 1.0f);
  733. Color maskColorDisabled = new Color(0, 0, 0, 0.5f);
  734. Color maskColorUnused = new Color(0.3f, 0.7f, 0.3f, 0.3f);
  735. void DrawMaskDisabled(SerializedProperty mask)
  736. {
  737. Texture m = (Texture)EditorGUIUtility.Load("Assets/SteamVR/Input/Editor/Resources/Icons/handmask.png");
  738. GUI.color = maskColorUnused;
  739. GUILayout.Label(m, GUILayout.MaxHeight(100), GUILayout.MaxWidth(100));
  740. GUI.color = Color.white;
  741. }
  742. void DrawMaskEnabled(SerializedProperty mask)
  743. {
  744. GUILayout.Label("", GUILayout.Height(100), GUILayout.Width(100));
  745. Rect maskRect = GUILayoutUtility.GetLastRect();
  746. for (int i = 0; i < 6; i++)
  747. {
  748. GUI.color = mask.GetArrayElementAtIndex(i).boolValue ? maskColorEnabled : maskColorDisabled;
  749. GUI.Label(maskRect, handMaskTextures[i]);
  750. GUI.color = new Color(0, 0, 0, 0.0f);
  751. if (GUI.Button(GetFingerAreaRect(maskRect, i), ""))
  752. {
  753. mask.GetArrayElementAtIndex(i).boolValue = !mask.GetArrayElementAtIndex(i).boolValue;
  754. }
  755. GUI.color = Color.white;
  756. //maskVal
  757. }
  758. }
  759. /// <summary>
  760. /// Defines area of mask icon to be buttons for each finger
  761. /// </summary>
  762. Rect GetFingerAreaRect(Rect source, int i)
  763. {
  764. Rect outRect = source;
  765. if (i == 0)
  766. {
  767. outRect.xMin = Mathf.Lerp(source.xMin, source.xMax, 0.4f); // left edge
  768. outRect.xMax = Mathf.Lerp(source.xMin, source.xMax, 0.8f); // right edge
  769. outRect.yMin = Mathf.Lerp(source.yMin, source.yMax, 0.5f); // top edge
  770. outRect.yMax = Mathf.Lerp(source.yMin, source.yMax, 1.0f); // bottom edge
  771. }
  772. if (i == 1)
  773. {
  774. outRect.xMin = Mathf.Lerp(source.xMin, source.xMax, 0.0f); // left edge
  775. outRect.xMax = Mathf.Lerp(source.xMin, source.xMax, 0.4f); // right edge
  776. outRect.yMin = Mathf.Lerp(source.yMin, source.yMax, 0.5f); // top edge
  777. outRect.yMax = Mathf.Lerp(source.yMin, source.yMax, 1.0f); // bottom edge
  778. }
  779. if (i == 2)
  780. {
  781. outRect.xMin = Mathf.Lerp(source.xMin, source.xMax, 0.3f); // left edge
  782. outRect.xMax = Mathf.Lerp(source.xMin, source.xMax, 0.425f); // right edge
  783. outRect.yMin = Mathf.Lerp(source.yMin, source.yMax, 0.0f); // top edge
  784. outRect.yMax = Mathf.Lerp(source.yMin, source.yMax, 0.5f); // bottom edge
  785. }
  786. if (i == 3)
  787. {
  788. outRect.xMin = Mathf.Lerp(source.xMin, source.xMax, 0.425f); // left edge
  789. outRect.xMax = Mathf.Lerp(source.xMin, source.xMax, 0.55f); // right edge
  790. outRect.yMin = Mathf.Lerp(source.yMin, source.yMax, 0.0f); // top edge
  791. outRect.yMax = Mathf.Lerp(source.yMin, source.yMax, 0.5f); // bottom edge
  792. }
  793. if (i == 4)
  794. {
  795. outRect.xMin = Mathf.Lerp(source.xMin, source.xMax, 0.55f); // left edge
  796. outRect.xMax = Mathf.Lerp(source.xMin, source.xMax, 0.675f); // right edge
  797. outRect.yMin = Mathf.Lerp(source.yMin, source.yMax, 0.0f); // top edge
  798. outRect.yMax = Mathf.Lerp(source.yMin, source.yMax, 0.5f); // bottom edge
  799. }
  800. if (i == 5)
  801. {
  802. outRect.xMin = Mathf.Lerp(source.xMin, source.xMax, 0.675f); // left edge
  803. outRect.xMax = Mathf.Lerp(source.xMin, source.xMax, 0.8f); // right edge
  804. outRect.yMin = Mathf.Lerp(source.yMin, source.yMax, 0.0f); // top edge
  805. outRect.yMax = Mathf.Lerp(source.yMin, source.yMax, 0.5f); // bottom edge
  806. }
  807. return outRect;
  808. }
  809. void DrawDivider()
  810. {
  811. GUI.color = new Color(0, 0, 0, 0.6f);
  812. EditorGUILayout.Space();
  813. EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
  814. EditorGUILayout.Space();
  815. GUI.color = Color.white;
  816. }
  817. bool IndentedFoldoutHeader(bool fold, string text, int indent = 1)
  818. {
  819. GUILayout.BeginHorizontal();
  820. GUIStyle boldFoldoutStyle = new GUIStyle(EditorStyles.foldout);
  821. boldFoldoutStyle.fontStyle = FontStyle.Bold;
  822. GUILayout.Space(14f * indent);
  823. fold = EditorGUILayout.Foldout(fold, text, boldFoldoutStyle);
  824. GUILayout.EndHorizontal();
  825. return fold;
  826. }
  827. }
  828. }