private void _OnGUI_Started_Toolbar() { GUILayout.BeginHorizontal(); { EUtil.PushGUIEnable(m_EditMode != EditMode.Fixer); if (GUILayout.Button("Fixer", EditorStyles.toolbarButton)) { _SwitchEditMode(EditMode.Fixer); } EUtil.PopGUIEnable(); EUtil.PushGUIEnable(m_EditMode != EditMode.Saver); if (GUILayout.Button("Saver", EditorStyles.toolbarButton)) { _SwitchEditMode(EditMode.Saver); } EUtil.PopGUIEnable(); EUtil.PushGUIEnable(m_EditMode != EditMode.None); EUtil.PushBackgroundColor(Color.red); if (GUILayout.Button("Stop", EditorStyles.toolbarButton)) { _EnsureStopEditing(); } EUtil.PopBackgroundColor(); EUtil.PopGUIEnable(); } GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { LookAt cp = (LookAt)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { cp.LookAxis = (EAxisD)EConUtil.DrawEnumBtns(AllLookAxis, AllLookAxisStr, cp.LookAxis, "LookAxis", "the axis to point towards target"); cp.UpAxis = (EAxisD)EConUtil.DrawEnumBtns(AllLookAxis, AllLookAxisStr, cp.UpAxis, "UpAxis", "the axis to point upward"); cp.UpAxis = ConUtil.EnsureAxisNotColinear(cp.LookAxis, cp.UpAxis); GUILayout.Space(5f); //influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public override void OnInspectorGUI() { LockedTrack cp = (LockedTrack)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { cp.LookAxis = (EAxisD)EConUtil.DrawEnumBtns(EConUtil.AxisDs, EConUtil.AxisDStrs, cp.LookAxis, "LookAxis", "Owner's local axis used to aim at the target", 80f); GUILayout.Space(5f); cp.RotateAxis = (EAxisD)EConUtil.DrawEnumBtns(EConUtil.AxisDsPositive, EConUtil.AxisDStrsPositive, cp.RotateAxis, "Rotate Axis", "Owner's local axis used to rotate around", 80f); GUILayout.Space(5f); cp.RotateAxis = ConUtil.EnsureAxisNotColinear(cp.LookAxis, cp.RotateAxis); // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
private void _OnGUI_NotStarted() { GameObject curGO = Selection.activeGameObject; bool bValid = false; if (curGO != null) { MeshFilter mf = curGO.GetComponent <MeshFilter>(); bValid = (mf != null); } Vector2 sz = new Vector2(position.width, position.height); EUtil.PushGUIEnable(bValid); { Rect rc = new Rect(30f, 30f, sz.x - 60f, sz.y - 60f); if (GUI.Button(rc, bValid ? "Start Edit" : "Need MeshFilter" )) { _StartEdit(); } } EUtil.PopGUIEnable(); }
public static float DrawLimitField( ref ELimitAffect eAffect, string label, string tips, float limitVal, ELimitAffect field) { bool v = (eAffect & field) != 0; EditorGUILayout.BeginHorizontal(); { Rect rc = GUILayoutUtility.GetRect(16f, 16f); bool newV = EditorGUI.Toggle(rc, v); if (v != newV) { if (newV) { eAffect |= field; } else { eAffect &= (~field); } } EUtil.PushGUIEnable(newV); { limitVal = EditorGUILayout.FloatField(new GUIContent(label, tips), limitVal); } EUtil.PopGUIEnable(); } EditorGUILayout.EndHorizontal(); return(limitVal); }
void OnGUI() { EUtil.PushGUIEnable(false); EditorGUILayout.TextArea( @"W/E/R: move/rotate/scale Q: Focus on pivot A: Select all/none Z: Toggle transparent mode B: Toggle Border-selection O: Toggle Soft-selection S: Toggle Pivot-Orientation D: Toggle Pivot-Position [ ]: Tune the soft-selection range ESC: Cancel Ctrl+RMB: Set 3D-cursor position Ctrl+LMB: Loop selection Alt+LMB: Rotate around pivot Mousewheel: zoom in/out MMB: Pan view " ); EUtil.PopGUIEnable(); }
public override void OnInspectorGUI() { ShrinkWrap cp = (ShrinkWrap)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target var newTarget = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); if (newTarget != null && (newTarget.GetComponent <MeshFilter>() == null || newTarget.GetComponent <Collider>() == null) ) { EUtil.ShowNotification("Target must have MeshFilter & Collider"); } else { cp.Target = newTarget; } EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { cp.Method = (ShrinkWrap.EShrinkWrapMethod)EditorGUILayout.EnumPopup(new GUIContent("ShrinkWrap Method", "select the algorithm for the action"), cp.Method); if (cp.Method == ShrinkWrap.EShrinkWrapMethod.NearestVertex) { EUtil.GetSceneView().renderMode = DrawCameraMode.TexturedWire; } else { EUtil.GetSceneView().renderMode = DrawCameraMode.Textured; } cp.Distance = EditorGUILayout.FloatField(new GUIContent("Distance", "keep distance to the projected point"), cp.Distance); if (cp.Method == ShrinkWrap.EShrinkWrapMethod.Project) { cp.ProjectDir = (EAxisD)EConUtil.DrawEnumBtns(EConUtil.AxisDs, EConUtil.AxisDStrs, cp.ProjectDir, "ProjectDir", "the direction or project ray, from origin of owner"); cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup(new GUIContent("OwnerSpace", "the space used for project dir"), cp.OwnerSpace); cp.MaxProjectDistance = Mathf.Max(0, EditorGUILayout.FloatField(new GUIContent("Max Project Dist", "only execute wrap when the projected point is within the dist; 0 means infinite distance"), cp.MaxProjectDistance)); } else if (cp.Method == ShrinkWrap.EShrinkWrapMethod.NearestVertex) { //nothing here } //cp.ModifyInitInfo = EditorGUILayout.Toggle(new GUIContent("Modify InitInfo", "the constraint result will be written back to the initInfo"), cp.ModifyInitInfo); cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
void OnGUI() { m_Animator = (Animator)EditorGUILayout.ObjectField("Animator", m_Animator, typeof(Animator), true); m_AnimType = (ModelImporterAnimationType)EditorGUILayout.EnumPopup("AnimType", m_AnimType); if (m_AnimType != ModelImporterAnimationType.Legacy) { m_AnimType = ModelImporterAnimationType.Generic; } bool bSet = (m_Animator != null); EUtil.PushGUIEnable(bSet); if (EUtil.Button("Convert Animation!", bSet ? Color.green : Color.red)) { if (!m_Animator.isHuman) { EUtil.ShowNotification("The model is not in Humanoid rig!"); return; } // save xforms recursively m_SavedPose = EUtil.CacheXformData(m_Animator.transform); m_Animator.Update(0); #if !U5 var ainfos = m_Animator.GetCurrentAnimationClipState(0); //only effect after Update is called #else var ainfos = m_Animator.GetCurrentAnimatorClipInfo(0); //only effect after Update is called #endif if (ainfos.Length == 0) { EUtil.ShowNotification("No clip in AnimationController!"); } else { AnimationClip clip = ainfos[0].clip; string oldClipAssetPath = AssetDatabase.GetAssetPath(clip); string newClipAssetPath = PathUtil.StripExtension(oldClipAssetPath) + NEW_CLIP_POSTFIX + m_AnimType + ".anim"; string filePath = EditorUtility.SaveFilePanel("Select export file path", Path.GetDirectoryName(newClipAssetPath), Path.GetFileNameWithoutExtension(newClipAssetPath), "anim"); if (filePath.Length > 0) { filePath = PathUtil.FullPath2ProjectPath(filePath); _ConvertAnim(filePath); } else { EUtil.ShowNotification("Conversion Cancelled..."); } } //apply the original pose back EUtil.ApplyXformData(m_Animator.transform, m_SavedPose); } EUtil.PopGUIEnable(); }
public override void OnInspectorGUI() { ClampTo cp = (ClampTo)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Spline = (BaseSplineBehaviour)EditorGUILayout.ObjectField("Target Spline", cp.Spline, typeof(BaseSplineBehaviour), true); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Spline); { //axis and offset m_foldoutAxis = EditorGUILayout.Foldout(m_foldoutAxis, "Affect"); if (m_foldoutAxis) { cp.MainAxis = (EAxis)EConUtil.DrawEnumBtns(AllAxis, AllAxisStr, cp.MainAxis, "Main Axis", "Choose the axis used to decide the parameter t for evaluate spline"); // offset cp.UseOffset = EditorGUILayout.Toggle(new GUIContent("Use Offset", "Add offset onto the result"), cp.UseOffset); if (cp.UseOffset) { cp.Offset = EUtil.DrawV3P(new GUIContent("Offset", "Offset in world space"), cp.Offset); } cp.Cyclic = EditorGUILayout.Toggle(new GUIContent("Cyclic", "the object will revert to the beginning of spline when exceed the dimension"), cp.Cyclic); GUILayout.Space(5f); } // dimension and startVal m_foldoutPos = EditorGUILayout.Foldout(m_foldoutPos, "Pos Define"); if (m_foldoutPos) { cp.Dimension = EditorGUILayout.FloatField(new GUIContent("Dimension", "the projection length on mainAxis"), cp.Dimension); cp.StartVal = EditorGUILayout.FloatField(new GUIContent("StartVal", "the low value on mainAxis"), cp.StartVal); if (GUILayout.Button(new GUIContent("Recalculate Dimension", "Recalculate dimension & startVal based on spline"))) { var behaviour = cp.Spline; Bounds bd = behaviour.CalculateTransformedBounds(); _SetDimensionByBounds(cp, bd); } } // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public override void OnInspectorGUI() { ChildOf cp = (ChildOf)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); if (cp.Target && !ConstraintEditorUtil.IsTargetHasAllUniformScaleInHierarchy(cp.Target)) { ConstraintEditorUtil.NonUniformScaleWarning(cp.Target); } EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { //affect X/Y/Z m_foldoutAffect.val = EditorGUILayout.Foldout(m_foldoutAffect.val, "Affect"); if (m_foldoutAffect.val) { cp.AffectPos = EConUtil.DrawAxisBtnMask(new GUIContent("Position", "which fields of position are affected"), cp.AffectPos); cp.AffectRot = EConUtil.DrawAxisBtnMask(new GUIContent("Rotation", "which fields of rotation are affected"), cp.AffectRot); cp.AffectSca = EConUtil.DrawAxisBtnMask(new GUIContent("Scale", "which fields of scale are affected"), cp.AffectSca); GUILayout.Space(5f); } // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); var pseuLocTr = cp.PseudoLocTr; pseuLocTr.pos = EUtil.DrawV3P(new GUIContent("position", "the pseudo local position"), pseuLocTr.pos); pseuLocTr.rot = Quaternion.Euler(EUtil.DrawV3P(new GUIContent("rotation", "the pseudo local rotation"), pseuLocTr.rot.eulerAngles)); pseuLocTr.scale = EUtil.DrawV3P(new GUIContent("scale", "the pseudo local scale"), pseuLocTr.scale); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(50f); if (GUILayout.Button(new GUIContent("Sample Data", "Use current transform data to calculate the pseudo local transform's data"), EditorStyles.toolbarButton)) { cp.RecalcPseudoLocalTransformData(); } GUILayout.Space(50f); } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public override void OnInspectorGUI() { LimitScale cp = (LimitScale)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint); { //affect X/Y/Z m_foldoutLimit = EditorGUILayout.Foldout(m_foldoutLimit, "Limits"); if (m_foldoutLimit) { ELimitAffect eAffect = cp.LimitAffect; Vector3 limitMin = cp.LimitMin; Vector3 limitMax = cp.LimitMax; limitMin.x = EConUtil.DrawLimitField(ref eAffect, "XMin", "min value of X", limitMin.x, ELimitAffect.MinX); limitMax.x = EConUtil.DrawLimitField(ref eAffect, "XMax", "max value of X", limitMax.x, ELimitAffect.MaxX); limitMin.y = EConUtil.DrawLimitField(ref eAffect, "YMin", "min value of Y", limitMin.y, ELimitAffect.MinY); limitMax.y = EConUtil.DrawLimitField(ref eAffect, "YMax", "max value of Y", limitMax.y, ELimitAffect.MaxY); limitMin.z = EConUtil.DrawLimitField(ref eAffect, "ZMin", "min value of Z", limitMin.z, ELimitAffect.MinZ); limitMax.z = EConUtil.DrawLimitField(ref eAffect, "ZMax", "max value of Z", limitMax.z, ELimitAffect.MaxZ); EConUtil.LimitFieldMinMaxFix(eAffect, ref limitMin, ref limitMax); cp.LimitAffect = eAffect; cp.LimitMin = limitMin; cp.LimitMax = limitMax; GUILayout.Space(5f); } m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping"); if (m_foldoutSpace) { // owner space cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup("Owner Space", cp.OwnerSpace); GUILayout.Space(5f); } //record modify cp.ModifyInternalData = EditorGUILayout.Toggle(new GUIContent("Modify Internal Data", "This modification will modify the ConstraintStack's internal transform data"), cp.ModifyInternalData); // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
private void _GUI_AddNewCurve() { EditorWindow uaw = (EditorWindow)EUtil.GetUnityAnimationWindow(); object uawstate = EUtil.GetUnityAnimationWindowState(uaw); m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState", "m_ActiveAnimationClip", uawstate) as AnimationClip; if (m_CurClip == null) { EditorGUILayout.LabelField("Need an animation clip first..."); return; } m_NewPath = EditorGUILayout.TextField("Path:", m_NewPath); m_NewProperty = EditorGUILayout.TextField("Property:", m_NewProperty); m_TypeFullName = EditorGUILayout.TextField("TypeFullName:", m_TypeFullName); m_bIsPPtrCurve = EditorGUILayout.Toggle("IsPPtrCurve:", m_bIsPPtrCurve); EditorGUILayout.Separator(); bool bOK = true; EUtil.PushGUIColor(Color.red); if (string.IsNullOrEmpty(m_NewProperty)) { bOK = false; EditorGUILayout.LabelField("Property is not specified"); } if (string.IsNullOrEmpty(m_TypeFullName) || RCall.GetTypeFromString(m_TypeFullName, true) == null) { bOK = false; EditorGUILayout.LabelField(string.Format("No type is found for name: {0}", m_TypeFullName)); } EUtil.PopGUIColor(); EUtil.PushGUIEnable(bOK); { if (EUtil.Button("Add New Curve", Color.green)) { Type tp = RCall.GetTypeFromString(m_TypeFullName); if (m_bIsPPtrCurve) { EditorCurveBinding newBinding = EditorCurveBinding.PPtrCurve(m_NewPath, tp, m_NewProperty); AnimationUtility.SetObjectReferenceCurve(m_CurClip, newBinding, new ObjectReferenceKeyframe[0]); } else { EditorCurveBinding newBinding = EditorCurveBinding.FloatCurve(m_NewPath, tp, m_NewProperty); AnimationUtility.SetEditorCurve(m_CurClip, newBinding, new AnimationCurve()); } } } EUtil.PopGUIEnable(); }
public override void OnInspectorGUI() { LimitRotation cp = (LimitRotation)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint); { //affect X/Y/Z m_foldoutLimit = EditorGUILayout.Foldout(m_foldoutLimit, "Limits"); if (m_foldoutLimit) { ELimitEuler eLimit = cp.LimitEuler; Vector3 limitMin = cp.LimitMin; Vector3 limitMax = cp.LimitMax; EConUtil.DrawEulerLimitField(ref eLimit, "X", ref limitMin, ref limitMax, ELimitEuler.X, -180f, 180f); EConUtil.DrawEulerLimitField(ref eLimit, "Y", ref limitMin, ref limitMax, ELimitEuler.Y, -180f, 180f); EConUtil.DrawEulerLimitField(ref eLimit, "Z", ref limitMin, ref limitMax, ELimitEuler.Z, -180f, 180f); cp.LimitEuler = eLimit; cp.LimitMin = limitMin; cp.LimitMax = limitMax; GUILayout.Space(5f); } //space mapping //m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping"); //if (m_foldoutSpace) //{ // // owner space // cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup("Owner Space", cp.OwnerSpace); // GUILayout.Space(5f); //} //record modify //cp.ModifyInternalData = EditorGUILayout.Toggle(new GUIContent("Modify Internal Data", "This modification will modify the ConstraintStack's internal transform data"), cp.ModifyInternalData); // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public static void PrefGUI() { if (!m_isLoaded) { _LoadPrefs(); } EditorGUILayout.BeginHorizontal(); { EUtil.PushGUIEnable(m_selectProduct != SelectProd.CAT); if (GUILayout.Button(new GUIContent("Character Animation Tools", "Bone Animation, Vertex animation, animation export, and all other tools"), EditorStyles.toolbarButton)) { m_selectProduct = SelectProd.CAT; } EUtil.PopGUIEnable(); EUtil.PushGUIEnable(m_selectProduct != SelectProd.ImmConsole); if (GUILayout.Button(new GUIContent("Immediate Console", "Execute C# snippets immediately in edit-mode & game-mode"), EditorStyles.toolbarButton)) { m_selectProduct = SelectProd.ImmConsole; } EUtil.PopGUIEnable(); } EditorGUILayout.EndHorizontal(); switch (m_selectProduct) { case SelectProd.CAT: { _GUI_CAT(); } break; case SelectProd.ImmConsole: { _GUI_ImmConsole(); } break; case SelectProd.None: { _GUI_None(); } break; default: Dbg.LogErr("Pref.PrefGUI: unexpected selected product: {0}", m_selectProduct); break; } }
private void _GUI_EditSingleCurve() { EditorWindow uaw = (EditorWindow)EUtil.GetUnityAnimationWindow(); object uawstate = EUtil.GetUnityAnimationWindowState(uaw); m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState", "m_ActiveAnimationClip", uawstate) as AnimationClip; IList curves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "activeCurves", uawstate); if (curves.Count != 1) { EditorGUILayout.LabelField(string.Format("Please select ONE curve, you have currently selected {0} curves", curves.Count)); return; } object oneCurve = curves[0]; //AnimationWindowCurve EditorCurveBinding oneBinding = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", oneCurve); EditorGUILayout.LabelField("Path:"); EUtil.PushContentColor(Color.yellow); EditorGUILayout.SelectableLabel(oneBinding.path); EUtil.PopContentColor(); EditorGUILayout.LabelField("Property:"); EUtil.PushContentColor(Color.green); EditorGUILayout.SelectableLabel(oneBinding.propertyName); EUtil.PopContentColor(); EditorGUILayout.LabelField("IsPPtrCurve: " + oneBinding.isPPtrCurve.ToString()); EditorGUILayout.Separator(); m_NewType = EditorGUILayout.TextField("Type:", m_NewType); if (m_NewType.Length == 0) { m_NewType = oneBinding.type.ToString(); } m_NewPath = EditorGUILayout.TextField("New Path:", m_NewPath); m_NewProperty = EditorGUILayout.TextField("New Property:", m_NewProperty); Type newTp = RCall.GetTypeFromString(m_NewType, true); EUtil.PushGUIEnable(m_NewProperty.Length > 0 && newTp != null); if (EUtil.Button("Apply Change", Color.green)) { Undo.RegisterCompleteObjectUndo(m_CurClip, "Apply Curve Change"); _ModifyCurveBinding(oneBinding, m_NewPath, m_NewProperty, newTp); } EUtil.PopGUIEnable(); }
public override EReturn OnGUI() { EUtil.PushGUIEnable(true); Rect rc = new Rect(Screen.width * 0.5f - 150, Screen.height * 0.5f - 50f, 300, 70); if (m_background != null) { GUI.DrawTexture(rc, m_background); } GUILayout.BeginArea(rc); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("SymBone:", EditorStyles.boldLabel); m_SymAxis = (Axis)EditorGUILayout.EnumPopup(m_SymAxis); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("NonSymBone:", EditorStyles.boldLabel); m_NonSymAxis = (Axis)EditorGUILayout.EnumPopup(m_NonSymAxis); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); { if (GUILayout.Button("OK")) { m_MirrorCtrl.SymBoneAxis = m_SymAxis; m_MirrorCtrl.NonSymBoneAxis = m_NonSymAxis; m_OnFinish(true); return(EReturn.STOP); } if (GUILayout.Button("Cancel")) { m_OnFinish(false); return(EReturn.STOP); } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); return(EReturn.MODAL); }
private void _GUI_BatchAddPrefix() { EditorWindow uaw = (EditorWindow)EUtil.GetUnityAnimationWindow(); object uawstate = EUtil.GetUnityAnimationWindowState(uaw); m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState", "m_ActiveAnimationClip", uawstate) as AnimationClip; //1. collect the TrPaths from active curves List <BindingInfo> bindingInfos = new List <BindingInfo>(); IList curves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "activeCurves", uawstate); for (int idx = 0; idx < curves.Count; ++idx) { object oneCurve = curves[idx]; //AnimationWindowCurve EditorCurveBinding oneBinding = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", oneCurve); bindingInfos.Add(new BindingInfo(oneBinding, oneCurve)); } //2. display EditorGUILayout.LabelField("Selected curves:"); m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, false, true, GUILayout.Height(200f)); { foreach (var oneInfo in bindingInfos) { EditorCurveBinding oneBinding = oneInfo.m_Binding; GUILayout.BeginHorizontal(); { EUtil.PushContentColor(Color.yellow); GUILayout.Label(oneBinding.path); EUtil.PopContentColor(); EUtil.PushContentColor(Color.green); GUILayout.Label(oneBinding.propertyName); EUtil.PopContentColor(); } GUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); //3. apply prefix m_Prefix = EditorGUILayout.TextField("Prefix:", m_Prefix); EUtil.PushGUIEnable(m_CurClip != null && bindingInfos.Count > 0); if (EUtil.Button("Apply Prefix", Color.green)) { _DoApplyPrefix(bindingInfos, m_Prefix); } EUtil.PopGUIEnable(); }
public override void OnInspectorGUI() { LimitDistance cp = (LimitDistance)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { // distance & reset EditorGUILayout.BeginHorizontal(); cp.Distance = EditorGUILayout.FloatField(new GUIContent("Distance", "limit distance"), cp.Distance); if (GUILayout.Button(new GUIContent("R", "recalculate the distance"), EditorStyles.miniButton, GUILayout.Width(20))) { Transform tr = cp.transform; cp.Distance = (tr.position - cp.Target.position).magnitude; } EditorGUILayout.EndHorizontal(); // clamp region cp.ClampRegion = (EClampRegion)EditorGUILayout.EnumPopup(new GUIContent("Clamp Region", "decide how to limit the distance"), cp.ClampRegion); // space mapping m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping"); if (m_foldoutSpace) { // target space cp.TargetSpace = (ESpace)EditorGUILayout.EnumPopup("Target Space", cp.TargetSpace); // owner space cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup("Owner Space", cp.OwnerSpace); GUILayout.Space(5f); } // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
void OnGUI() { EditorGUI.BeginChangeCheck(); m_Clip = (AnimationClip)EditorGUILayout.ObjectField("Compress clip:", m_Clip, typeof(AnimationClip), false); m_PosErr = EditorGUILayout.FloatField(new GUIContent("Position Threshold:", "raising this value could reduce more keys"), m_PosErr); m_RotErr = EditorGUILayout.FloatField(new GUIContent("Rotation Threshold:", "raising this value could reduce more keys"), m_RotErr); m_ScaErr = EditorGUILayout.FloatField(new GUIContent("Scale Threshold:", "raising this value could reduce more keys"), m_ScaErr); m_FloatErr = EditorGUILayout.FloatField(new GUIContent("Float Threshold:", "raising this value could reduce more keys"), m_FloatErr); m_Verbose = EditorGUILayout.ToggleLeft("Verbose", m_Verbose); if (EditorGUI.EndChangeCheck()) { } EUtil.PushGUIEnable(m_Clip != null); if (EUtil.Button("Execute!", "Start the work", Color.green, GUILayout.ExpandHeight(true))) { string newPath = EditorUtility.SaveFilePanelInProject("Save new clip", m_Clip.name + "_optimized", "anim", "Select new optimized clip save location"); if (!string.IsNullOrEmpty(newPath)) { string oldPath = AssetDatabase.GetAssetPath(m_Clip); if (oldPath == newPath) { bool bOK = EditorUtility.DisplayDialog("Are you sure?", "You're going to overwrite old animation file", "Go Ahead", "No-No"); if (bOK) { var comp = new AnimCompress(); comp.Verbose = m_Verbose; comp.ReduceKeyframes(m_Clip, m_PosErr, m_RotErr, m_ScaErr, m_FloatErr); } } else { AnimationClip newClip = AnimationClip.Instantiate(m_Clip) as AnimationClip; if (newClip == null) { Dbg.LogErr("cannot load new clip at path: {0}", newPath); return; } var comp = new AnimCompress(); comp.Verbose = m_Verbose; comp.ReduceKeyframes(newClip, m_PosErr, m_RotErr, m_ScaErr, m_FloatErr); newClip.name = Path.GetFileNameWithoutExtension(newPath); EUtil.SaveAnimClip(newClip, newPath); } } } EUtil.PopGUIEnable(); }
public override void OnInspectorGUI() { Floor cp = (Floor)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { cp.PlaneDir = (EAxisD)EConUtil.DrawEnumBtns(EConUtil.AxisDs, EConUtil.AxisDStrs, cp.PlaneDir, "Plane Normal", "the normal direction of floor plane"); // offset cp.UseOffset = EditorGUILayout.Toggle(new GUIContent("Use Offset", "Add offset onto the result"), cp.UseOffset); if (cp.UseOffset) { cp.Offset = EditorGUILayout.FloatField(new GUIContent("Offset", "offset along normal direction"), cp.Offset); } // raycast cp.UseRaycast = EditorGUILayout.Toggle(new GUIContent("Use Raycast", "use raycast to decide contact point"), cp.UseRaycast); EditorGUILayout.BeginHorizontal(); { EUtil.PushLabelWidth(100f); EUtil.PushFieldWidth(20f); cp.Sticky = EditorGUILayout.Toggle(new GUIContent("Sticky", "Prevent sliding on plane"), cp.Sticky); cp.UseRotation = EditorGUILayout.Toggle(new GUIContent("Use Rotation", "Use the rotation from target object"), cp.UseRotation); EUtil.PopFieldWidth(); EUtil.PopLabelWidth(); } EditorGUILayout.EndHorizontal(); // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public void OnGUI() { m_targetSMR = EditorGUILayout.ObjectField("Main SMR:", m_targetSMR, typeof(SkinnedMeshRenderer), true) as SkinnedMeshRenderer; m_fromSMR = EditorGUILayout.ObjectField("Extra SMR:", m_fromSMR, typeof(SkinnedMeshRenderer), true) as SkinnedMeshRenderer; bool bAllSet = (m_targetSMR != null && m_fromSMR != null); Color c = bAllSet ? Color.green : Color.red; EUtil.PushGUIEnable(bAllSet); if (EUtil.Button("Share_Skele", c)) { Undo.RecordObject(m_fromSMR, "ShareSkele"); ShareSkeleton.ShareSkele(m_targetSMR, m_fromSMR); } EUtil.PopGUIEnable(); }
public override void OnInspectorGUI() { FollowPath cp = (FollowPath)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Spline = (BaseSplineBehaviour)EditorGUILayout.ObjectField("Target Spline", cp.Spline, typeof(BaseSplineBehaviour), true); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Spline); { EUtil.PushLabelWidth(100f); cp.Offset = EditorGUILayout.Slider(new GUIContent("Offset", "t parameter for the spline"), cp.Offset, 0, 1f); //axis and offset cp.FollowCurve = EditorGUILayout.Toggle(new GUIContent("Follow Curve", "owner's rotation will follow the spline"), cp.FollowCurve); if (cp.FollowCurve) { cp.ForwardDir = (EAxisD)EConUtil.DrawEnumBtns(AllAxis, AllAxisStr, cp.ForwardDir, "Forward Axis", "the axis of owner, which will be taken as the forward direction when follow the spline"); cp.UpDir = (EAxisD)EConUtil.DrawEnumBtns(AllAxis, AllAxisStr, cp.UpDir, "Up Axis", "the axis of owner, which will be taken as the up direction when follow the spline"); cp.UpDir = ConUtil.EnsureAxisNotColinear(cp.ForwardDir, cp.UpDir); GUILayout.Space(5f); } EUtil.PopLabelWidth(); // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public override void OnInspectorGUI() { CopyTransform cp = (CopyTransform)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); if (cp.Target && !ConstraintEditorUtil.IsTargetHasAllUniformScaleInHierarchy(cp.Target)) { ConstraintEditorUtil.NonUniformScaleWarning(cp.Target); } EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping"); if (m_foldoutSpace) { // target space cp.TargetSpace = (ESpace)EditorGUILayout.EnumPopup("Target Space", cp.TargetSpace); // owner space cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup("Owner Space", cp.OwnerSpace); GUILayout.Space(5f); } // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public override void OnInspectorGUI() { ConstraintStack cstack = (ConstraintStack)target; serializedObject.Update(); GUILayout.Space(3f); // constraints for (int i = 0; i < cstack.constraintCount; ++i) { BaseConstraint c = cstack.Get(i); if (!c) { //remove broken reference cstack.RemoveAt(i); --i; continue; } // draw constraint & buttons EditorGUILayout.BeginHorizontal(); { Color btnColor = c.IsActiveConstraint ? Color.white : Color.red; EUtil.PushBackgroundColor(btnColor); var content = new GUIContent(c.GetType().Name, "Click to fold other components"); Rect rc = GUILayoutUtility.GetRect(content, EditorStyles.toolbarButton); if (GUI.Button(rc, content, EditorStyles.toolbarButton)) { _FoldComponents(cstack); var wnd = EditorEditorWindow.OpenWindowWithActivatorRect(c, rc); EUtil.SetEditorWindowTitle(wnd, content.text); } EditorGUI.ProgressBar(rc, c.Influence, content.text); EUtil.PopBackgroundColor(); if (GUILayout.Button(new GUIContent(c.IsActiveConstraint ? EConUtil.activeBtn : EConUtil.inactiveBtn, "Toggle constraint active state"), EditorStyles.toolbarButton, GUILayout.Height(20), GUILayout.Width(20))) { c.IsActiveConstraint = !c.IsActiveConstraint; EditorUtility.SetDirty(cstack); } EUtil.PushGUIEnable(i != 0); if (GUILayout.Button(new GUIContent(EConUtil.upBtn, "move up"), EditorStyles.toolbarButton, GUILayout.Height(20), GUILayout.Width(20))) { cstack.Swap(i, i - 1); EditorUtility.SetDirty(cstack); //ComponentUtility.MoveComponentUp(c); } EUtil.PopGUIEnable(); EUtil.PushGUIEnable(i != cstack.constraintCount - 1); if (GUILayout.Button(new GUIContent(EConUtil.downBtn, "move down"), EditorStyles.toolbarButton, GUILayout.Height(20), GUILayout.Width(20))) { cstack.Swap(i, i + 1); EditorUtility.SetDirty(cstack); //ComponentUtility.MoveComponentDown(c); } EUtil.PopGUIEnable(); if (GUILayout.Button(new GUIContent(EConUtil.deleteBtn, "delete the constraint from stack"), EditorStyles.toolbarButton, GUILayout.Height(20), GUILayout.Width(20))) { MUndo.RecordObject(cstack, "Remove Constraint"); cstack.RemoveAt(i); EditorUtility.SetDirty(cstack); _FoldComponents(cstack); EditorGUIUtility.ExitGUI(); } } EditorGUILayout.EndHorizontal(); } //for(int i=0; i<cstack.constraintCount; ++i) GUILayout.Space(2f); EditorGUI.BeginChangeCheck(); int newOrder = EditorGUILayout.IntField(new GUIContent("Exec Order", "used to help decide evaluation order, the smaller the earlier"), cstack.ExecOrder); if (EditorGUI.EndChangeCheck()) { cstack.ExecOrder = newOrder; } { //new constraint window EUtil.DrawSplitter(new Color(1, 1, 1, 0.3f)); EditorGUILayout.BeginHorizontal(); GUILayout.Space(15f); var content = new GUIContent("Add Constraint", "Add new constraint into current stack"); Rect btnRc = GUILayoutUtility.GetRect(content, GUI.skin.button); if (GUI.Button(btnRc, content)) { var wnd = ScriptableObject.CreateInstance <ConstraintsWindow>(); Rect wndRc = EUtil.GetRectByActivatorRect(wnd.position, btnRc); wnd.position = wndRc; wnd.SetConstraintStack(cstack); wnd.ShowPopup(); wnd.Focus(); } GUILayout.Space(15f); EditorGUILayout.EndHorizontal(); } if (Pref.ShowInitInfos) { EditorGUILayout.PropertyField(m_spInitInfo, true); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { TransformMapping cp = (TransformMapping)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true); if (cp.Target && !ConstraintEditorUtil.IsTargetHasAllUniformScaleInHierarchy(cp.Target)) { ConstraintEditorUtil.NonUniformScaleWarning(cp.Target); } EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target); { //mapping m_foldoutMapping = EditorGUILayout.Foldout(m_foldoutMapping, "Mapping"); if (m_foldoutMapping) { //source (from target) ETransformData eSrcType = cp.SrcDataType; EConUtil.DrawChooseTransformData(ref eSrcType, "Src data type", "which data of transform of target is taken as source"); cp.SrcDataType = eSrcType; //destination (to owner) ETransformData eDstType = cp.DstDataType; EConUtil.DrawChooseTransformData(ref eDstType, "Dst data type", "which data of transform of target is taken as source"); cp.DstDataType = eDstType; // XYZ mapping GUILayout.Label("Source to Destination Mapping:"); for (int i = 0; i < 3; ++i) { EditorGUILayout.BeginHorizontal(); cp.Mapping[i] = (EAxis)EditorGUILayout.EnumPopup(cp.Mapping[i]); GUILayout.Label(" >> " + (char)('X' + i)); EditorGUILayout.EndHorizontal(); } // extrapolate cp.Extrapolate = EditorGUILayout.Toggle(new GUIContent("Extrapolate", "will extend the range outside specified range"), cp.Extrapolate); GUILayout.Space(5f); } //source data range m_foldoutSrcRange = EditorGUILayout.Foldout(m_foldoutSrcRange, "Source Range"); if (m_foldoutSrcRange) { Vector3 srcFrom = cp.SrcFrom; Vector3 srcTo = cp.SrcTo; EConUtil.DrawAxisRange(ref srcFrom, ref srcTo); cp.SrcFrom = srcFrom; cp.SrcTo = srcTo; GUILayout.Space(5f); } //dest data range m_foldoutDstRange = EditorGUILayout.Foldout(m_foldoutDstRange, "Destination Range"); if (m_foldoutDstRange) { Vector3 dstFrom = cp.DstFrom; Vector3 dstTo = cp.DstTo; EConUtil.DrawAxisRange(ref dstFrom, ref dstTo); cp.DstFrom = dstFrom; cp.DstTo = dstTo; GUILayout.Space(5f); } // space mapping m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping"); if (m_foldoutSpace) { // target space cp.TargetSpace = (ESpace)EditorGUILayout.EnumPopup("Target Space", cp.TargetSpace); // owner space cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup("Owner Space", cp.OwnerSpace); GUILayout.Space(5f); } // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
// public method #endregion "public method" #region "private method" private void _DrawDeformEntry(MorphProc proc, int deformIdx, bool isBasis = true) { ShapeKeyMorphSO deform = (ShapeKeyMorphSO)m_propDeforms.GetArrayElementAtIndex(deformIdx).objectReferenceValue; EditorGUILayout.BeginHorizontal(); { float newWeight = 0f; // weight if (isBasis) { EUtil.PushGUIEnable(false); } EditorGUI.BeginChangeCheck(); newWeight = EditorGUILayout.FloatField(deform.name, m_propAnimWeights[deformIdx].floatValue); if (EditorGUI.EndChangeCheck()) { m_propAnimWeights[deformIdx].floatValue = Mathf.Clamp(newWeight, 0, 100f); } if (isBasis) { EUtil.PopGUIEnable(); } // after weight if (isBasis) { //the basis GUILayout.Space(20f); if (EUtil.Button("R", "Reset as Basis", Color.green, GUILayout.Width(42f))) { Undo.RecordObject(proc, "MorphProc Inspector"); proc.ResetToBasisShape(); } } else { if (GUILayout.Button(new GUIContent(m_texDetail, "Edit details of this deform"), m_styleBtn, GUILayout.Width(20f))) { var e = (BaseMorphSOEditor)Editor.CreateEditor(deform); e.m_MorphProcEditor = this; e.m_MorphProc = proc; e.m_MorphIdx = deformIdx; EditorEditorWindow.OpenWindowWithEditor(e); } if (GUILayout.Button(new GUIContent(m_texApply, "Apply only this deform 100%"), m_styleBtn, GUILayout.Width(20f))) { Undo.RecordObject(proc, "MorphProc Inspector"); proc.ApplyOnlyMorphAt(deformIdx); } if (GUILayout.Button(new GUIContent(m_texDelete, "Delete this deform"), m_styleBtn, GUILayout.Width(20f))) { if (EditorUtility.DisplayDialog("To be or not to be", "Are you sure to delete this Morph?", "Go Ahead", "No No No")) { Undo.RecordObject(proc, "MorphProc Inspector"); proc.RemoveShapeKeyMorphAt(deformIdx); } } } } EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { EmptyMarker o = (EmptyMarker)target; EditorGUI.BeginChangeCheck(); var newMf = (MeshFilter)EditorGUILayout.ObjectField("MeshFilter", o.mf, typeof(MeshFilter), true); if (EditorGUI.EndChangeCheck()) { o.mf = newMf; EUtil.SetDirty(o); } EUtil.PushGUIEnable(o.mf != null); { EditorGUI.BeginChangeCheck(); var newMesh = (Mesh)EditorGUILayout.ObjectField("Mesh", o.mesh, typeof(Mesh), false); if (EditorGUI.EndChangeCheck()) { o.mesh = newMesh; EUtil.SetDirty(o); } EditorGUI.BeginChangeCheck(); var newMat = (Material)EditorGUILayout.ObjectField("Material", o.material, typeof(Material), false); if (EditorGUI.EndChangeCheck()) { o.material = newMat; EUtil.SetDirty(o); } EditorGUI.BeginChangeCheck(); var newSelMat = (Material)EditorGUILayout.ObjectField("Selected Material", o.selectedMaterial, typeof(Material), false); if (EditorGUI.EndChangeCheck()) { o.selectedMaterial = newSelMat; EUtil.SetDirty(o); } } EUtil.PopGUIEnable(); EditorGUI.BeginChangeCheck(); o.jumpTo = (Transform)EditorGUILayout.ObjectField("Jump To", o.jumpTo, typeof(Transform), true); if (EditorGUI.EndChangeCheck()) { EUtil.SetDirty(o); } // create "mesh" child object to hold marker EditorGUILayout.BeginHorizontal(); { Rect rc = GUILayoutUtility.GetRect(new GUIContent("Presets"), GUI.skin.button); if (GUI.Button(rc, new GUIContent("Presets", "select presets marker"))) { PopupWindow.Show(rc, new EmptyMarkerPresetsPopup(o)); } if (GUILayout.Button(new GUIContent("Delete", "delete marker"))) { if (o.mf != null) { MUndo.DestroyObj(o.mf.gameObject); } MUndo.DestroyObj(o); EditorGUIUtility.ExitGUI(); } if (o.jumpTo != null) { if (GUILayout.Button(new GUIContent("Target", "jump to the target transform"))) { Selection.activeTransform = o.jumpTo; } } } EditorGUILayout.EndHorizontal(); }
void OnGUI() { if (!EUtil.IsUnityAnimationWindowOpen()) { EditorGUILayout.LabelField("Animation Window is not open..."); return; } // mode switch EditorGUILayout.BeginHorizontal(); { EUtil.PushGUIEnable(m_OpMode != OpMode.AddPathPrefixOnMultiCurveBinding); if (EUtil.Button("Batch AddPrefix", Color.green)) { _OnOpModeChange(m_OpMode, OpMode.AddPathPrefixOnMultiCurveBinding); m_OpMode = OpMode.AddPathPrefixOnMultiCurveBinding; } EUtil.PopGUIEnable(); EUtil.PushGUIEnable(m_OpMode != OpMode.ChangePath); if (EUtil.Button("Change Path", Color.green)) { _OnOpModeChange(m_OpMode, OpMode.ChangePath); m_OpMode = OpMode.ChangePath; } EUtil.PopGUIEnable(); EUtil.PushGUIEnable(m_OpMode != OpMode.EditSingleCurveBinding); if (EUtil.Button("Edit Single Curve", Color.green)) { _OnOpModeChange(m_OpMode, OpMode.EditSingleCurveBinding); m_OpMode = OpMode.EditSingleCurveBinding; } EUtil.PopGUIEnable(); EUtil.PushGUIEnable(m_OpMode != OpMode.AddNewCurve); if (EUtil.Button("Add New Curve", Color.green)) { _OnOpModeChange(m_OpMode, OpMode.AddNewCurve); m_OpMode = OpMode.AddNewCurve; } EUtil.PopGUIEnable(); } EditorGUILayout.EndHorizontal(); // specific GUI switch (m_OpMode) { case OpMode.AddPathPrefixOnMultiCurveBinding: { _GUI_BatchAddPrefix(); } break; case OpMode.ChangePath: { _GUI_ChangePath(); } break; case OpMode.EditSingleCurveBinding: { _GUI_EditSingleCurve(); } break; case OpMode.AddNewCurve: { _GUI_AddNewCurve(); } break; default: Dbg.LogErr("AnimCurvePropEditor.OnGUI: unexpected OpMode: {0}", m_OpMode); break; } }
public override void OnInspectorGUI() { MaintainVolume cp = (MaintainVolume)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint); { // base volume cp.BaseVolume = EditorGUILayout.FloatField(new GUIContent("Base", "the base value of volume, the product of xyz component of scale"), cp.BaseVolume); cp.BaseVolume = Mathf.Max(cp.BaseVolume, 0.01f); //affect X/Y/Z m_foldoutAxis = EditorGUILayout.Foldout(m_foldoutAxis, "Axis"); if (m_foldoutAxis) { EAxis eAffect = cp.FreeAxis; EditorGUILayout.BeginHorizontal(); { EUtil.PushBackgroundColor(eAffect == EAxis.X ? EConUtil.kSelectedBtnColor : Color.white); if (GUILayout.Button(new GUIContent("X", "X axis as main axis"), EditorStyles.toolbarButton)) { eAffect = EAxis.X; } EUtil.PopBackgroundColor(); EUtil.PushBackgroundColor(eAffect == EAxis.Y ? EConUtil.kSelectedBtnColor : Color.white); if (GUILayout.Button(new GUIContent("Y", "Y axis as main axis"), EditorStyles.toolbarButton)) { eAffect = EAxis.Y; } EUtil.PopBackgroundColor(); EUtil.PushBackgroundColor(eAffect == EAxis.Z ? EConUtil.kSelectedBtnColor : Color.white); if (GUILayout.Button(new GUIContent("Z", "Z axis as main axis"), EditorStyles.toolbarButton)) { eAffect = EAxis.Z; } EUtil.PopBackgroundColor(); } EditorGUILayout.EndHorizontal(); cp.FreeAxis = eAffect; GUILayout.Space(5f); } // vol mul cp.VolMul = EditorGUILayout.FloatField(new GUIContent("Multiplier", "extra multiplier on base volume"), cp.VolMul); // space m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping"); if (m_foldoutSpace) { // owner space cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup("Owner Space", cp.OwnerSpace); GUILayout.Space(5f); } // influence cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
private void _GUI_ChangePath() { EditorWindow uaw = (EditorWindow)EUtil.GetUnityAnimationWindow(); object uawstate = EUtil.GetUnityAnimationWindowState(uaw); m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState", "m_ActiveAnimationClip", uawstate) as AnimationClip; //1. collect the TrPaths from active curves List <EditorCurveBinding> bindingInfos = new List <EditorCurveBinding>(); IList curves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "activeCurves", uawstate); if (curves.Count <= 0) { EditorGUILayout.LabelField("Please Select a Curve first..."); return; } EditorCurveBinding theBinding = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", curves[0]); string toChangePath = theBinding.path; IList allCurves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "allCurves", uawstate); foreach (var oneUAWCurve in allCurves) { EditorCurveBinding oneBinding = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", oneUAWCurve); if (oneBinding.path == toChangePath) { bindingInfos.Add(oneBinding); } } //2. display EditorGUILayout.LabelField("Affected curves:"); m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, false, true, GUILayout.Height(200f)); { foreach (var oneInfo in bindingInfos) { EditorCurveBinding oneBinding = oneInfo; GUILayout.BeginHorizontal(); { EUtil.PushContentColor(Color.yellow); GUILayout.Label(oneBinding.path); EUtil.PopContentColor(); EUtil.PushContentColor(Color.green); GUILayout.Label(oneBinding.propertyName); EUtil.PopContentColor(); } GUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); //3. apply prefix EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("R", GUILayout.Width(20))) { GUIUtility.keyboardControl = 0; m_NewPath = toChangePath; } m_NewPath = EditorGUILayout.TextField("New Path:", m_NewPath); EditorGUILayout.EndHorizontal(); EUtil.PushGUIEnable(m_CurClip != null && bindingInfos.Count > 0); if (EUtil.Button("Change Path!", Color.green)) { _DoChangePath(bindingInfos, m_NewPath); } EUtil.PopGUIEnable(); }