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 static void DrawActiveLine(BaseConstraint cp) { EUtil.PushLabelWidth(50f); EUtil.PushFieldWidth(30f); EditorGUILayout.BeginHorizontal(); { cp.IsActiveConstraint = EditorGUILayout.Toggle(new GUIContent("Active", "whether this constraint is active"), cp.IsActiveConstraint); GUILayout.FlexibleSpace(); if (cp.HasGizmos) { cp.ShowGizmos = EditorGUILayout.Toggle(new GUIContent("Gizmos", "whether display gizmos for this constraint"), cp.ShowGizmos); } else { cp.ShowGizmos = false; } } EditorGUILayout.EndHorizontal(); EUtil.PopFieldWidth(); EUtil.PopLabelWidth(); }
public override void OnInspectorGUI() { if (targets.Length > 1) { EditorGUILayout.HelpBox("Cannot edit multiple spline together", MessageType.Info, true); ms_isMultiEdit = true; return; } else { ms_isMultiEdit = false; } CatmullRomCentripetalBehaviour behaviour = (CatmullRomCentripetalBehaviour)target; CatmullRomCentripetal spline = (CatmullRomCentripetal)behaviour.Spline; GUILayout.Space(5f); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(new GUIContent("Add Point", "hotkey: I"), EditorStyles.toolbarButton)) { _AddPoint(spline); } if (GUILayout.Button(new GUIContent("Del Point", "hotkey: X"), EditorStyles.toolbarButton)) { _DelPoint(spline); } if (GUILayout.Button(spline.Cycle ? "Break Cycle" : "Make Cycle", EditorStyles.toolbarButton)) { _ToggleCycle(spline); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(5f); if (m_curPtIdx >= 0) { EditorGUILayout.BeginHorizontal(); { MUndo.RecordObject(this, "change current point"); GUILayout.Label("Current Point"); if (GUILayout.Button("<<")) { m_curPtIdx = Mathf.Max(0, m_curPtIdx - 1); } EditorGUI.BeginChangeCheck(); m_curPtIdx = EditorGUILayout.IntField(m_curPtIdx); if (EditorGUI.EndChangeCheck()) { m_curPtIdx = Mathf.Clamp(m_curPtIdx, 0, spline.PointCount); } GUILayout.Label(" / " + (spline.PointCount - 1)); if (GUILayout.Button(">>")) { m_curPtIdx = Mathf.Min(m_curPtIdx + 1, spline.PointCount - 1); } } EditorGUILayout.EndHorizontal(); MUndo.RecordObject(target, "modify control point"); EUtil.PushLabelWidth(80f); spline[m_curPtIdx] = EUtil.DrawV3P(new GUIContent("Position"), spline[m_curPtIdx]); spline.SetTilt(m_curPtIdx, EditorGUILayout.FloatField("Tilt", spline.GetTilt(m_curPtIdx))); EUtil.PopLabelWidth(); } ms_foldoutSettings = EditorGUILayout.Foldout(ms_foldoutSettings, "Settings"); if (ms_foldoutSettings) { MUndo.RecordObject(this, "change setting"); spline.Resolution = EditorGUILayout.IntField("Point/Seg", spline.Resolution); spline.TwistMtd = (ETwistMethod)EditorGUILayout.EnumPopup(new GUIContent("Twist Method", "Decide how to calculate the base-up direction before applying tilt"), spline.TwistMtd); ms_drawArrow = EditorGUILayout.Toggle("Draw Arrow", ms_drawArrow); ms_drawUp = EditorGUILayout.Toggle("Draw Up", ms_drawUp); ms_arrowLineLen = EditorGUILayout.FloatField("Arrow LineLen", ms_arrowLineLen); ms_drawPts = EditorGUILayout.Toggle("Draw points", ms_drawPts); ms_ptSize = EditorGUILayout.FloatField("Point size", ms_ptSize); ms_lookAtDist = EditorGUILayout.FloatField(new GUIContent("LookAt dist", "the distance from camera to target point when camera in follow mode"), ms_lookAtDist); } ms_foldoutTSlider = EditorGUILayout.Foldout(ms_foldoutTSlider, "T slider"); if (ms_foldoutTSlider) { EditorGUI.BeginChangeCheck(); EUtil.PushLabelWidth(20f); m_tSlider = EditorGUILayout.Slider("T", m_tSlider, 0, 1f); EUtil.PopLabelWidth(); if (EditorGUI.EndChangeCheck()) { //Transform tr = behaviour.transform; EUtil.SceneViewLookAt( behaviour.GetTransformedPosition(m_tSlider), Quaternion.LookRotation(behaviour.GetTransformedTangent(m_tSlider), behaviour.GetTransformedUp(m_tSlider)), ms_lookAtDist); } } if (GUI.changed) { EUtil.RepaintSceneView(); } }
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 } }