public override void OnInspectorGUI() { DragTrack_Curved _target = (DragTrack_Curved)target; EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Track shape:", EditorStyles.boldLabel); _target.radius = EditorGUILayout.FloatField("Radius:", _target.radius); _target.handleColour = EditorGUILayout.ColorField("Handles colour:", _target.handleColour); _target.doLoop = EditorGUILayout.Toggle("Is looped?", _target.doLoop); if (!_target.doLoop) { _target.maxAngle = EditorGUILayout.FloatField("Maximum angle:", _target.maxAngle); if (_target.maxAngle > 360f) { _target.maxAngle = 360f; } } EditorGUILayout.EndVertical(); SharedGUI(true); }
public void OnSceneGUI() { DragTrack_Curved _target = (DragTrack_Curved)target; float _angle = _target.maxAngle; if (_target.doLoop) { _angle = 360f; } Handles.color = new Color(_target.handleColour.r / 2f, _target.handleColour.g / 2f, _target.handleColour.b / 2f, _target.handleColour.a); Vector3 startPosition = _target.transform.position + (_target.radius * _target.transform.right); Handles.DrawSolidDisc(startPosition, _target.transform.up, _target.discSize); Transform t = _target.transform; Vector3 originalPosition = _target.transform.position; Quaternion originalRotation = _target.transform.rotation; t.position = startPosition; t.RotateAround(originalPosition, _target.transform.forward, _angle); Handles.color = _target.handleColour; Handles.DrawSolidDisc(t.position, t.up, _target.discSize); _target.transform.position = originalPosition; _target.transform.rotation = originalRotation; Handles.color = _target.handleColour; Handles.DrawWireArc(_target.transform.position, _target.transform.forward, _target.transform.right, _angle, _target.radius); }
private void DrawSnapHandles(TrackSnapData trackSnapData, DragTrack_Curved curvedTrack) { float minPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong - trackSnapData.Width); float maxPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong + trackSnapData.Width); Quaternion rot = Quaternion.AngleAxis(curvedTrack.MaxAngle * trackSnapData.PositionAlong, curvedTrack.transform.forward); Vector3 endUp = RotatePointAroundPivot(curvedTrack.transform.up, Vector3.zero, rot); Handles.color = trackSnapData.GizmoColor; Vector3 positionAlongWorld = curvedTrack.GetGizmoPosition(trackSnapData.PositionAlong); Handles.DrawSolidDisc(positionAlongWorld, endUp, curvedTrack.discSize / 2f); rot = Quaternion.AngleAxis(curvedTrack.MaxAngle * minPositionAlong, curvedTrack.transform.forward); endUp = RotatePointAroundPivot(curvedTrack.transform.right, Vector3.zero, rot); Handles.DrawWireArc(curvedTrack.transform.position, curvedTrack.transform.forward, endUp, curvedTrack.MaxAngle * (maxPositionAlong - minPositionAlong), curvedTrack.radius * 1.01f); Quaternion minRot = Quaternion.AngleAxis(curvedTrack.MaxAngle * minPositionAlong, curvedTrack.transform.forward); endUp = RotatePointAroundPivot(curvedTrack.transform.up, Vector3.zero, minRot); Vector3 minPositionAlongWorld = curvedTrack.GetGizmoPosition(minPositionAlong); Handles.DrawSolidDisc(minPositionAlongWorld, endUp, curvedTrack.discSize / 4f); Quaternion maxRot = Quaternion.AngleAxis(curvedTrack.MaxAngle * maxPositionAlong, curvedTrack.transform.forward); endUp = RotatePointAroundPivot(curvedTrack.transform.up, Vector3.zero, maxRot); Vector3 maxPositionAlongWorld = curvedTrack.GetGizmoPosition(maxPositionAlong); Handles.DrawSolidDisc(maxPositionAlongWorld, endUp, curvedTrack.discSize / 4f); }
public void OnSceneGUI() { DragTrack_Curved _target = (DragTrack_Curved)target; Handles.color = new Color(_target.handleColour.r / 2f, _target.handleColour.g / 2f, _target.handleColour.b / 2f, _target.handleColour.a); Handles.DrawSolidDisc(_target.GetGizmoPosition(0f), _target.transform.up, _target.discSize); if (!_target.Loops) { Handles.color = _target.handleColour; Quaternion rot = Quaternion.AngleAxis(_target.MaxAngle, _target.transform.forward); Vector3 endUp = RotatePointAroundPivot(_target.transform.up, Vector3.zero, rot); Handles.DrawSolidDisc(_target.GetGizmoPosition(1f), endUp, _target.discSize); } Handles.color = _target.handleColour; Handles.DrawWireArc(_target.transform.position, _target.transform.forward, _target.transform.right, _target.MaxAngle, _target.radius); if (_target.doSnapping) { foreach (TrackSnapData trackSnapData in _target.allTrackSnapData) { DrawSnapHandles(trackSnapData, _target); } } }
public override void OnInspectorGUI() { DragTrack_Curved _target = (DragTrack_Curved)target; EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Track shape:", EditorStyles.boldLabel); _target.radius = CustomGUILayout.FloatField("Radius:", _target.radius, "", "The track's radius"); _target.handleColour = CustomGUILayout.ColorField("Handles colour:", _target.handleColour, "", "The colour of Scene window Handles"); _target.doLoop = CustomGUILayout.Toggle("Is looped?", _target.doLoop, "", "If True, then the track forms a complete loop"); if (!_target.doLoop) { _target.maxAngle = CustomGUILayout.FloatField("Maximum angle:", _target.maxAngle, "", "The angle of the tracks's curve"); if (_target.maxAngle > 360f) { _target.maxAngle = 360f; } } EditorGUILayout.EndVertical(); SharedGUI(true); }
public override void OnInspectorGUI() { DragTrack_Curved _target = (DragTrack_Curved)target; EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Track shape:", EditorStyles.boldLabel); _target.radius = CustomGUILayout.FloatField("Radius:", _target.radius, "", "The track's radius"); if (_target.radius < 0f) { _target.radius = 0f; } _target.handleColour = CustomGUILayout.ColorField("Handles colour:", _target.handleColour, "", "The colour of Scene window Handles"); _target.doLoop = CustomGUILayout.Toggle("Is looped?", _target.doLoop, "", "If True, then the track forms a complete loop"); if (!_target.doLoop) { _target.maxAngle = CustomGUILayout.Slider("Maximum angle:", _target.maxAngle, 0f, 360, "", "The angle of the tracks's curve"); } _target.dragMovementCalculation = (DragMovementCalculation)CustomGUILayout.EnumPopup("Movement input:", _target.dragMovementCalculation); if (_target.dragMovementCalculation == DragMovementCalculation.CursorPosition && !_target.Loops) { _target.preventEndToEndJumping = CustomGUILayout.ToggleLeft("Prevent end-to-end jumping?", _target.preventEndToEndJumping, "", "If True, then the dragged object will be prevented from jumping from one end to the other without first moving somewhere in between"); } _target.discSize = CustomGUILayout.Slider("Gizmo size:", _target.discSize, 0f, 2f, "", "The size of the track's ends, as seen in the Scene window"); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("End-colliders", EditorStyles.boldLabel); if (!_target.Loops) { _target.generateColliders = CustomGUILayout.Toggle("Generate end-colliders?", _target.generateColliders); } if (_target.generateColliders && !_target.Loops) { _target.colliderMaterial = (PhysicMaterial)CustomGUILayout.ObjectField <PhysicMaterial> ("Material:", _target.colliderMaterial, false, "", "Physics Material to give the track's end colliders"); } EditorGUILayout.EndVertical(); SnapDataGUI(_target, true); UnityVersionHandler.CustomSetDirty(_target); }