public override void OnInspectorGUI()
        {
            DragTrack_Hinge _target = (DragTrack_Hinge)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;
                }
            }
            else
            {
                _target.limitRevolutions = EditorGUILayout.Toggle("Limit no. of revolutions?", _target.limitRevolutions);
                if (_target.limitRevolutions)
                {
                    _target.maxRevolutions = EditorGUILayout.IntField("Max no. of revolutions:", _target.maxRevolutions);
                }
            }

            _target.alignDragToFront = EditorGUILayout.Toggle("Align drag vector to front?", _target.alignDragToFront);

            EditorGUILayout.EndVertical();

            SharedGUI(false);
        }
        public void OnSceneGUI()
        {
            DragTrack_Hinge _target = (DragTrack_Hinge)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);
        }
        public override void OnInspectorGUI()
        {
            DragTrack_Hinge _target = (DragTrack_Hinge)target;

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Track shape:", EditorStyles.boldLabel);

            _target.radius       = CustomGUILayout.FloatField("Radius:", _target.radius, "", "The track's radius (for visualising in the Scene window)");
            _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 objects can be rotated a full revolution");
            if (!_target.doLoop)
            {
                _target.maxAngle = CustomGUILayout.FloatField("Maximum angle:", _target.maxAngle, "", "How much an object can be rotated by");

                if (_target.maxAngle > 360f)
                {
                    _target.maxAngle = 360f;
                }
            }
            else
            {
                _target.limitRevolutions = CustomGUILayout.Toggle("Limit revolutions?", _target.limitRevolutions, "", "If True, then the number of revolutions an object can rotate is limited");
                if (_target.limitRevolutions)
                {
                    _target.maxRevolutions = CustomGUILayout.IntField("Max revolutions:", _target.maxRevolutions, "", "The maximum number of revolutions an object can be rotated by");
                }
            }

            _target.alignDragToFront = CustomGUILayout.Toggle("Align drag vector to front?", _target.alignDragToFront, "", "If True, then the calculated drag vector will be based on the track's orientation, rather than the object being rotated, so that the input drag vector will always need to be the same direction");

            EditorGUILayout.EndVertical();

            SharedGUI(false);
        }
示例#4
0
        private void DrawTrackRegions(TrackSnapData trackSnapData, DragTrack_Hinge hingeTrack)
        {
            float minPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong - trackSnapData.Width);
            float maxPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong + trackSnapData.Width);

            Quaternion rot   = Quaternion.AngleAxis(hingeTrack.MaxAngle * trackSnapData.PositionAlong, hingeTrack.transform.forward);
            Vector3    endUp = RotatePointAroundPivot(hingeTrack.transform.up, Vector3.zero, rot);

            Handles.color = trackSnapData.GizmoColor;
            Vector3 positionAlongWorld = hingeTrack.GetGizmoPosition(trackSnapData.PositionAlong);

            Handles.DrawSolidDisc(positionAlongWorld, endUp, hingeTrack.discSize / 2f);

            rot   = Quaternion.AngleAxis(hingeTrack.MaxAngle * minPositionAlong, hingeTrack.transform.forward);
            endUp = RotatePointAroundPivot(hingeTrack.transform.right, Vector3.zero, rot);

            Handles.DrawWireArc(hingeTrack.transform.position, hingeTrack.transform.forward, endUp, hingeTrack.MaxAngle * (maxPositionAlong - minPositionAlong), hingeTrack.radius);

            Quaternion minRot = Quaternion.AngleAxis(hingeTrack.MaxAngle * minPositionAlong, hingeTrack.transform.forward);

            endUp = RotatePointAroundPivot(hingeTrack.transform.up, Vector3.zero, minRot);
            Vector3 minPositionAlongWorld = hingeTrack.GetGizmoPosition(minPositionAlong);

            Handles.DrawSolidDisc(minPositionAlongWorld, endUp, hingeTrack.discSize / 4f);

            Quaternion maxRot = Quaternion.AngleAxis(hingeTrack.MaxAngle * maxPositionAlong, hingeTrack.transform.forward);

            endUp = RotatePointAroundPivot(hingeTrack.transform.up, Vector3.zero, maxRot);
            Vector3 maxPositionAlongWorld = hingeTrack.GetGizmoPosition(maxPositionAlong);

            Handles.DrawSolidDisc(maxPositionAlongWorld, endUp, hingeTrack.discSize / 4f);
        }
示例#5
0
        public void OnSceneGUI()
        {
            DragTrack_Hinge _target = (DragTrack_Hinge)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);
            Handles.color = _target.handleColour;

            if (!_target.Loops)
            {
                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.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);
                }
            }
        }
示例#6
0
        public override void OnInspectorGUI()
        {
            DragTrack_Hinge _target = (DragTrack_Hinge)target;

            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Track shape:", EditorStyles.boldLabel);

            _target.radius = CustomGUILayout.FloatField("Radius:", _target.radius, "", "The track's radius (for visualising in the Scene window)");
            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 objects can be rotated a full revolution");
            if (!_target.doLoop)
            {
                _target.maxAngle = CustomGUILayout.Slider("Maximum angle:", _target.maxAngle, 0f, 360, "", "How much an object can be rotated by");
            }
            else
            {
                _target.limitRevolutions = CustomGUILayout.Toggle("Limit revolutions?", _target.limitRevolutions, "", "If True, then the number of revolutions an object can rotate is limited");
                if (_target.limitRevolutions)
                {
                    _target.maxRevolutions = CustomGUILayout.IntField("Max revolutions:", _target.maxRevolutions, "", "The maximum number of revolutions an object can be rotated by");
                    if (_target.maxRevolutions < 1)
                    {
                        _target.maxRevolutions = 1;
                    }
                }
            }

            _target.dragMovementCalculation = (DragMovementCalculation)CustomGUILayout.EnumPopup("Movement input:", _target.dragMovementCalculation);
            if (_target.dragMovementCalculation == DragMovementCalculation.DragVector)
            {
                _target.alignDragToFront = CustomGUILayout.ToggleLeft("Align drag vector to front?", _target.alignDragToFront, "", "If True, then the calculated drag vector will be based on the track's orientation, rather than the object being rotated, so that the input drag vector will always need to be the same direction");
            }
            else 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");

            CustomGUILayout.EndVertical();

            SnapDataGUI(_target, true);

            UnityVersionHandler.CustomSetDirty(_target);
        }