Пример #1
0
    void DrawRecognitionDistance()
    {
        foreach (FlockAgent agent in flock.Agents.Values)
        {
            Handles.color = agent.NeighborCount > 0 ? new Color(255f, 255f, 0, .2f) : new Color(255f, 255f, 255f, .1f);
            Handles.SphereHandleCap(
                agent.GetInstanceID(),
                agent.transform.position,
                Quaternion.identity,
                flock.NeighborRadius,
                EventType.Repaint
                );

            // Draw a vector of fish
            Handles.color = Color.white;
            Quaternion rotation = agent.transform.rotation;
            Handles.ArrowHandleCap(2, agent.transform.position, rotation, agent.transform.forward.magnitude * 3f, EventType.Repaint);
            Handles.color = Color.red;
            Handles.DrawLine(agent.transform.position,
                             agent.transform.position + agent.transform.up * 3f);
        }
    }
        private float DrawPlaneAndHandle(Vector3[] plane, Vector3 planeSize, float zPosition, Vector3 cagePosition, string label, bool editingEnabled)
        {
            cagePosition.z = zPosition;
            MakePlaneFromPoint(plane, cagePosition, planeSize, transform);

            if (VisiblePlanes)
            {
                Handles.DrawSolidRectangleWithOutline(plane, Color.Lerp(Handles.color, Color.clear, 0.65f), Handles.color);
            }

            Vector3 mousePosition = SceneView.currentDrawingSceneView.camera.ScreenToViewportPoint(Event.current.mousePosition);

            mousePosition.y = 1f - mousePosition.y;
            mousePosition.z = 0;
            Vector3 handleVisiblePos = SceneView.currentDrawingSceneView.camera.WorldToViewportPoint(plane[1]);

            handleVisiblePos.z = 0;

            if (Vector3.Distance(mousePosition, handleVisiblePos) < labelMouseOverDistance)
            {
                DrawLabel(plane[1], transform.up - transform.right, label, labelStyle);
                SceneView.RepaintAll();
            }

            float handleSize = HandleUtility.GetHandleSize(plane[1]) * 0.15f;

            Handles.ArrowHandleCap(0, plane[1], Quaternion.LookRotation(transform.forward, Vector3.up), handleSize * 2, EventType.Repaint);
            Handles.ArrowHandleCap(0, plane[1], Quaternion.LookRotation(-transform.forward, Vector3.up), handleSize * 2, EventType.Repaint);

            // Draw forward / backward arrows so people know they can drag
            if (editingEnabled)
            {
                Vector3 handlePosition = Handles.FreeMoveHandle(plane[1], Quaternion.identity, handleSize, Vector3.zero, Handles.SphereHandleCap);
                handlePosition = transform.InverseTransformPoint(handlePosition);
                zPosition      = handlePosition.z;
            }

            return(zPosition);
        }
Пример #3
0
        public void OnSceneGUI(SceneView sceneView)
        {
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                Ray        ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, 1000))
                {
                    _data.meshFilter         = GetMeshFilter(hit.transform);
                    _data.selectedObjectName = _data.meshFilter.name;
                    if (_data.meshFilter != null)
                    {
                        _data.isVertexSelected = true;
                        _vertexProcessor.ProcessSelected(hit.point);
                        return;
                    }
                    _data.isVertexSelected = false;
                }
                else
                {
                    _data.isVertexSelected   = false;
                    _data.selectedObjectName = VertexToolData.NO_OBJECT_SELECTED;
                    _data.meshFilter         = null;
                }
                _vertexProcessor.Clean();
            }

            if (_data.isVertexSelected)
            {
                var disPosition = _data.VertexData.Position + _data.meshFilter.transform.position;
                Handles.Label(disPosition, "Selected Vertex");
                Handles.color = _data.normalArrowColor;
                Handles.ArrowHandleCap(0, disPosition, Quaternion.LookRotation(_data.VertexData.Normal), _data.normalArrowSize, Event.current.type);
                Handles.color = _data.solidDiskColor;
                Handles.DrawSolidDisc(disPosition, _data.VertexData.Normal, _data.solidDiskSize);
                Handles.color = _data.selectedVertexColor;
                Handles.SphereHandleCap(0, disPosition, Quaternion.LookRotation(_data.VertexData.Normal), _data.selectedVertexSize, Event.current.type);
            }
        }
        static void DrawGizmosSelected(DecalProjector decalProjector, GizmoType gizmoType)
        {
            //draw them scale independent
            using (new Handles.DrawingScope(Color.white, Matrix4x4.TRS(decalProjector.transform.position, decalProjector.transform.rotation, Vector3.one)))
            {
                handle.center = decalProjector.offset;
                handle.size   = decalProjector.size;
                handle.DrawHull(editMode == k_EditShapePreservingUV || editMode == k_EditShapeWithoutPreservingUV);

                Quaternion arrowRotation  = Quaternion.LookRotation(Vector3.down, Vector3.right);
                float      arrowSize      = decalProjector.size.z * 0.25f;
                Vector3    pivot          = decalProjector.offset;
                Vector3    projectedPivot = pivot + decalProjector.size.z * 0.5f * Vector3.back;
                Handles.ArrowHandleCap(0, projectedPivot, Quaternion.identity, arrowSize, EventType.Repaint);

                //[TODO: add editable pivot. Uncomment this when ready]
                //draw pivot
                //Handles.SphereHandleCap(controlID, pivot, Quaternion.identity, 0.02f, EventType.Repaint);
                //Color c = Color.white;
                //c.a = 0.2f;
                //Handles.color = c;
                //Handles.DrawLine(projectedPivot, projectedPivot + decalProjector.m_Size.x * 0.5f * Vector3.right);
                //Handles.DrawLine(projectedPivot, projectedPivot + decalProjector.m_Size.y * 0.5f * Vector3.up);
                //Handles.DrawLine(projectedPivot, projectedPivot + decalProjector.m_Size.z * 0.5f * Vector3.forward);

                //draw UV
                Color face = Color.green;
                face.a = 0.1f;
                Vector2 size = new Vector2(
                    (decalProjector.uvScale.x > 100000 || decalProjector.uvScale.x < -100000 ? 0f : 1f / decalProjector.uvScale.x) * decalProjector.size.x,
                    (decalProjector.uvScale.x > 100000 || decalProjector.uvScale.x < -100000 ? 0f : 1f / decalProjector.uvScale.y) * decalProjector.size.y
                    );
                Vector2 start = (Vector2)projectedPivot - new Vector2(decalProjector.uvBias.x * size.x, decalProjector.uvBias.y * size.y);
                using (new Handles.DrawingScope(face, Matrix4x4.TRS(decalProjector.transform.position - decalProjector.transform.rotation * (decalProjector.size * 0.5f + decalProjector.offset.z * Vector3.back), decalProjector.transform.rotation, Vector3.one)))
                {
                    Handles.DrawSolidRectangleWithOutline(new Rect(start, size), face, Color.white);
                }
            }
        }
        public override void OnDrawSpacedGizmo(DirectionType direction)
        {
            direction.direction.Normalize();
            if (direction.direction == Vector3.zero)
            {
                direction.direction = Vector3.up;
            }


            Quaternion normalQuat = Quaternion.FromToRotation(Vector3.forward, direction.direction);

            Ray ray      = HandleUtility.GUIPointToWorldRay(Vector2.one * 200);
            var position = ray.origin + ray.direction * 2;

            Handles.ArrowHandleCap(0, position, normalQuat, HandleUtility.GetHandleSize(position) * 1, Event.current.type);

            if (m_Property.isEditable && NormalGizmo(position, ref direction.direction, true))
            {
                direction.direction.Normalize();
                m_Property.SetValue(direction);
            }
        }
    private void OnSceneGUI() //Monobehaviour editor function
    {
        MovementController mc = target as MovementController;

        Handles.ArrowHandleCap(0, mc.transform.position, mc.transform.rotation, mc.speed * .3f, EventType.Repaint); //Draws an arrow, at pos in direction of a given size. EventType.Repaint means it happens every frame

        if (mc.waypoints.Length > 1)
        {
            Color originalHandleColor = Handles.color;                                                      //Like Enabled, we must perserve the original handle color!
            Handles.color = Color.green;                                                                    //Set the color of all

            for (int i = 0; i < mc.waypoints.Length - 1; i++)                                               //Length minus one, because the last one doesnt have a "next"
            {
                if (mc.waypoints[i] && mc.waypoints[i + 1])
                {
                    Handles.DrawLine(mc.waypoints[i].position, mc.waypoints[i + 1].position);                   //Draw a line from i to i+1
                }
            }
            if (mc.waypoints[mc.waypoints.Length - 1] && mc.waypoints[0])
            {
                Handles.DrawLine(mc.waypoints[mc.waypoints.Length - 1].position, mc.waypoints[0].position); //Draw line from last element back to first element
            }
            Handles.color = originalHandleColor;                                                            //Reset the handle back to the original!
        }

        Handles.BeginGUI();                                                                                 //Begin 2D gui handle, specifies that this is on the scene
        for (int i = 0; i < mc.waypoints.Length; i++)
        {
            if (!mc.waypoints[i])
            {
                continue;
            }
            Vector2 guiPoint = HandleUtility.WorldToGUIPoint(mc.waypoints[i].position);                     //Convert a space in the world to the 2D GUI space
            Rect    rect     = new Rect(guiPoint.x - 50f, guiPoint.y - 40, 100, 20);                        //Create a scalable rect (In this case, hardcoded size)
            GUI.Box(rect, "Waypoint: " + i);                                                                //Create a GUI text box with the rect size
        }
        Handles.EndGUI();                                                                                   //Call end to GUI 2D Handle
    }
        public void OnSceneGUI()
        {
            if (Event.current.type == EventType.Repaint)
            {
                ObiRope rope = cursor.rope;

                if (rope == null)
                {
                    return;
                }

                ObiDistanceConstraintBatch distanceBatch = rope.DistanceConstraints.GetBatches()[0] as ObiDistanceConstraintBatch;

                Handles.color = Color.yellow;
                int     constraint = rope.GetConstraintIndexAtNormalizedCoordinate(cursor.normalizedCoord);
                Vector3 pos1       = rope.GetParticlePosition(distanceBatch.springIndices[constraint * 2]);
                Vector3 pos2       = rope.GetParticlePosition(distanceBatch.springIndices[constraint * 2 + 1]);

                if (cursor.direction)
                {
                    Handles.DrawWireDisc(pos1, pos2 - pos1, rope.thickness * 2);
                    Vector3 direction = pos2 - pos1;
                    if (direction != Vector3.zero)
                    {
                        Handles.ArrowHandleCap(0, pos1, Quaternion.LookRotation(direction), 0.2f, EventType.Repaint);
                    }
                }
                else
                {
                    Handles.DrawWireDisc(pos2, pos1 - pos2, rope.thickness * 2);
                    Vector3 direction = pos1 - pos2;
                    if (direction != Vector3.zero)
                    {
                        Handles.ArrowHandleCap(0, pos2, Quaternion.LookRotation(direction), 0.2f, EventType.Repaint);
                    }
                }
            }
        }
Пример #8
0
    private void drawArrowBetweenPoints(Vector3 point1, Vector3 point2)
    {
        // no need to draw arrows for tiny segments
        var distance = Vector3.Distance(point1, point2);

        if (distance < 40)
        {
            return;
        }

        // we dont want to be exactly in the middle so we offset the length of the arrow
        var lerpModifier = (distance * 0.5f - 25) / distance;

        Handles.color = _target.pathColor;

        // get the midpoint between the 2 points
        var dir  = Vector3.Lerp(point1, point2, lerpModifier);
        var quat = Quaternion.LookRotation(point2 - point1);

        Handles.ArrowHandleCap(0, dir, quat, 25, EventType.Repaint);

        Handles.color = Color.white;
    }
Пример #9
0
    protected void DrawBaseGizmos()
    {
        if (Application.isPlaying)
        {
            // Print the state
            var centered = new GUIStyle
            {
                alignment = TextAnchor.MiddleCenter,
                normal    = { textColor = Color.white },
                fontSize  = 14,
            };
            Handles.Label(transform.position + Vector3.up * 2.0f,
                          stateMachine?._curState.ToString() ?? "No Current State!", centered);

            // Visualize GoalPosition
            Handles.color = new Color(0.9f, 0.0f, 0.7f, 1.0f);
            Handles.ArrowHandleCap(0, goalPosition + (Vector3.up * 2.0f),
                                   Quaternion.LookRotation(Vector3.down, Vector3.forward),
                                   2.0f, EventType.Repaint);
        }

        stateMachine?.DrawGizmos();
    }
Пример #10
0
 static void DrawConnectionGizmo(SendGameCommand sgc, GizmoType gizmoType)
 {
     if (sgc.interactiveObject != null)
     {
         var start = sgc.transform.position;
         var end   = sgc.interactiveObject.transform.position;
         if (end == start)
         {
             end += sgc.interactiveObject.transform.forward * 1;
         }
         var dir = (end - start).normalized;
         if (Application.isPlaying)
         {
             Handles.color = Color.Lerp(Color.white, Color.green, sgc.Temperature);
         }
         else
         {
             Handles.color = new Color(1, 1, 1, 0.25f);
         }
         Handles.DrawDottedLine(start, end, 5);
         Handles.ArrowHandleCap(0, start + (dir * 2), Quaternion.LookRotation(dir), 1, EventType.Repaint);
     }
 }
Пример #11
0
        public override void OnModuleSceneDebugGUI()
        {
            var data = Target.SimulatedSpots;

            if (data)
            {
                Handles.matrix = Target.Generator.transform.localToWorldMatrix;
                DTGUI.PushColor(Color.red);
                for (int i = 0; i < data.Points.Length; i++)
                {
                    var Q = data.Points[i].Rotation * Quaternion.Euler(-90, 0, 0);
#if UNITY_5_6_OR_NEWER
                    Handles.ArrowHandleCap(0, data.Points[i].Position, Q, 2, EventType.Repaint);
#else
                    Handles.ArrowCap(0, data.Points[i].Position, Q, 2);
#endif

                    Handles.Label(data.Points[i].Position, data.Points[i].Index.ToString(), EditorStyles.boldLabel);
                }
                DTGUI.PopColor();
                Handles.matrix = Matrix4x4.identity;
            }
        }
Пример #12
0
		protected override void Editor_OnSceneGUI()
		{
			var path = moveAlongPath.path;
            if (path)
			{
				_fromLocation = path.GetLocationByLength(_from, _fromLocation.index);
				var position = path.GetPoint(_fromLocation);
				var direction = path.GetTangent(_fromLocation);
				float handleSize = HandleUtility.GetHandleSize(position);

				Handles.color = _beginColor;
				Handles.DrawWireDisc(position, direction, handleSize * _discSize);
				float arrowLength = handleSize * _arrowSize;

#if UNITY_5_6_OR_NEWER
				Handles.ArrowHandleCap(0, position, Quaternion.LookRotation(_from > _to ? -direction : direction), arrowLength, EventType.Repaint);
#else
				Handles.ArrowCap(0, position, Quaternion.LookRotation(_from > _to ? -direction : direction), arrowLength);
#endif

				_toLocation = path.GetLocationByLength(_to, _toLocation.index);
				position = path.GetPoint(_toLocation);
				direction = path.GetTangent(_toLocation);
				handleSize = HandleUtility.GetHandleSize(position);

				Handles.color = _endColor;
				Handles.DrawWireDisc(position, direction, handleSize * _discSize);
				arrowLength = handleSize * _arrowSize;
				if (_from > _to) direction  = - direction;

#if UNITY_5_6_OR_NEWER
				Handles.ArrowHandleCap(0, position - direction * arrowLength, Quaternion.LookRotation(direction), arrowLength, EventType.Repaint);
#else
				Handles.ArrowCap(0, position - direction * arrowLength, Quaternion.LookRotation(direction), arrowLength);
#endif
			}
		}
Пример #13
0
    private void OnDrawGizmosSelected()
    {
        using (new Handles.DrawingScope())
        {
            var homeColor   = new Color(1.0f, 0.7f, 0.0f, 1.0f);
            var evadeColor  = new Color(1.0f, 0.3f, 0.3f, 1.0f);
            var escapeColor = new Color(0.2f, 0.9f, 0.7f, 1.0f);

            if (!Application.isPlaying)
            {
                InitialPosition = transform.position;
            }

            // Visualize SpawnPatrolRadius
            Handles.color = homeColor;
            Handles.DrawWireDisc(InitialPosition, Vector3.up, SpawnPatrolRadius);

            // Visualize EvadePlayerRadius
            Handles.color = evadeColor;
            Handles.DrawWireDisc(transform.position, Vector3.up, EvadePlayerRadius);

            // Visualize EscapedPlayerRadius
            Handles.color = escapeColor;
            Handles.DrawWireDisc(transform.position, Vector3.up, EscapedPlayerRadius);

            if (Application.isPlaying)
            {
                // Visualize InitialPosition
                Handles.color = homeColor;
                Handles.ArrowHandleCap(0, InitialPosition + (Vector3.up * 1.0f),
                                       Quaternion.LookRotation(Vector3.down, Vector3.forward),
                                       1.0f, EventType.Repaint);
            }

            base.DrawBaseGizmos();
        }
    }
Пример #14
0
    void OnDrawGizmos()
    {
        if (DrawAxis)
        {
            Handles.color = DebugColor;

            Handles.ArrowHandleCap(0, transform.position, transform.rotation, AxisSize, EventType.Repaint);
        }

        Gizmos.color  = DebugColor;
        Gizmos.matrix = transform.localToWorldMatrix;

        if (_Collider && UseColliders)
        {
            UsesColliders(false);
            return;
        }

        switch (gizmoType)
        {
        case GizmoType.Cube:
            Gizmos.DrawWireCube(Vector3.zero, new Vector3(debugSize, debugSize, debugSize));
            Gizmos.color = new Color(DebugColor.r, DebugColor.g, DebugColor.b, alpha);
            Gizmos.DrawCube(Vector3.zero, Vector3.one * debugSize);
            break;

        case GizmoType.Sphere:

            Gizmos.DrawWireSphere(Vector3.zero, debugSize);
            Gizmos.color = new Color(DebugColor.r, DebugColor.g, DebugColor.b, alpha);
            Gizmos.DrawSphere(Vector3.zero, debugSize);
            break;

        default:
            break;
        }
    }
Пример #15
0
        public void DrawHierarchy()
        {
            foreach (var linearFeature in GetComponentsInChildren <Asset.World.LinearFeature>())
            {
                if (linearFeature == null)
                {
                    continue;
                }
                else if (linearFeature == this)
                {
                    Vector2 parentPosition = ParentPosition;
                    for (int i = 0; i < linearFeature.NumEdges; ++i)
                    {
                        if (linearFeature[i].PreviousEdge == null)
                        {
                            continue;
                        }

                        Vector2 p1    = parentPosition + linearFeature[i - 1].Position;
                        Vector2 p2    = parentPosition + linearFeature[i].Position;
                        float   scale = (Camera.current.transform.position - ToV3((p1 + p2) / 2.0f)).magnitude / 50.0f;
                        Handles.color = Color;
                        Handles.DrawLine(ToV3(p1), ToV3(p2));
                        Handles.ArrowHandleCap(
                            0,
                            ToV3((p1 + p2) / 2.0f),
                            Quaternion.LookRotation(ToV3(new Vector2((p2 - p1).y, -(p2 - p1).x), false)),
                            scale,
                            EventType.Repaint);
                    }
                }
                else
                {
                    linearFeature.DrawHierarchy();
                }
            }
        }
        /// <summary>
        /// Helper method to draw a line between the target object and the current position, also adds an arrow in the right direction
        /// </summary>
        /// <param name="currentPosition">The starting position for this line</param>
        /// <param name="obj">The object to target</param>
        /// <param name="color">The color of the line</param>
        /// <param name="ReverseArrowDirection">Point arrow from the currentLocation or towards it</param>
        private static void DrawEventLine(Vector3 currentPosition, Object obj, Color color,
                                          bool ReverseArrowDirection = true)
        {
            const float arrowSize = 5f;

            Handles.color = color;
            Vector3 targetPos = Vector3.zero;

            // Grab the target pos
            switch (obj)
            {
            case Component comp:
                targetPos = comp.transform.position;
                break;

            case GameObject gameObject:
                targetPos = gameObject.transform.position;
                break;
            }

            //Draw the regular line
            Handles.DrawLine(currentPosition, targetPos);

            //Draw the arrow
            if (ReverseArrowDirection)
            {
                Handles.ArrowHandleCap(0, currentPosition,
                                       Quaternion.LookRotation((targetPos - currentPosition).normalized, Vector3.up), arrowSize,
                                       EventType.Repaint);
            }
            else
            {
                Handles.ArrowHandleCap(0, targetPos,
                                       Quaternion.LookRotation((currentPosition - targetPos).normalized, Vector3.up), arrowSize,
                                       EventType.Repaint);
            }
        }
Пример #17
0
        public override void OnSceneGUI(Terrain terrain, IOnSceneGUI editContext)
        {
            commonUI.OnSceneGUI2D(terrain, editContext);

            // only do the rest if user mouse hits valid terrain or they are using the
            // brush parameter hotkeys to resize, etc
            if (!editContext.hitValidTerrain && !commonUI.isInUse)
            {
                return;
            }

            // update brush UI group
            commonUI.OnSceneGUI(terrain, editContext);

            // dont render preview if this isnt a repaint. losing performance if we do
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            using (IBrushRenderPreviewUnderCursor brushRender = new BrushRenderPreviewUIGroupUnderCursor(commonUI, "WindErosion", editContext.brushTexture))
            {
                if (brushRender.CalculateBrushTransform(out BrushTransform brushXform))
                {
                    Material     previewMaterial = Utility.GetDefaultPreviewMaterial();
                    PaintContext ctx             = brushRender.AcquireHeightmap(false, brushXform.GetBrushXYBounds(), 1);
                    var          texelCtx        = Utility.CollectTexelValidity(ctx.originTerrain, brushXform.GetBrushXYBounds());
                    Utility.SetupMaterialForPaintingWithTexelValidityContext(ctx, texelCtx, brushXform, previewMaterial);
                    TerrainPaintUtilityEditor.DrawBrushPreview(ctx, TerrainBrushPreviewMode.SourceRenderTexture,
                                                               editContext.brushTexture, brushXform, previewMaterial, 0);
                    texelCtx.Cleanup();

                    Quaternion windRot = Quaternion.AngleAxis(commonUI.brushRotation, new Vector3(0.0f, 1.0f, 0.0f));
                    Handles.ArrowHandleCap(0, commonUI.raycastHitUnderCursor.point, windRot, 0.5f * commonUI.brushSize, EventType.Repaint);
                }
            }
        }
Пример #18
0
        public override void OnDrawSpacedGizmo(Plane plane)
        {
            Vector3 normal = plane.normal.normalized;

            if (normal == Vector3.zero)
            {
                normal = Vector3.up;
            }

            var normalQuat = Quaternion.FromToRotation(Vector3.forward, normal);

            float size = 10;

            Vector3[] points = new Vector3[]
            {
                new Vector3(size, size, 0),
                new Vector3(size, -size, 0),
                new Vector3(-size, -size, 0),
                new Vector3(-size, size, 0),
                new Vector3(size, size, 0),
            };

            using (new Handles.DrawingScope(Handles.matrix * Matrix4x4.Translate(plane.position) * Matrix4x4.Rotate(normalQuat)))
            {
                Handles.DrawPolyLine(points);
            }
            Handles.ArrowHandleCap(0, plane.position, normalQuat, 5, Event.current.type);

            PositionGizmo(plane.position, Vector3.zero, m_PositionProperty, false);

            if (m_NormalProperty.isEditable && NormalGizmo(plane.position, ref normal, false))
            {
                normal.Normalize();
                m_NormalProperty.SetValue(normal);
            }
        }
Пример #19
0
    void OnSceneGUI()
    {
        CarWheel wheel = (CarWheel)this.target;

        Transform wheelModelTransform = wheel.transform;

        if (wheel.wheelModel != null)
        {
            wheelModelTransform = wheel.wheelModel;
        }

        Handles.color = new Color(0f, 1f, 0f, 0.4f);

        Vector3 topSuspensionPosition = wheel.transform.position + Vector3.up * wheel.suspensionHeight;

        Handles.DrawDottedLine(wheel.transform.position, topSuspensionPosition, 2f);
        Handles.DrawWireArc(topSuspensionPosition, wheelModelTransform.forward, wheel.transform.up, 360f, wheel.wheelRadius);

        Handles.color = Color.red;

        Handles.DrawWireArc(wheel.transform.position, wheelModelTransform.forward, wheel.transform.up, 360f, wheel.wheelRadius);
        if (wheel.rotate)
        {
            Vector3 arrowDirection = Vector3.Cross(wheelModelTransform.forward, wheel.transform.up);
            Handles.ArrowHandleCap(0, wheel.transform.position + wheel.transform.up * wheel.wheelRadius, Quaternion.LookRotation(arrowDirection), 0.5f, EventType.Repaint);
        }
        if (wheel.turnAngle != 0f)
        {
            Handles.color = new Color(0f, 0f, 1f, 0.5f);
            Quaternion turnQuaternion = Quaternion.AngleAxis(wheel.turnAngle, wheel.transform.up);
            Handles.DrawWireArc(wheel.transform.position, turnQuaternion * wheelModelTransform.forward, wheel.transform.up, 180f, wheel.wheelRadius);

            turnQuaternion = Quaternion.AngleAxis(-wheel.turnAngle, wheel.transform.up);
            Handles.DrawWireArc(wheel.transform.position, turnQuaternion * wheelModelTransform.forward, wheel.transform.up, 180f, wheel.wheelRadius);
        }
    }
Пример #20
0
    public void OnSceneGUI()
    {
        APJumper oJumper = (APJumper)target;

        if (oJumper.enabled)
        {
            // draw direction arrow
            Color color = Color.cyan;
            color.a       = 0.5f;
            Handles.color = color;

            float   fAngle       = oJumper.m_mode == APJumper.EImpulseMode.Impulse ? -Mathf.Deg2Rad * oJumper.m_impulseDirection : -Mathf.Deg2Rad * 90f;
            Vector2 v2ImpulseDir = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));

            if (oJumper.m_mode == APJumper.EImpulseMode.Impulse)
            {
                v2ImpulseDir = oJumper.transform.TransformDirection(v2ImpulseDir);
            }

            //Vector3 dir = new Vector3(-oJumper.m_impulseDirection, 90f, 0f);
            Quaternion rot = Quaternion.LookRotation(v2ImpulseDir);
            Handles.ArrowHandleCap(0, oJumper.transform.position, rot, 0.5f, EventType.Repaint);
        }
    }
        protected override void DrawLocalGizmos(ref Matrix4x4 matrix)
        {
            base.DrawLocalGizmos(ref matrix);

            if (_previewRotation)
            {
                ValidateSamples();

                int        segmentCount = this.segmentCount;
                Location   loc;
                Quaternion rot;
                Vector3    pos;

                Handles.color = previewRotationColor;

                for (loc.index = 0; loc.index < segmentCount; loc.index++)
                {
                    int count = Mathf.CeilToInt(node(loc.index).length);

                    for (int t = 0; t <= count; t++)
                    {
                        if (t == count && loc.index != segmentCount - 1)
                        {
                            continue;
                        }

                        loc.time = (float)t / count;
                        rot      = GetRotation(loc, Space.Self);
                        pos      = GetPoint(loc, Space.Self);

                        Handles.ArrowHandleCap(0, pos, rot, 0.75f, EventType.Repaint);
                        HandlesKit.DrawAALine(pos, pos + rot * Vector3.up);
                    }
                }
            }
        }
Пример #22
0
        static void DrawSwing1(CharacterJoint joint, Vector3 position, Vector3 direction, Vector3 axisDir, Vector3 swingAxisDir, float size)
        {
            Handles.color = new Color(0.0f, 0.7f, 0.0f, 1f);
            Handles.ArrowHandleCap(0, position, Quaternion.LookRotation(swingAxisDir), size * 1.1f, EventType.Repaint);

            Handles.color = new Color(0.0f, 0.7f, 0.0f, 1f);
            Vector3 swing1Noraml = Vector3.Cross(axisDir, direction);
            var     swing1Limit  = joint.swing1Limit;
            float   newLimit     = swing1Limit.limit;

            newLimit = ProcessLimit(position, swing1Noraml, direction, size, newLimit);
            newLimit = -ProcessLimit(position, swing1Noraml, direction, size, -newLimit);

            if (newLimit < 10f)
            {
                newLimit = 0f;
            }

            if (swing1Limit.limit != newLimit)
            {
                swing1Limit.limit = newLimit;
                joint.swing1Limit = swing1Limit;
            }
        }
Пример #23
0
    void DrawUnselectedKnots()
    {
        for (int i = 0; i < spline.KnotCount; i++)
        {
            if (selectedKnots.Contains(i))
            {
                continue;
            }
            Bezier3DSpline.Knot knot = spline.GetKnot(i);

            Vector3 knotWorldPos = spline.transform.TransformPoint(knot.position);
            if (knot.orientation.HasValue)
            {
                Handles.color = Handles.yAxisColor;
                Quaternion rot = spline.transform.rotation * knot.orientation.Value;
                Handles.ArrowHandleCap(0, knotWorldPos, rot * Quaternion.AngleAxis(90, Vector3.left), 0.15f, EventType.Repaint);
            }
            Handles.color = Color.white;
            if (Handles.Button(knotWorldPos, Camera.current.transform.rotation, HandleUtility.GetHandleSize(knotWorldPos) * handleSize, HandleUtility.GetHandleSize(knotWorldPos) * handleSize, Handles.CircleHandleCap))
            {
                SelectKnot(i, Event.current.control);
            }
        }
    }
Пример #24
0
        protected override void InternalOnSceneGUI()
        {
            var cursor = Cursor;

            if (cursor == null)
            {
                return;
            }

            var position = cursor.CalculatePosition();

            var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get <float>(cursor, "handlesScale"));

            BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(cursor, "handlesColor"), () =>
            {
#if UNITY_5_6_OR_NEWER
                Handles.ArrowHandleCap(0, position + Vector3.up * handleSize * 1.2f, Quaternion.LookRotation(Vector3.down), handleSize, EventType.Repaint);
                Handles.SphereHandleCap(0, position, Quaternion.LookRotation(Vector3.down), handleSize * .15f, EventType.Repaint);
#else
                Handles.ArrowCap(0, position + Vector3.up * handleSize * 1.2f, Quaternion.LookRotation(Vector3.down), handleSize);
                Handles.SphereCap(0, position, Quaternion.LookRotation(Vector3.down), handleSize * .15f);
#endif
            });
        }
    public void OnSceneGUI()
    {
        if (animator.showScenePreview)
        {
            float handleSize = HandleUtility.GetHandleSize(previewCamPos * 0.5f);
            Handles.color = (Color.white - bezier.lineColour) + new Color(0, 0, 0, 1);
            Handles.DrawLine(previewCamPos, previewCamPos + Vector3.up * 0.5f);
            Handles.DrawLine(previewCamPos, previewCamPos + Vector3.down * 0.5f);
            Handles.DrawLine(previewCamPos, previewCamPos + Vector3.left * 0.5f);
            Handles.DrawLine(previewCamPos, previewCamPos + Vector3.right * 0.5f);
            Handles.DrawLine(previewCamPos, previewCamPos + Vector3.forward * 0.5f);
            Handles.DrawLine(previewCamPos, previewCamPos + Vector3.back * 0.5f);

            Handles.ArrowHandleCap(0, previewCamPos, previewCamRot, handleSize, EventType.Repaint);
            Handles.Label(previewCamPos, "Preview\nCamera\nPosition");
        }

        if (GUI.changed)
        {
            bezier.RecalculateStoredValues();
            EditorUtility.SetDirty(animator);
            EditorUtility.SetDirty(bezier);
        }
    }
Пример #26
0
    // void SnapToGrid(){

    //  float yPos = Mathf.Round( this.transform.localPosition.y - gPosition.z );
    //  float xPos = Mathf.Round( this.transform.localPosition.x /4 ) * 4;
    //  if( yPos % 2 == 0 ){
    //      /// Evens
    //      if( xPos % 2 != 0 ){
    //          if( this.transform.localPosition.x > xPos ){
    //              xPos += 1;
    //          } else {
    //              xPos -= 1;
    //          }
    //      }
    //  } else {
    //      /// Odds
    //      if( xPos % 2 == 0 ){
    //          if( this.transform.localPosition.x > xPos ){
    //              xPos += 2;
    //          } else {
    //              xPos -= 2;
    //          }
    //      }
    //  }
    //  // this.transform.localPosition = new Vector3( xPos, yPos + gPosition.z,  this.transform.localPosition.z );
    //  this.transform.localPosition = new Vector3( xPos, yPos + gPosition.z,  gPosition.z * -0.001f );

    //  VectorT gp = VectorT.WorldToGrid( this.transform.localPosition );
    //  gPosition.x = gp.x;
    //  gPosition.y = gp.y;

    //  sr.sortingOrder = (int)Mathf.Round( -this.transform.localPosition.y + gPosition.z );

    // }



    void OnDrawGizmos()
    {
        if (!Selection.Contains(this.gameObject) || TileEditor.editing == false)
        {
            return;
        }

        // if( !( Selection.Contains(this.gameObject) && Tools.current == Tool.Move ) ){
        //  return;
        // }

        Gizmos.color = new Color(0.2f, 0.5f, 1, 0.15f);

        int drawRange = 2;

        VectorT basePos = gPosition;

        basePos.z = 0;

        for (int u = -drawRange * 2; u < drawRange * 2; u++)
        {
            for (int v = -drawRange * 2; v < drawRange * 2; v++)
            {
                Gizmos.DrawLine(new VectorT(u + basePos.x, v + basePos.y).ToWorld(), new VectorT(u + basePos.x, -v + basePos.y).ToWorld());
                Gizmos.DrawLine(new VectorT(u + basePos.x, v + basePos.y).ToWorld(), new VectorT(-u + basePos.x, v + basePos.y).ToWorld());
            }
        }

        // // Gizmos.Draw
        Handles.color = Handles.xAxisColor;
        Handles.ArrowHandleCap(0, basePos.ToWorld(), Quaternion.Euler(27, 90, 0), 2, EventType.Repaint);
        Handles.color = Handles.yAxisColor;
        Handles.ArrowHandleCap(0, basePos.ToWorld(), Quaternion.Euler(27, -90, 0), 2, EventType.Repaint);
        Handles.color = Handles.zAxisColor;
        Handles.ArrowHandleCap(0, basePos.ToWorld(), Quaternion.Euler(-90, 0, 0), 2, EventType.Repaint);
    }
Пример #27
0
    private void DrawVisualDebug(int i, Vector3 next)
    {
        //draw arrow
        if (platform.Points.Count > 2)
        {
            Handles.color = Color.green;
            Vector3 middle = Vector3.Lerp(platform.Points[i], next, 0.5f);
            Vector3 dir    = next - platform.Points[i];
            int     id     = GUIUtility.GetControlID(FocusType.Passive);
            float   size   = HandleUtility.GetHandleSize(middle);//constant size
            Handles.ArrowHandleCap(id + i * 10, middle - dir.normalized, Quaternion.LookRotation(dir), 2, EventType.Repaint);
        }

        //draw dotted line from point to point
        Handles.color = i == lineIndex ? Color.red : Color.white;
        Handles.DrawDottedLine(platform.Points[i], next, 5);

        //draw yellow/white transparent disk
        var debugColor = i == pointIndex ? Color.yellow : Color.white;

        debugColor.a  = 0.1f;
        Handles.color = debugColor;
        Handles.DrawSolidDisc(platform.Points[i], Vector3.up, radius);
    }
Пример #28
0
        protected virtual void OnSceneGUI()
        {
            if (DrawAttachPoints)
            {
                Handles.color = Color.Lerp(Color.clear, Color.red, 0.5f);
                float scale = externalPlot.ContentScale * 0.01f;

                ToolTipUtility.GetAttachPointPositions(ref localAttachPointPositions, externalPlot.LocalContentSize);
                foreach (Vector3 attachPoint in localAttachPointPositions)
                {
                    Handles.SphereHandleCap(0, externalPlot.ContentParentTransform.TransformPoint(attachPoint), Quaternion.identity, scale, EventType.Repaint);
                }
            }

            if (DrawHandles)
            {
                ExternalPlot externalPlot = (ExternalPlot)target;
                float        handleSize   = 0;
                float        arrowSize    = 0;

                BaseMixedRealityLineDataProvider line = externalPlot.GetComponent <BaseMixedRealityLineDataProvider>();
                if (line == null)
                {
                    Handles.color = Color.white;
                    Handles.DrawDottedLine(externalPlot.AnchorPosition, externalPlot.AttachPointPosition, 5f);
                }

                EditorGUI.BeginChangeCheck();

                Handles.color = Color.cyan;
                handleSize    = HandleUtility.GetHandleSize(externalPlot.PivotPosition) * handleSizeMultiplier;
                arrowSize     = handleSize * 2;
                Vector3 newPivotPosition = Handles.FreeMoveHandle(externalPlot.PivotPosition, Quaternion.identity, handleSize, Vector3.zero, Handles.SphereHandleCap);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                Handles.color = Color.white;
                Handles.Label(newPivotPosition + (Vector3.up * arrowSize), "Pivot", EditorStyles.whiteLabel);

                Handles.color = Color.cyan;
                handleSize    = HandleUtility.GetHandleSize(externalPlot.AnchorPosition) * handleSizeMultiplier;
                arrowSize     = handleSize * 2;
                Vector3 newAnchorPosition = Handles.FreeMoveHandle(externalPlot.AnchorPosition, Quaternion.identity, HandleUtility.GetHandleSize(externalPlot.AnchorPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                Handles.color = Color.white;
                Handles.Label(newAnchorPosition + (Vector3.up * arrowSize), "Anchor", EditorStyles.whiteLabel);

                if (EditorGUI.EndChangeCheck())
                {
                    if (newAnchorPosition != externalPlot.AnchorPosition)
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot.Anchor.transform, "Moved Anchor");
                        externalPlot.Anchor.transform.position = newAnchorPosition;
                    }

                    if (newPivotPosition != externalPlot.PivotPosition)
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot.Pivot.transform, "Moved Pivot");
                        externalPlot.Pivot.transform.position = newPivotPosition;
                    }
                }

                if (EditAttachPoint)
                {
                    EditorGUI.BeginChangeCheck();

                    Handles.color = Color.cyan;
                    handleSize    = HandleUtility.GetHandleSize(externalPlot.AttachPointPosition) * handleSizeMultiplier;
                    arrowSize     = handleSize * 2;
                    Vector3 newAttachPointPosition = Handles.FreeMoveHandle(externalPlot.AttachPointPosition, Quaternion.identity, HandleUtility.GetHandleSize(externalPlot.AttachPointPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                    Handles.color = Color.white;
                    Handles.Label(newAttachPointPosition + (Vector3.up * arrowSize), "Attach Point", EditorStyles.whiteLabel);

                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot, "Moved Attach Point");
                        Undo.RegisterCompleteObjectUndo(externalPlot.Anchor.transform, "Moved Attach Point");
                        externalPlot.AttachPointPosition = newAttachPointPosition;
                    }
                }
            }
        }
Пример #29
0
    static void OnGizmo(MapSystemComponent manager, GizmoType type)
    {
        float handleSize = HandleUtility.GetHandleSize(Vector3.zero);
        Color gradient   = Prefs.circleGradient.Evaluate(MapSystem.currentAngle / MapSystem.MaxAngle);


        //绘制低半部分指示圆环
        float alpha = MapSystem.currentAngle % MapSystem.AnglePerGroup;
        float beta  = MapSystem.AnglePerGroup / 2 - alpha;

        float   pAngle0 = MapSystem.currentGroupIndex % MapSystem.GroupCountPerCircle * MapSystem.AnglePerGroup * angleToPiRate;
        Vector3 p0      = new Vector3(Mathf.Cos(pAngle0) * Prefs.r0, -Prefs.circleVerticalCurve.Evaluate(Mathf.Abs(beta)) * Prefs.circleVerticleRate * alpha * angleToPiRate, Mathf.Sin(pAngle0) * Prefs.r0);

        float   alphai = alpha + MapSystem.AnglePerGroup;
        float   phi = (MapSystem.AnglePerGroup / 2 + alpha);
        float   pAngleii = pAngle0;
        float   pAnglei = pAngle0 - MapSystem.AnglePerGroup * angleToPiRate;
        Vector3 ppi = p0, ppit;
        Vector3 pi, pit;

        while (alphai <= 180)
        {
            ppit = new Vector3(Mathf.Cos(pAngleii - bezierAngle) * Prefs.r0 * bezierRadius, ppi.y - Prefs.circleVerticalCurve.Evaluate(phi) * Prefs.circleVerticleRate * bezierAngle, Mathf.Sin(pAngleii - bezierAngle) * Prefs.r0 * bezierRadius);
            pi   = new Vector3(Mathf.Cos(pAnglei) * Prefs.r0, ppi.y - Prefs.circleVerticalCurve.Evaluate(phi) * Prefs.circleVerticleRate * MapSystem.AnglePerGroup * angleToPiRate, Mathf.Sin(pAnglei) * Prefs.r0);
            pit  = new Vector3(Mathf.Cos(pAnglei + bezierAngle) * Prefs.r0 * bezierRadius, pi.y + Prefs.circleVerticalCurve.Evaluate(phi) * Prefs.circleVerticleRate * bezierAngle, Mathf.Sin(pAnglei + bezierAngle) * Prefs.r0 * bezierRadius);


            Handles.DrawBezier(ppi, pi, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);
            Handles.DrawBezier(ppi * Prefs.r2, pi * Prefs.r2, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);
            Handles.DrawBezier(ppi * Prefs.r3, pi * Prefs.r3, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);

            alphai  += MapSystem.AnglePerGroup;
            phi     += MapSystem.AnglePerGroup;
            pAngleii = pAnglei;
            pAnglei -= MapSystem.AnglePerGroup * angleToPiRate;
            ppi      = pi;
        }

        pAnglei = (alpha - 180 + MapSystem.currentGroupIndex * MapSystem.AnglePerGroup) * angleToPiRate;

        float newAngle        = (180 - alpha) % MapSystem.AnglePerGroup;
        float newBezierFactor = bezierFactor * (newAngle) / MapSystem.AnglePerGroup;
        float newBezierRadius = Mathf.Sqrt(newBezierFactor * newBezierFactor + 1);
        float newBezierAngle  = Mathf.Atan(newBezierFactor);

        ppit = new Vector3(Mathf.Cos(pAngleii - newBezierAngle) * Prefs.r0 * newBezierRadius, ppi.y - Prefs.circleVerticalCurve.Evaluate(phi) * Prefs.circleVerticleRate * newBezierAngle, Mathf.Sin(pAngleii - newBezierAngle) * Prefs.r0 * newBezierRadius);
        pi   = new Vector3(Mathf.Cos(pAnglei) * Prefs.r0, ppi.y - Prefs.circleVerticalCurve.Evaluate(phi) * Prefs.circleVerticleRate * newAngle * angleToPiRate, Mathf.Sin(pAnglei) * Prefs.r0);
        pit  = new Vector3(Mathf.Cos(pAnglei + newBezierAngle) * Prefs.r0 * newBezierRadius, pi.y + Prefs.circleVerticalCurve.Evaluate(phi) * Prefs.circleVerticleRate * newBezierAngle, Mathf.Sin(pAnglei + newBezierAngle) * Prefs.r0 * newBezierRadius);

        Handles.DrawBezier(ppi, pi, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);
        Handles.DrawBezier(ppi * Prefs.r2, pi * Prefs.r2, ppit * Mathf.Lerp(Prefs.r2, 1, newAngle / MapSystem.AnglePerGroup), pit * Mathf.Lerp(Prefs.r2, 1, newAngle / MapSystem.AnglePerGroup), Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);
        Handles.DrawBezier(ppi * Prefs.r3, pi * Prefs.r3, ppit * Mathf.Lerp(Prefs.r3, 1, newAngle / MapSystem.AnglePerGroup), pit * Mathf.Lerp(Prefs.r3, 1, newAngle / MapSystem.AnglePerGroup), Color.Lerp(Prefs.circleGradient.Evaluate(MapSystem.currentAngle / MapSystem.MaxAngle), Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);



        //绘制可见范围
        if (MapManager.Active)
        {
            Handles.color = Prefs.arcColor;
            Handles.DrawSolidArc(Vector3.zero, Vector3.up, Quaternion.Euler(-Vector3.up * (MapSystem.currentAngle - MapSystem.AnglePerGroup)) * Vector3.right, 360 - 2 * MapSystem.AnglePerGroup, Prefs.arcRadius * handleSize);
            Handles.color = Color.white;
        }



        //绘制高半部分指示圆环
        alphai   = MapSystem.AnglePerGroup - alpha;
        phi      = beta;
        pAngleii = pAngle0;
        pAnglei  = pAngle0 + MapSystem.AnglePerGroup * angleToPiRate;

        ppi = p0;
        while (alphai <= 180)
        {
            ppit = new Vector3(Mathf.Cos(pAngleii + bezierAngle) * Prefs.r0 * bezierRadius, ppi.y + Prefs.circleVerticalCurve.Evaluate(Mathf.Abs(phi)) * Prefs.circleVerticleRate * bezierAngle, Mathf.Sin(pAngleii + bezierAngle) * Prefs.r0 * bezierRadius);
            pi   = new Vector3(Mathf.Cos(pAnglei) * Prefs.r0, ppi.y + Prefs.circleVerticalCurve.Evaluate(Mathf.Abs(phi)) * Prefs.circleVerticleRate * MapSystem.AnglePerGroup * angleToPiRate, Mathf.Sin(pAnglei) * Prefs.r0);
            pit  = new Vector3(Mathf.Cos(pAnglei - bezierAngle) * Prefs.r0 * bezierRadius, pi.y - Prefs.circleVerticalCurve.Evaluate(Mathf.Abs(phi)) * Prefs.circleVerticleRate * bezierAngle, Mathf.Sin(pAnglei - bezierAngle) * Prefs.r0 * bezierRadius);

            Handles.DrawBezier(ppi, pi, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(Mathf.Abs(phi))), null, Prefs.circleWidth);
            Handles.DrawBezier(ppi * Prefs.r2, pi * Prefs.r2, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(Mathf.Abs(phi))), null, Prefs.circleWidth);
            Handles.DrawBezier(ppi * Prefs.r3, pi * Prefs.r3, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(Mathf.Abs(phi))), null, Prefs.circleWidth);

            alphai  += MapSystem.AnglePerGroup;
            phi     += MapSystem.AnglePerGroup;
            pAngleii = pAnglei;
            pAnglei += MapSystem.AnglePerGroup * angleToPiRate;
            ppi      = pi;
        }

        pAnglei = (alpha + 180 + MapSystem.currentGroupIndex * MapSystem.AnglePerGroup) * angleToPiRate;

        newAngle        = (180 + alpha) % MapSystem.AnglePerGroup;
        newBezierFactor = bezierFactor * (newAngle) / MapSystem.AnglePerGroup;
        newBezierRadius = Mathf.Sqrt(newBezierFactor * newBezierFactor + 1);
        newBezierAngle  = Mathf.Atan(newBezierFactor);

        ppit = new Vector3(Mathf.Cos(pAngleii + newBezierAngle) * Prefs.r0 * newBezierRadius, ppi.y + Prefs.circleVerticalCurve.Evaluate(Mathf.Abs(phi)) * Prefs.circleVerticleRate * newBezierAngle, Mathf.Sin(pAngleii + newBezierAngle) * Prefs.r0 * newBezierRadius);
        pi   = new Vector3(Mathf.Cos(pAnglei) * Prefs.r0, ppi.y + Prefs.circleVerticalCurve.Evaluate(Mathf.Abs(phi)) * Prefs.circleVerticleRate * newAngle * angleToPiRate, Mathf.Sin(pAnglei) * Prefs.r0);
        pit  = new Vector3(Mathf.Cos(pAnglei - newBezierAngle) * Prefs.r0 * newBezierRadius, pi.y - Prefs.circleVerticalCurve.Evaluate(Mathf.Abs(phi)) * Prefs.circleVerticleRate * newBezierAngle, Mathf.Sin(pAnglei - newBezierAngle) * Prefs.r0 * newBezierRadius);

        Handles.DrawBezier(ppi, pi, ppit, pit, Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);
        Handles.DrawBezier(ppi * Prefs.r2, pi * Prefs.r2, ppit * Mathf.Lerp(Prefs.r2, 1, newAngle / MapSystem.AnglePerGroup), pit * Mathf.Lerp(Prefs.r2, 1, newAngle / MapSystem.AnglePerGroup), Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);
        Handles.DrawBezier(ppi * Prefs.r3, pi * Prefs.r3, ppit * Mathf.Lerp(Prefs.r3, 1, newAngle / MapSystem.AnglePerGroup), pit * Mathf.Lerp(Prefs.r3, 1, newAngle / MapSystem.AnglePerGroup), Color.Lerp(gradient, Prefs.backColor, Prefs.circleColorCurve.Evaluate(phi)), null, Prefs.circleWidth);


        //绘制组边线(只对应每层三组的情况)
        int t = MapSystem.currentGroupIndex % 3;

        outline0.target = t != 1 ? 1 : 0;
        outline1.target = t != 2 ? 1 : 0;
        outline2.target = t != 0 ? 1 : 0;

        Quaternion yRot = Quaternion.Euler(0, -120, 0);
        Vector3    axis = Vector3.right;

        Handles.color = Color.Lerp(Color.clear, gradient, outline0.value);
        Handles.DrawAAPolyLine(Prefs.outlineWidth, axis * Prefs.r0 * Prefs.r3 * Prefs.outlineBegin, axis * Prefs.r0 * Prefs.r3 * Prefs.outlineEnd * handleSize);

        axis          = yRot * axis;
        Handles.color = Color.Lerp(Color.clear, gradient, outline1.value);
        Handles.DrawAAPolyLine(Prefs.outlineWidth, axis * Prefs.r0 * Prefs.r3 * Prefs.outlineBegin, axis * Prefs.r0 * Prefs.r3 * Prefs.outlineEnd * handleSize);

        axis          = yRot * axis;
        Handles.color = Color.Lerp(Color.clear, gradient, outline2.value);
        Handles.DrawAAPolyLine(Prefs.outlineWidth, axis * Prefs.r0 * Prefs.r3 * Prefs.outlineBegin, axis * Prefs.r0 * Prefs.r3 * Prefs.outlineEnd * handleSize);

        Handles.color = Color.white;


        //绘制中央信息
        Handles.Label(Vector3.zero, MapSystem.CurrentCircle.ToString(), Prefs.circleIndexStyle);
        Handles.Label(Vector3.zero * 1f, MapSystem.currentAngle.ToString(), Prefs.angleStyle);



        //绘制小人

        float rr2 = Prefs.r0 * Mathf.Lerp(1, Prefs.r2, Mathf.Abs(beta) * 2f / MapSystem.AnglePerGroup);

        Handles.color = Prefs.arrowColor;
        Handles.ArrowHandleCap(0, new Vector3(Mathf.Cos(MapSystem.currentAngle * angleToPiRate), 0, Mathf.Sin(MapSystem.currentAngle * angleToPiRate)) * rr2, Quaternion.Euler(-90, 0, 0), Prefs.arrowSize, EventType.Repaint);
        Handles.SphereHandleCap(0, new Vector3(Mathf.Cos(MapSystem.currentAngle * angleToPiRate) * rr2, Prefs.headHeight * Prefs.arrowSize, Mathf.Sin(MapSystem.currentAngle * angleToPiRate) * rr2), Quaternion.identity, Prefs.headSize * Prefs.arrowSize, EventType.Repaint);
        Handles.color = Color.white;
    }
Пример #30
0
        public override void Draw(SVArgs args, ref object value)
        {
            Ray?ray = value as Ray?;

            Handles.ArrowHandleCap(0, ray.Value.origin, Quaternion.LookRotation(ray.Value.direction), 1f, EventType.Repaint);
        }