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 } }
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 } }
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() { 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() { 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() { 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 } }
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 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 } }
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 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() { 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 } }
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 override void OnInspectorGUI() { CCDSolverMB cp = (CCDSolverMB)target; EditorGUI.BeginChangeCheck(); EConUtil.DrawActiveLine(cp); //constraint target cp.Target = (Transform)EditorGUILayout.ObjectField("Target Object", cp.Target, typeof(Transform), true); EUtil.DrawSplitter(); EUtil.PushGUIEnable(cp.IsActiveConstraint); { // reset button GUILayout.BeginHorizontal(); GUILayout.Space(30f); if (EUtil.Button("Recollect IKConstraints", "click this when add new IK-constraint on this IK-link", Color.green)) { cp.GetSolver(true); EUtil.RepaintSceneView(); } GUILayout.Space(30f); GUILayout.EndHorizontal(); // jointList if (!m_manualSetJoints) { m_autoCollectBoneCount = EditorGUILayout.IntField(CONT_BoneCnt, m_autoCollectBoneCount); } else { var jointList = cp.jointList; Undo.RecordObject(cp, "JointList"); for (int i = 0; i < jointList.Count; ++i) { EditorGUILayout.BeginHorizontal(); jointList[i] = (Transform)EditorGUILayout.ObjectField(jointList[i], typeof(Transform), true); if (GUILayout.Button(new GUIContent("+", "add new entry"))) { jointList.Insert(i, null); GUIUtility.ExitGUI(); } if (GUILayout.Button(new GUIContent("-", "delete this entry"))) { jointList.RemoveAt(i); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(m_manualSetJoints ? CONT_ManualSetJoints : CONT_AutoSetJoints, EditorStyles.toolbarButton)) { m_manualSetJoints = !m_manualSetJoints; } bool isIdentical = _CheckJointListIdentical(cp); EUtil.PushBackgroundColor(isIdentical ? Color.white : Color.blue); if (GUILayout.Button(new GUIContent("Apply", "Apply the joint list"), EditorStyles.toolbarButton)) { if (m_manualSetJoints) { if (_CheckManualSetJointList(cp)) { cp._RenewInitInfoAndSolver(); } } else { cp._RenewByCollectJointsWithBontCount(m_autoCollectBoneCount); } m_autoCollectBoneCount = cp.boneCount; } EUtil.PopBackgroundColor(); EditorGUILayout.EndHorizontal(); EUtil.DrawSplitter(); // dist thres EditorGUI.BeginChangeCheck(); float newDistThres = EditorGUILayout.FloatField(CONT_DistThres, cp.distThres); if (EditorGUI.EndChangeCheck()) { if (newDistThres > 0f) { Undo.RecordObject(cp, "Set Dist Thres"); cp.distThres = newDistThres; } } cp.useDamp = EditorGUILayout.Toggle(CONT_Damp, cp.useDamp); if (cp.useDamp) { cp.globalDamp = EditorGUILayout.FloatField("Global damp", cp.globalDamp); } cp.useTargetRotation = EditorGUILayout.Toggle(CONT_UseTargetRotation, cp.useTargetRotation); cp.maxIteration = EditorGUILayout.IntField(CONT_MaxIteration, cp.maxIteration); cp.revertOpt = (CCDSolver.RevertOption)EditorGUILayout.EnumPopup(CONT_RevertOpt, cp.revertOpt); m_markerSize.val = Mathf.Max(0, EditorGUILayout.FloatField(CONT_BoneMarkSize, m_markerSize.val)); EUtil.PushGUIEnable(!cp.Target); { if (GUILayout.Button("Control Mode: " + (cp.Target ? "Target" : m_panel.ToString()), EditorStyles.toolbarButton)) { m_panel = (EPanel)((int)(m_panel + 1) % (int)EPanel.END); cp.GetSolver().Target = cp.transform.position; } _OnGUI_IKPanel(cp); } EUtil.PopGUIEnable(); // influence GUILayout.Space(5f); cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}"); //initInfos if (Pref.ShowInitInfos) { EditorGUILayout.PropertyField(serializedObject.FindProperty("m_initInfos"), true); } } EUtil.PopGUIEnable(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode } }
public override void OnInspectorGUI() { CopyRotation cp = (CopyRotation)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); { //affect X/Y/Z m_foldoutAffect.val = EditorGUILayout.Foldout(m_foldoutAffect.val, "Affect"); if (m_foldoutAffect.val) { EUtil.PushLabelWidth(12f); EUtil.PushFieldWidth(16f); EditorGUILayout.BeginHorizontal(); { EAxisD eAffect = cp.Affect; eAffect = EConUtil.DrawAffectField(eAffect, "+X", "apply X from target to owner", EAxisD.X, EAxisD.InvX); eAffect = EConUtil.DrawAffectField(eAffect, "-X", "apply -X from target to owner", EAxisD.InvX, EAxisD.X); eAffect = EConUtil.DrawAffectField(eAffect, "+Y", "apply Y from target to owner", EAxisD.Y, EAxisD.InvY); eAffect = EConUtil.DrawAffectField(eAffect, "-Y", "apply -Y from target to owner", EAxisD.InvY, EAxisD.Y); eAffect = EConUtil.DrawAffectField(eAffect, "+Z", "apply Z from target to owner", EAxisD.Z, EAxisD.InvZ); eAffect = EConUtil.DrawAffectField(eAffect, "-Z", "apply -Z from target to owner", EAxisD.InvZ, EAxisD.Z); cp.Affect = eAffect; } EditorGUILayout.EndHorizontal(); EUtil.PopFieldWidth(); EUtil.PopLabelWidth(); // 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 owner space"), cp.Offset); } GUILayout.Space(5f); } m_foldoutSpace.val = EditorGUILayout.Foldout(m_foldoutSpace.val, "Space Mapping"); if (m_foldoutSpace.val) { // 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 } }