public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Poses", EditorStyles.boldLabel); poseFileName = EditorGUILayout.TextField("Pose Filename", poseFileName); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save pose")) { skeleton.SavePose(poseFileName); } if (GUILayout.Button("Reset pose")) { if (skeleton.basePose != null) { skeleton.RestorePose(skeleton.basePose); } } GUILayout.EndHorizontal(); if (skeleton.basePose == null) { EditorGUILayout.HelpBox("You have not selected a base pose.", MessageType.Error); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUILayout.Separator(); skeleton.useShadows = EditorGUILayout.Toggle("Use Shadows", skeleton.useShadows); if (GUILayout.Button("Flip")) { skeleton.flip = !skeleton.flip; } EditorGUILayout.LabelField("Poses", EditorStyles.boldLabel); poseFileName = EditorGUILayout.TextField("Pose Filename", poseFileName); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save pose")) { skeleton.SavePose(poseFileName); } if (GUILayout.Button("Reset pose")) { if (skeleton.basePose != null) { skeleton.RestorePose(skeleton.basePose); } } GUILayout.EndHorizontal(); if (skeleton.GetComponentInChildren <Skin2D>() != null && GUILayout.Button("Calculate weights")) { skeleton.CalculateWeights(false); } if (skeleton.basePose == null) { EditorGUILayout.HelpBox("You have not selected a base pose.", MessageType.Error); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUILayout.Separator(); if (GUILayout.Button("FlipY")) { skeleton.flipY = !skeleton.flipY; } if (GUILayout.Button("FlipX")) { skeleton.flipX = !skeleton.flipX; } EditorGUILayout.Separator(); if (GUILayout.Button("Use Shadows")) { skeleton.useShadows = !skeleton.useShadows; } if (skeleton.useShadows) { shadows = "On"; } else { shadows = "Off"; } EditorGUILayout.LabelField("Shadows:", shadows, EditorStyles.whiteLabel); EditorGUILayout.Separator(); if (GUILayout.Button("Use Z Sorting")) { skeleton.useZSorting = !skeleton.useZSorting; } if (skeleton.useZSorting) { zsorting = "On"; } else { zsorting = "Off"; } EditorGUILayout.LabelField("Z Sorting:", zsorting, EditorStyles.whiteLabel); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Poses", EditorStyles.boldLabel); poseFileName = EditorGUILayout.TextField("Pose Filename", poseFileName); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save pose")) { skeleton.SavePose(poseFileName); } if (GUILayout.Button("Reset pose")) { if (skeleton.basePose != null) { skeleton.RestorePose(skeleton.basePose); } } GUILayout.EndHorizontal(); if (GUILayout.Button("Calculate weights")) { skeleton.CalculateWeights(); } if (skeleton.basePose == null) { EditorGUILayout.HelpBox("You have not selected a base pose.", MessageType.Error); } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Save/Load Children Positions", EditorStyles.boldLabel); if (!skeleton.editMode) { EditorGUILayout.HelpBox("Skeleton Needs to be in Edit Mode.", MessageType.Error); } if (GUILayout.Button("Save Children Positions") && skeleton.editMode) { Bone[] bones = skeleton.gameObject.GetComponentsInChildren <Bone>(true); foreach (Bone bone in bones) { bone.SaveChildPosRot(); if (bone.HasChildPositionsSaved()) { skeleton.hasChildPositionsSaved = true; } } Debug.Log("Saved Children Positions and Rotations in Skeleton."); } if (!skeleton.hasChildPositionsSaved) { EditorGUILayout.HelpBox("You have not saved children positions.", MessageType.Error); } if (GUILayout.Button("Load Children Positions") && skeleton.hasChildPositionsSaved && skeleton.editMode) { Bone[] bones = skeleton.gameObject.GetComponentsInChildren <Bone>(true); foreach (Bone bone in bones) { bone.LoadChildPosRot(); } Debug.Log("Loaded Children Positions and Rotations in Skeleton."); } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Create Skin2D Prefabs from Children", EditorStyles.boldLabel); if (GUILayout.Button("Create Skin2D Prefabs")) { Skin2D[] skins = skeleton.gameObject.GetComponentsInChildren <Skin2D>(true); foreach (Skin2D skin in skins) { bool skinActive = skin.gameObject.activeSelf; skin.gameObject.SetActive(true); skin.SaveAsPrefab(); skin.gameObject.SetActive(skinActive); } Debug.Log("Saved all Skins as Prefabs."); } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Disconnect All Skin2D Prefabs", EditorStyles.boldLabel); if (GUILayout.Button("Disconnect Skin2D Prefabs")) { Skin2D[] skins = skeleton.gameObject.GetComponentsInChildren <Skin2D>(true); foreach (Skin2D skin in skins) { bool skinActive = skin.gameObject.activeSelf; skin.gameObject.SetActive(true); PrefabUtility.DisconnectPrefabInstance(skin.gameObject); skin.gameObject.SetActive(skinActive); } Debug.Log("Disconnected Skin2D Prefabs."); } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Reset Skins' Control Point Names", EditorStyles.boldLabel); if (GUILayout.Button("Reset Control Point Names")) { ControlPoint[] cps = skeleton.gameObject.GetComponentsInChildren <ControlPoint>(true); foreach (ControlPoint cp in cps) { cp.Rename(); } Debug.Log("Reset all control point names."); } }