예제 #1
0
    private void ShowPoint(float x, float y)
    {
        Vector2 square = new Vector2(x, y);
        // Vector2 circle = square.normalized;
        Vector2 circle;

        circle.x = square.x * Mathf.Sqrt(1f - square.y * square.y * 0.5f);
        circle.y = square.y * Mathf.Sqrt(1f - square.x * square.x * 0.5f);

        Gizmos.color = Color.black;
        Gizmos.DrawSphere(square, 0.025f);

        Gizmos.color = Color.white;
        Gizmos.DrawSphere(circle, 0.025f);

        Gizmos.color = Color.yellow;
        Gizmos.DrawLine(square, circle);

        Gizmos.color = Color.gray;
        Gizmos.DrawLine(circle, Vector2.zero);
    }
예제 #2
0
    //para desenhar icones dos inimigos.
    private void OnDrawGizmos()
    {
        //pega a posicao do primeiro waypoint (Waypoint1)..
        Vector3 startPosition = pathHolder.GetChild(0).position;
        // e coloca na 1a posicao do loop
        Vector3 previousPOsition = startPosition;

        foreach (Transform waypoint in pathHolder)
        {
            //para eles aparecerem na camera vai em togglegizmoson no inspector.
            Gizmos.DrawSphere(waypoint.position, 0.3f);
            //desenha uma linha da posicao anterior ate a posicao do waypoint atual.
            Gizmos.DrawLine(previousPOsition, waypoint.position);
            //atualiza posicao anterior para o proximo desenho
            previousPOsition = waypoint.position;
        }
        Gizmos.DrawLine(previousPOsition, startPosition);

        Gizmos.color = Color.red;
        Gizmos.DrawRay(transform.position, transform.forward * viewDistance);
    }
예제 #3
0
        public static void GizmosDrawPlane(Vector3 normal, Vector3 position, Color color, float size = 1f)
        {
            var v3      = Vector3.Cross(normal, Mathf.Abs(Vector3.Dot(normal, Vector3.forward)) < 0.999f ? Vector3.forward : Vector3.up).normalized *size;
            var corner0 = position + v3;
            var corner2 = position - v3;

            v3 = Quaternion.AngleAxis(90f, normal) * v3;
            var corner1 = position + v3;
            var corner3 = position - v3;

            Gizmos.matrix = Matrix4x4.identity;
            Gizmos.color  = color;
            Gizmos.DrawLine(corner0, corner2);
            Gizmos.DrawLine(corner1, corner3);
            Gizmos.DrawLine(corner0, corner1);
            Gizmos.DrawLine(corner1, corner2);
            Gizmos.DrawLine(corner2, corner3);
            Gizmos.DrawLine(corner3, corner0);
            //Gizmos.color = Color.red;
            //Gizmos.DrawRay(position, normal);
        }
 public void OnDrawGizmos()
 {
     if (showHandles)
     {
         if (nodeObjectVerts != null)
         {
             if (nodeObjectVerts.Length > 0)
             {
                 int n = nodeObjectVerts.Length;
                 for (int i = 0; i < n; i++)
                 {
                     // Handles...
                     Gizmos.color = Color.white;
                     Gizmos.DrawLine(transform.TransformPoint(nodeObjectVerts[i] + new Vector3(-0.5f, 0, 0)), transform.TransformPoint(nodeObjectVerts[i] + new Vector3(0.5f, 0, 0)));
                     Gizmos.DrawLine(transform.TransformPoint(nodeObjectVerts[i] + new Vector3(0, -0.5f, 0)), transform.TransformPoint(nodeObjectVerts[i] + new Vector3(0, 0.5f, 0)));
                     Gizmos.DrawLine(transform.TransformPoint(nodeObjectVerts[i] + new Vector3(0, 0, -0.5f)), transform.TransformPoint(nodeObjectVerts[i] + new Vector3(0, 0, 0.5f)));
                 }
             }
         }
     }
 }
예제 #5
0
    private void OnDrawGizmos()
    {
        if (mouseRayGizmo)
        {
            if (camHit.point != null)
            {
                Gizmos.color = Color.red;
                Gizmos.DrawSphere(Camera.main.transform.localPosition, 0.5f);
                Gizmos.DrawLine(Camera.main.transform.position, camHit.point);
                Gizmos.DrawSphere(camHit.point, 0.5f);
            }
        }

        Gizmos.color = Color.green;
        if (!shoutArea)
        {
            return;
        }
        Gizmos.matrix = Matrix4x4.TRS(shoutArea.transform.position, transform.rotation, Vector3.one);
        Gizmos.DrawWireCube(Vector3.zero, transform.localScale * 8);
    }
예제 #6
0
    private void OnDrawGizmos()
    {
        if (handRef != null)
        {
            Gizmos.color = Color.cyan;
            Gizmos.DrawLine(upperRef.position, centroidRef.position);

            Gizmos.color = Color.yellow;
            Gizmos.DrawLine(upperRef.position, lowerRef.position);
            Gizmos.DrawLine(lowerRef.position, handRef.position);

            Gizmos.color = Color.magenta;
            Gizmos.DrawLine(lowerRef.position, elbowRef.position);

            Gizmos.color = Color.red;
            Gizmos.DrawWireSphere(endEffector.position, 0.15f);

            Gizmos.color = Color.green;
            Gizmos.DrawLine(handRef.position, endEffector.position);
        }
    }
예제 #7
0
        /// <summary>
        /// Construct a circle in space
        /// @image html circle.png
        /// </summary>
        /// <param name="origin">The center point of the circle</param>
        /// <param name="normalRadius">
        /// The normal and radius of the circle, the radius of the circle will be
        /// equivalent to this vector's magnitude.
        /// </param>
        /// <param name="segments">
        /// Optional, the number of segments to construct the circle out of.
        /// Defaults to 32.
        /// </param>
        public static void Circle(Vector3 origin, Vector3 normalRadius,
                                  int segments = 32)
        {
            var(left, up) = GetComponentsFromNormal(normalRadius);
            float radius = normalRadius.magnitude;

            for (int i = 0; i < segments; i++)
            {
                float theta0 = 2f * Mathf.PI * (float)i / segments;
                float theta1 = 2f * Mathf.PI * (float)(i + 1) / segments;

                float x0 = radius * Mathf.Cos(theta0);
                float y0 = radius * Mathf.Sin(theta0);
                float x1 = radius * Mathf.Cos(theta1);
                float y1 = radius * Mathf.Sin(theta1);

                Gizmos.DrawLine(
                    origin + left * x0 + up * y0,
                    origin + left * x1 + up * y1);
            }
        }
예제 #8
0
    private void OnDrawGizmos()
    {
        if (DebugMode)
        {
            if (graph != null)
            {
                foreach (Node node in graph)
                {
                    if (node != null)
                    {
                        Gizmos.DrawWireSphere(new Vector3(node.position.x, node.position.y, 0), 0.1f);

                        foreach (Node neighbor in node.neighbors)
                        {
                            Gizmos.DrawLine(node.position, neighbor.position);
                        }
                    }
                }
            }
        }
    }
예제 #9
0
    void OnDrawGizmos()
    {
        if (Spline.Length == transform.childCount)
        {
            for (int i = 0; i < Spline.Length; i++)
            {
                Gizmos.DrawWireSphere(Spline [i].transform.position, SplinePointSize);
                if ((i + 1) != Spline.Length)
                {
                    Gizmos.DrawLine(Spline [i].transform.position, Spline [i + 1].transform.position);
                }
            }
            return;
        }

        Spline = new GameObject[gameObject.transform.childCount];
        for (int i = 0; i < transform.childCount; i++)
        {
            Spline [i] = transform.GetChild(i).gameObject;
        }
    }
예제 #10
0
    void OnDrawGizmos()
    {
        if (vertices == null || vertices.Length == 0)
        {
            return;
        }

        var offset = transform.TransformVector(Vector3.up * height);

        for (int i = 0; i < 4; i++)
        {
            int next = (i + 1) % 4;
            var a    = transform.TransformPoint(vertices[i]);
            var b    = a + offset;
            var c    = transform.TransformPoint(vertices[next]);
            var d    = c + offset;
            Gizmos.DrawLine(a, b);
            Gizmos.DrawLine(a, c);
            Gizmos.DrawLine(b, d);
        }
    }
예제 #11
0
        /// <summary>
        /// Gizmo の描画時に呼び出されます。
        /// </summary>
        protected override void OnDrawGizmos()
        {
            Color previousGizmosColor = Gizmos.color;

            Gizmos.color = Color.white;

            foreach (Vector3 checkPoint in this.checkPoints)
            {
                Gizmos.DrawSphere(checkPoint, 0.25f);
            }

            if (this.checkPointIndex >= this.checkPoints.Count)
            {
                return;
            }

            Gizmos.DrawLine(base.transform.position,
                            (this.checkPoints[this.checkPointIndex] + base.transform.position) / 2f);

            Gizmos.color = previousGizmosColor;
        }
예제 #12
0
    public void OnDrawGizmos()
    {
        if (path != null)
        {
            for (int i = targetIndex; i < path.Length; i++)
            {
                Gizmos.color = Color.black;
                Gizmos.DrawCube(path[i], Vector3.one);

                if (i == targetIndex)
                {
                    Gizmos.DrawLine(transform.position, path[i]);
                }

                else
                {
                    Gizmos.DrawLine(path[i - 1], path[i]);
                }
            }
        }
    }
예제 #13
0
    private void OnDrawGizmos()
    {
        OnEnable();
        Matrix4x4 rotationMatrix;

        // Make the origin point
        rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale); // * Quaternion.Euler(roationToFollow)
        Gizmos.matrix  = rotationMatrix;
        for (int i = 0; i < localKnots.Length - 1; ++i)
        {
            Gizmos.DrawLine(localKnots[i], localKnots[i + 1]);
        }

        int k = 600;

        // Gizmos.color = Color.red;
        // for (int i = 0; i < k; ++i) Gizmos.DrawSphere(origin + calcPosLinear(localKnots, t + i / (float)(k)), 0.00025f);

        Gizmos.color = Color.green;
        for (int i = 0; i < k; ++i)
        {
            Gizmos.DrawSphere(calcPosCubic(localKnots, t + i / (float)(k)), 0.0025f);
        }



        // Gizmos.color = Color.cyan;
        // for (int i = 0; i < k; ++i) Gizmos.DrawSphere(origin + calcPosHermite(localKnots, t + i / (float)(k)), 0.00025f);

        // Gizmos.color = Color.yellow;
        // for (int i = 0; i < k; ++i) Gizmos.DrawSphere(origin + calcPosTest(localKnots, t + i / (float)(k)), 0.00025f);
        // Gizmos.color = Color.blue;
        // for (int i = 0; i < k; ++i) Gizmos.DrawSphere(origin +bezierpath.GetPointNorm((t + i / (float)(k)) % 1), 0.00025f);

        t += 0.00025f;
        if (t > 1f)
        {
            t = 0;
        }
    }
예제 #14
0
    void OnDrawGizmos()
    {
        if (holes.Length <= 0)
        {
            return;
        }

        Gizmos.color = Color.black;
        logoOutline.GizmoDraw();

        Gizmos.color = Color.white;
        foreach (UPolygon hole in holes)
        {
            hole.GizmoDraw();
        }

        if (meshRepresentation == null)
        {
            return;
        }

        Gizmos.color = Color.cyan;

        foreach (KeyValuePair <int, TriangleNet.Data.Triangle> pair in meshRepresentation.triangles)
        {
            TriangleNet.Data.Triangle triangle = pair.Value;

            TriangleNet.Data.Vertex vertex0 = triangle.GetVertex(0);
            TriangleNet.Data.Vertex vertex1 = triangle.GetVertex(1);
            TriangleNet.Data.Vertex vertex2 = triangle.GetVertex(2);

            Vector2 p0 = new Vector2((float)vertex0.x, (float)vertex0.y);
            Vector2 p1 = new Vector2((float)vertex1.x, (float)vertex1.y);
            Vector2 p2 = new Vector2((float)vertex2.x, (float)vertex2.y);

            Gizmos.DrawLine(p0, p1);
            Gizmos.DrawLine(p1, p2);
            Gizmos.DrawLine(p2, p0);
        }
    }
예제 #15
0
파일: Base.cs 프로젝트: 0ptaq0/Corba-2D
        /** Draw gizmos for the graph */
        public virtual void OnDrawGizmos(bool drawNodes)
        {
            if (!drawNodes)
            {
                return;
            }

            // This is the relatively slow default implementation
            // subclasses of the base graph class may override
            // this method to draw gizmos in a more optimized way

            PathHandler data = AstarPath.active.debugPathData;
            GraphNode   node = null;

            // Use this delegate to draw connections
            // from the #node variable to #otherNode
            GraphNodeDelegate drawConnection = otherNode => Gizmos.DrawLine((Vector3)node.position, (Vector3)otherNode.position);

            GetNodes(_node => {
                // Set the #node variable so that #drawConnection can use it
                node = _node;

                Gizmos.color = NodeColor(node, AstarPath.active.debugPathData);
                if (AstarPath.active.showSearchTree && !InSearchTree(node, AstarPath.active.debugPath))
                {
                    return(true);
                }

                PathNode nodeR = data != null ? data.GetPathNode(node) : null;
                if (AstarPath.active.showSearchTree && nodeR != null && nodeR.parent != null)
                {
                    Gizmos.DrawLine((Vector3)node.position, (Vector3)nodeR.parent.node.position);
                }
                else
                {
                    node.GetConnections(drawConnection);
                }
                return(true);
            });
        }
예제 #16
0
    private void OnDrawGizmosSelected()
    {
        m_BoxCollider2D = GetComponent <BoxCollider2D>();
        Vector2     currentLeft  = (Vector2)transform.position + new Vector2(-m_BoxCollider2D.size.x / 2, m_BoxCollider2D.size.y / 2);
        Vector2     currentRight = (Vector2)transform.position + new Vector2(m_BoxCollider2D.size.x / 2, -m_BoxCollider2D.size.y / 2);
        Rigidbody2D rd           = GetComponent <Rigidbody2D>();
        float       gAdd         = GetComponent <PhysicsUpdate>().Gravity / rd.mass;
        float       deltaTime    = 0.02f;
        float       gVelo        = -0.5f * gAdd * deltaTime;

        Gizmos.color = Color.blue;
        for (int i = 0; i < 80; i++)
        {
            gVelo += (gAdd * deltaTime);
            Gizmos.DrawLine(currentLeft, currentLeft + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime);
            Gizmos.DrawLine(currentRight, currentRight + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime);
            currentLeft  = currentLeft + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime;
            currentRight = currentRight + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime;
        }
        currentLeft  = (Vector2)transform.position + new Vector2(-m_BoxCollider2D.size.x / 2, m_BoxCollider2D.size.y / 2);
        currentRight = (Vector2)transform.position + new Vector2(m_BoxCollider2D.size.x / 2, -m_BoxCollider2D.size.y / 2);
        gAdd         = GetComponent <PhysicsUpdate>().Gravity / rd.mass;
        float jumpRetentionAdd = m_JumpRetentionForce / rd.mass;

        gVelo        = -0.5f * gAdd * deltaTime;
        gVelo       -= jumpRetentionAdd * deltaTime;
        Gizmos.color = Color.red;
        for (int i = 0; i < 80; i++)
        {
            gVelo += (gAdd * deltaTime);
            if (i * deltaTime <= m_JumpRetentionTime)
            {
                gVelo += (jumpRetentionAdd * deltaTime);
            }
            Gizmos.DrawLine(currentLeft, currentLeft + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime);
            Gizmos.DrawLine(currentRight, currentRight + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime);
            currentLeft  = currentLeft + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime;
            currentRight = currentRight + (new Vector2(0, m_JumpForce / rd.mass * Time.fixedDeltaTime) + new Vector2(0, gVelo) + new Vector2(m_MoveRate, 0)) * deltaTime;
        }
    }
예제 #17
0
    /*
     * Draws an n-sided polygon at the given position and scale.
     * See http://www.mathopenref.com/coordcirclealgorithm.html for an explanation of the algorithm.
     */
    void DrawPolygon(Vector3 pos, Vector3 scale, int sides)
    {
        //Delta theta.	This controls the number of times we loop and is therefore a function
        // of 2pi and the number of sides we wish to draw.
        float dt = 2 * Mathf.PI / sides;

        //we will need the very first and very last vertices generated after the loop, so they are saved here.
        Vector3 prevPoint  = Vector3.zero;
        Vector3 firstPoint = Vector3.zero;

        //Our main loop.	Each iteration calculates the next vertex position (in 2D space).
        // This could be further improved by taking in a rotation in radians and adding it to both
        // the initialization of t and its terminus, thus effectively rotating our generated polygon
        // (currently all polygons start with the first vertex at [radius, 0] (relative), so our
        // triangle points to the right, and our square is a diamond).
        for (float t = 0; t <= 2 * Mathf.PI; t += dt)
        {
            float   x        = pos.x + (scale.x / 2 * Mathf.Cos(t));
            float   y        = pos.z + (scale.z / 2 * Mathf.Sin(t));
            Vector3 newPoint = new Vector3(x, pos.y, y);

            //Draws the line from the last generated vertex to the one just calculated. Does not do
            // this the first iteration of the loop, as we only have one vertex to work with at that point.
            if (prevPoint != Vector3.zero)
            {
                Gizmos.DrawLine(prevPoint, newPoint);
            }
            else
            {
                //records the first point generated, as we'll need this to close the gap at the end
                firstPoint = newPoint;
            }

            //Save the newly-generated vertex for the next iteration of the loop.
            prevPoint = newPoint;
        }

        //Closes the gap and completes the polygon.
        Gizmos.DrawLine(prevPoint, firstPoint);
    }
예제 #18
0
        private void OnDrawGizmos()
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (gameObject == UnityEditor.Selection.activeGameObject)
            {
                Gizmos.color = Color.cyan;
                Transform relativeTo = null;
                switch (PivotDirectionOrient)
                {
                case ToolTipConnector.OrientTypeEnum.OrientToCamera:
                    relativeTo = Camera.main.transform;    //Veil.Instance.HeadTransform;
                    break;

                case ToolTipConnector.OrientTypeEnum.OrientToObject:
                    relativeTo = (Anchor != null) ? Anchor.transform : transform;
                    break;
                }
                if (PivotMode == ToolTipConnector.PivotModeEnum.Automatic)
                {
                    Vector3 targetPosition  = (Anchor != null) ? Anchor.transform.position : transform.position;
                    Vector3 toolTipPosition = targetPosition + ToolTipConnector.GetDirectionFromPivotDirection(
                        PivotDirection,
                        ManualPivotDirection,
                        relativeTo) * PivotDistance;
                    Gizmos.DrawLine(targetPosition, toolTipPosition);
                    Gizmos.DrawWireCube(toolTipPosition, Vector3.one * 0.05f);
                }
                else
                {
                    Vector3 targetPosition  = (Anchor != null) ? Anchor.transform.position : transform.position;
                    Vector3 toolTipPosition = transform.TransformPoint(ManualPivotLocalPosition);
                    Gizmos.DrawLine(targetPosition, toolTipPosition);
                    Gizmos.DrawWireCube(toolTipPosition, Vector3.one * 0.05f);
                }
            }
        }
예제 #19
0
파일: GridMap.cs 프로젝트: Wholanz/Tower
    //绘制场景信息
    void OnDrawGizmos()
    {
        if (!m_debug || m_map == null)
        {
            return;
        }

        // 线条的颜色
        Gizmos.color = Color.blue;

        // 绘制线条的高度
        float height = 0;

        // 绘制网格
        for (int i = 0; i < MapSizeX; i++)
        {
            Gizmos.DrawLine(new Vector3(i, height, 0), new Vector3(i, height, MapSizeZ));
        }
        for (int k = 0; k < MapSizeZ; k++)
        {
            Gizmos.DrawLine(new Vector3(0, height, k), new Vector3(MapSizeX, height, k));
        }

        // 改为红色
        Gizmos.color = Color.red;

        for (int i = 0; i < MapSizeX; i++)
        {
            for (int k = 0; k < MapSizeZ; k++)
            {
                //在不能放置防守区域的方格内绘制红色的方块
                if (m_map[i, k].fieldtype == MapData.FieldTypeID.CanNotStand)
                {
                    Gizmos.color = new Color(1, 0, 0, 0.5f);

                    Gizmos.DrawCube(new Vector3(i + 0.5f, height, k + 0.5f), new Vector3(1, height + 0.1f, 1));
                }
            }
        }
    }
예제 #20
0
    private void OnDrawGizmos()
    {
        Vector3 firstPos    = transform.GetChild(0).position;
        Vector3 previousPos = firstPos;

        foreach (Transform waypoint in transform)
        {
            Gizmos.DrawSphere(waypoint.position, 0.3f);
            Gizmos.DrawLine(previousPos, waypoint.position);
            previousPos = waypoint.position;
        }
        Gizmos.DrawLine(previousPos, firstPos);

        /*
         * my original implementation, teachers was more concise
         * Vector3 previousPos = Vector3.zero;
         * Vector3 currentPos = Vector3.zero;
         * Vector3 firstPos = Vector3.zero;
         * int iteration = 0;
         *
         * foreach (Transform waypoint in transform) {
         *      iteration++;
         *      Gizmos.DrawSphere(waypoint.position, 0.3f);
         *
         *      if (currentPos == Vector3.zero) {
         *              currentPos = waypoint.position;
         *              firstPos = currentPos;
         *      } else {
         *              previousPos = currentPos;
         *              currentPos = waypoint.position;
         *
         *              Gizmos.DrawLine(previousPos, currentPos);
         *      }
         *
         *      if (iteration == transform.childCount) {
         *              Gizmos.DrawLine(currentPos, firstPos);
         *      }
         * }
         */
    }
예제 #21
0
        protected override void OnDrawGizmos()
        {
            base.OnDrawGizmos();
            if (!enabled || !setupSuccessful)
            {
                return;
            }

            // show opening direction
            Bounds bounds;

            if (handle)
            {
                bounds = Utilities.GetBounds(handle.transform, handle.transform);
            }
            else
            {
                bounds = Utilities.GetBounds(lid.transform, lid.transform);
            }
            float   length = bounds.extents.y * 5f;
            Vector3 point  = bounds.center + new Vector3(0, length, 0);

            switch (finalDirection)
            {
            case Direction.x:
                point += transform.right.normalized * (length / 2f) * subDirection;
                break;

            case Direction.y:
                point += transform.up.normalized * (length / 2f) * subDirection;
                break;

            case Direction.z:
                point += transform.forward.normalized * (length / 2f) * subDirection;
                break;
            }

            Gizmos.DrawLine(bounds.center + new Vector3(0, bounds.extents.y, 0), point);
            Gizmos.DrawSphere(point, length / 8f);
        }
예제 #22
0
    private void OnDrawGizmosSelected()
    {
        const float POINT_DIST     = .005f;
        const float LINE_THICKNESS = .015f;

        if (hit)
        {
            Gizmos.color = editorHitColor;
        }
        else
        {
            Gizmos.color = editorDefaultColor;
        }

        Vector2 pos = new Vector2(transform.position.x, transform.position.y);

        if (!IsFacingLeft())
        {
            pos.x += hitboxOffsetX;
            pos.y += hitboxOffsetY;
        }
        else
        {
            pos.x -= hitboxOffsetX;
            pos.y -= hitboxOffsetY;
        }

        float   theta    = 0.0f;
        Vector2 startPos = pos + new Vector2(attackRadius * Mathf.Cos(theta), attackRadius * Mathf.Sin(theta));

        Gizmos.DrawLine(startPos, startPos);

        for (theta = POINT_DIST; theta < (Mathf.PI * 2.0f); theta += POINT_DIST)
        {
            float   xOffset = attackRadius * Mathf.Cos(theta);
            float   yOffset = attackRadius * Mathf.Sin(theta);
            Vector2 newPos  = pos + new Vector2(xOffset, yOffset);
            Gizmos.DrawLine(newPos - new Vector2(LINE_THICKNESS, LINE_THICKNESS), newPos);
        }
    }
        // draw helper lines
        void OnDrawGizmosSelected()
        {
            if (
                !LeftHandHold ||
                !RightHandHold ||
                !LeftFootHold ||
                !RightFootHold
                )
            {
                return;
            }
            Gizmos.color = Color.blue;

            float size = 1.5f;

            if (LadderSize == LadderSize.Medium)
            {
                size = 3.0f;
            }
            else if (LadderSize == LadderSize.Long)
            {
                size = 6.0f;
            }

            Vector3 ldown = LeftHandHold.position - LeftHandHold.up * size;
            Vector3 lup   = LeftHandHold.position + LeftHandHold.up * size;
            Vector3 rdown = RightHandHold.position - RightHandHold.up * size;
            Vector3 rup   = RightHandHold.position + RightHandHold.up * size;

            Gizmos.DrawLine(ldown, lup);
            Gizmos.DrawLine(rdown, rup);


            ldown = LeftFootHold.position - LeftFootHold.up * size;
            lup   = LeftFootHold.position + LeftFootHold.up * size;
            rdown = RightFootHold.position - RightFootHold.up * size;
            rup   = RightFootHold.position + RightFootHold.up * size;
            Gizmos.DrawLine(ldown, lup);
            Gizmos.DrawLine(rdown, rup);
        }
예제 #24
0
        public static void DrawCircle(Vector3 position, Vector3 up, Color color, float radius = 1.0f)
        {
            up = ((up == Vector3.zero) ? Vector3.up : up).normalized * radius;
            Vector3 _forward = Vector3.Slerp(up, -up, 0.5f);
            Vector3 _right   = Vector3.Cross(up, _forward).normalized *radius;

            Matrix4x4 matrix = new Matrix4x4();

            matrix[0] = _right.x;
            matrix[1] = _right.y;
            matrix[2] = _right.z;

            matrix[4] = up.x;
            matrix[5] = up.y;
            matrix[6] = up.z;

            matrix[8]  = _forward.x;
            matrix[9]  = _forward.y;
            matrix[10] = _forward.z;

            Vector3 _lastPoint = position + matrix.MultiplyPoint3x4(new Vector3(Mathf.Cos(0), 0, Mathf.Sin(0)));
            Vector3 _nextPoint = Vector3.zero;

            Color oldColor = Gizmos.color;

            Gizmos.color = (color == default(Color)) ? Color.white : color;

            for (var i = 0; i < 91; i++)
            {
                _nextPoint.x = Mathf.Cos((i * 4) * Mathf.Deg2Rad);
                _nextPoint.z = Mathf.Sin((i * 4) * Mathf.Deg2Rad);
                _nextPoint.y = 0;

                _nextPoint = position + matrix.MultiplyPoint3x4(_nextPoint);

                Gizmos.DrawLine(_lastPoint, _nextPoint);
                _lastPoint = _nextPoint;
            }
            Gizmos.color = oldColor;
        }
예제 #25
0
    void ShowDebugInEditor()
    {
        if (!m_debug || blocks == null || blocks.Length < m_mapSizeX * m_mapSizeZ)
        {
            return;
        }

        Vector3 startpos = this.transform.position;

        Gizmos.color = Color.blue;

        // draw lines
        float height = 0;

        for (int i = 0; i < mapSizeX; i++)
        {
            Gizmos.DrawLine(new Vector3(startpos.x + i * m_quadSize, height, startpos.z), new Vector3(startpos.x + i * m_quadSize, height, startpos.z + mapSizeZ * m_quadSize));
        }
        for (int k = 0; k < mapSizeZ; k++)
        {
            Gizmos.DrawLine(new Vector3(startpos.x, height, startpos.z + k * m_quadSize), new Vector3(startpos.x + mapSizeX * m_quadSize, height, startpos.z + k * m_quadSize));
        }

        // draw red area
        Gizmos.color = Color.red;

        for (int i = 0; i < mapSizeX; i++)
        {
            for (int k = 0; k < mapSizeZ; k++)
            {
                //if (m_map.IsBlocked2(i * m_quadSize + startpos.x, k * m_quadSize + startpos.z, 0))
                if (blocks[i + k * m_mapSizeX] > 0)
                {
                    Gizmos.color = new Color(1, 0, 0, 0.5f);

                    Gizmos.DrawCube(new Vector3(startpos.x + i * m_quadSize + m_quadSize * 0.5f, height, startpos.z + k * m_quadSize + m_quadSize * 0.5f), new Vector3(m_quadSize, height + 0.1f, m_quadSize));
                }
            }
        }
    }
    private void OnDrawGizmos()
    {
        //var t = transform;
        //var fwd = t.up;
        //var p = transform.position;
        //p.z -= 3;
        //var dir = ((p + fwd) - p).normalized;

        //dir = (Quaternion.Euler(new Vector3(0, 0,  angle_)) * dir).normalized;

        //var p2 = p + dir;

        float3 p   = transform.position;
        float3 fwd = transform.up;

        var angledDir = Utils.GetAngleDir(p, fwd, angle_);

        Vector3 p2 = p + angledDir;

        Gizmos.color = Color.magenta;
        Gizmos.DrawLine(p, p2);
    }
예제 #27
0
 private void OnDrawGizmosSelected()
 {
     Gizmos.color = (Color.red + Color.yellow) / 2.0f;
     for (int i = 0; i < wallSensorCount; i++)
     {
         float   angle = Mathf.Deg2Rad * i * 360.0f / wallSensorCount;
         Vector2 v     = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));
         Gizmos.DrawLine(transform.position, v * avoidWallsRange + (Vector2)transform.position);
     }
     Gizmos.color = Color.Lerp(Color.green, Color.white, 0.2f);
     Gizmos.DrawWireSphere(transform.position, avoidZombiesRange);
     Gizmos.color = Color.Lerp(Color.red, Color.white, 0.8f);
     Gizmos.DrawWireSphere(transform.position, huntSoldiersRange);
     Gizmos.color = Color.Lerp(Color.red, Color.white, 0.5f);
     Gizmos.DrawWireSphere(transform.position, frenziedDistance);
     Gizmos.color = Color.Lerp(Color.red, Color.white, 0.1f);
     Gizmos.DrawWireSphere(transform.position, soldierTetherDistance);
     if (targetedSoldier != null)
     {
         Gizmos.DrawLine(transform.position, targetedSoldier.transform.position);
     }
 }
예제 #28
0
 private void OnDrawGizmos()
 {
     if (lightTargetParameters != null && lightTargetParameters.drawGizmo)
     {
         var targetedLightSpot = targetedLight.GetComponent <Light>();
         var gizmoColor        = lightTargetParameters.colorFilter;
         gizmoColor.a = 1f;
         Gizmos.color = gizmoColor;
         var relativeRotation = targetedLight.transform.rotation;
         var relativePosition = targetedLight.transform.position;
         Gizmos.matrix = targetedLight.transform.localToWorldMatrix;;
         Gizmos.DrawFrustum(new Vector3(0, 0, 1) * targetedLightSpot.shadowNearPlane, targetedLightSpot.spotAngle, targetedLightSpot.range, targetedLightSpot.shadowNearPlane, 1);
         Gizmos.matrix = Matrix4x4.identity;
         //Draw Target
         Gizmos.DrawLine(LightParent.transform.position, LightParent.transform.position + LightParent.transform.TransformVector(LightParent.transform.root.forward * 0.25f));
         Gizmos.DrawLine(LightParent.transform.position, LightParent.transform.position + LightParent.transform.TransformVector(LightParent.transform.root.forward * -0.25f));
         Gizmos.DrawLine(LightParent.transform.position, LightParent.transform.position + LightParent.transform.TransformVector(LightParent.transform.root.up * 0.25f));
         Gizmos.DrawLine(LightParent.transform.position, LightParent.transform.position + LightParent.transform.TransformVector(LightParent.transform.root.up * -0.25f));
         Gizmos.DrawLine(LightParent.transform.position, LightParent.transform.position + LightParent.transform.TransformVector(LightParent.transform.root.right * 0.25f));
         Gizmos.DrawLine(LightParent.transform.position, LightParent.transform.position + LightParent.transform.TransformVector(LightParent.transform.root.right * -0.25f));
     }
 }
예제 #29
0
        protected virtual void OnDrawGizmos()
        {
            if (!this.drawGizmos)
            {
                return;
            }

            Gizmos.color = this.gizmosColor;

            foreach (Vector3 checkPoint in this.checkPoints)
            {
                Gizmos.DrawSphere(checkPoint, this.gizmoSize);
            }

            if (this.checkPointIndex >= this.checkPoints.Length)
            {
                return;
            }

            Gizmos.DrawLine(base.transform.position,
                            (this.checkPoints[this.checkPointIndex] + base.transform.position) / 2f);
        }
예제 #30
0
        private void OnDrawGizmosSelected()
        {
            var sprite = GetComponentInChildren <SpriteRenderer>();

            if (sprite == null)
            {
                return;
            }

            //Highlighting all controlled doors with red lines and spheres
            Gizmos.color = new Color(1, 0.5f, 0, 1);
            for (int i = 0; i < doorControllers.Count; i++)
            {
                var doorController = doorControllers[i];
                if (doorController == null)
                {
                    continue;
                }
                Gizmos.DrawLine(sprite.transform.position, doorController.transform.position);
                Gizmos.DrawSphere(doorController.transform.position, 0.25f);
            }
        }