private void DrawCubeWithWire(Vector3 pos, float size, Color wireColor, Color cubeColor)
 {
     Handles.color = wireColor;
     Handles.DrawWireCube(pos, new Vector3(size, size, size));
     Handles.color = cubeColor;
     Handles.CubeHandleCap(0, pos, Quaternion.identity, size + 0.001f, EventType.Repaint); // slight offset on size to fix z-fighting
 }
예제 #2
0
        void Preview(SceneView sceneView)
        {
            if (!previewMesh)
            {
                return;
            }
            float zOffset = Curves[0].Spline.transform.position.z;

            previewGO.transform.position = new Vector3(previewGO.transform.position.x, previewGO.transform.position.y, zOffset);

            Vector3[] vts  = previewMesh.vertices;
            int[]     tris = new int[0];
            if (Mode != VERTEXLINE)
            {
                tris = previewMesh.triangles;
            }
            Handles.color  = Color.green;
            Handles.matrix = Matrix4x4.TRS(new Vector3(0, 0, zOffset), Quaternion.identity, Vector3.one);
            for (int i = 0; i < tris.Length; i += 3)
            {
                Handles.DrawPolyLine(vts[tris[i]], vts[tris[i + 1]], vts[tris[i + 2]], vts[tris[i]]);
            }

            Handles.color = Color.gray;
            for (int i = 0; i < vts.Length; i++)
            {
#if UNITY_5_6_OR_NEWER
                Handles.CubeHandleCap(0, vts[i], Quaternion.identity, HandleUtility.GetHandleSize(vts[i]) * 0.07f, EventType.Repaint);
#else
                Handles.CubeCap(0, vts[i], Quaternion.identity, HandleUtility.GetHandleSize(vts[i]) * 0.07f);
#endif
            }
        }
예제 #3
0
    private static void DrawSelectionHandles(PathMovementProxy path)
    {
        for (int i = 0; i < path.NumPoints; ++i)
        {
            PathMovementProxy.Point p = path[i];

            Handles.color = p.isSelected ? Color.blue : Color.white;

            if (!p.makeSmoothTangent)
            {
                Handles.CubeHandleCap(
                    p.controlId,
                    p.position,
                    Quaternion.identity,
                    .3f,
                    EventType.Repaint);
            }
            else
            {
                Handles.SphereHandleCap(
                    p.controlId,
                    p.position,
                    Quaternion.identity,
                    .3f,
                    EventType.Repaint);
            }
        }
    }
예제 #4
0
        public override void Draw(bool isActive)
        {
#if UNITY_EDITOR
            base.Draw(isActive);
            Handles.CubeHandleCap(0, centre, Quaternion.identity, size, EventType.Repaint);
#endif
        }
예제 #5
0
        /*private void DrawBranchPoints(Color color)
         * {
         *      ivyInfo = (IvyInfo)target;
         *      Handles.color = color;
         *
         *      RTBakedIvy bakedIvy = ivyInfo.GetComponent<RTBakedIvy>();
         *
         *      BranchContainer branch = bakedIvy.ivyContainer.branches[1];
         *
         *      //BranchContainer currentBranch = ivyInfo.infoPool.ivyContainer.branches[i];
         *      Handles.color = Color.blue;
         *      Handles.CubeHandleCap(0, branch.branchPoints[0].point, Quaternion.identity, 0.0025f, EventType.Repaint);
         *      for (int j = 1; j < branch.branchPoints.Count; j++)
         *      {
         *              Handles.color = color;
         *              Handles.CubeHandleCap(0, branch.branchPoints[j].point, Quaternion.identity, 0.0025f, EventType.Repaint);
         *      }
         *
         * }*/

        private void DrawBuildingMesh(Color color)
        {
            ivyInfo       = (IvyInfo)target;
            Handles.color = color;


            RuntimeBakedIvy bakedIvy = ivyInfo.GetComponent <RuntimeBakedIvy>();



            if (bakedIvy != null && bakedIvy.meshBuilder != null)
            {
                RTMeshData meshData    = bakedIvy.meshBuilder.buildingMeshData;
                int        maxVertices = meshData.VertexCount();
                int        initIndex   = meshData.VertexCount() - 200;
                initIndex = Mathf.Clamp(initIndex, 0, int.MaxValue);

                maxVertices = Mathf.Clamp(maxVertices, 0, 100);

                for (int i = 0; i < meshData.VertexCount(); i++)
                {
                    Vector3 pos = ivyInfo.transform.TransformPoint(meshData.vertices[i]);

                    Handles.CubeHandleCap(0, pos, Quaternion.identity, 0.0025f, EventType.Repaint);


                    Handles.Label(pos, "" + i);
                }
            }


            //ivyMesh.vertices.Length - 25
        }
예제 #6
0
        private void DrawProcessedMeshVertices(Color[] colorPerBranch)
        {
            ivyInfo = (IvyInfo)target;



            RuntimeBakedIvy bakedIvy = ivyInfo.GetComponent <RuntimeBakedIvy>();

            RTMeshData         processedMeshData        = bakedIvy.meshBuilder.processedMeshData;
            List <List <int> > verticesIndicesPerBranch = bakedIvy.meshBuilder.processedVerticesIndicesPerBranch;
            int verticesPerLoop = bakedIvy.meshBuilder.ivyParameters.sides + 1;

            int initIndex = verticesIndicesPerBranch.Count - (verticesPerLoop * 4);

            initIndex = Mathf.Clamp(initIndex, 0, int.MaxValue);

            Handles.color = Color.yellow;
            for (int j = 0; j < bakedIvy.meshBuilder.processedMeshData.VertexCount(); j++)
            {
                Vector3 vertex = bakedIvy.meshBuilder.processedMeshData.vertices[j];
                Vector3 pos    = ivyInfo.transform.TransformPoint(vertex);
                Handles.CubeHandleCap(0, pos, Quaternion.identity, 0.01f, EventType.Repaint);
            }



            for (int j = 0; j < verticesIndicesPerBranch[verticesIndicesPerBranch.Count - 1].Count; j++)
            {
                int     index = verticesIndicesPerBranch[verticesIndicesPerBranch.Count - 1][j];
                Vector3 pos   = ivyInfo.transform.TransformPoint(processedMeshData.vertices[index]);
                Handles.CubeHandleCap(0, pos, Quaternion.identity, 0.01f, EventType.Repaint);
            }
        }
예제 #7
0
    private void OnSceneGUI()
    {
        Vector3 onCompassPos  = new Vector3(targT.position.x, targT.position.y, targT.position.z + compassRad);
        Vector3 dipCompassPos = new Vector3(targT.position.x, targT.position.y - s_dipValue.floatValue, targT.position.z + compassRad);
        float   cubeSize      = 0.25f;

        // Draw markers to provide context for different values
        if (Event.current.type == EventType.Repaint)
        {
            // Create marker to denote the radius of the compass
            Handles.CircleHandleCap
            (
                0,
                targT.position,
                targT.rotation,
                compassRad,
                EventType.Repaint
            );

            // Create marker for point on compass at dip value of zero
            Handles.CubeHandleCap(0, onCompassPos, Quaternion.identity, cubeSize, EventType.Repaint);

            // Create marker for point on compass at dip value
            Handles.CubeHandleCap(1, dipCompassPos, Quaternion.identity, cubeSize, EventType.Repaint);
            Handles.Label(dipCompassPos, "Cloud Spawn\nDip");

            // Draw a line between the two points
            Handles.DrawLine(onCompassPos, dipCompassPos);
        }
    }
        /*
         * Draws the scene view helpers for IKSolverFABRIKRoot
         * */
        public static void AddScene(IKSolverFABRIKRoot solver, Color color, bool modifiable, ref FABRIKChain selected)
        {
            // Protect from null reference errors
            if (Application.isPlaying && !solver.initiated)
            {
                return;
            }
            if (!Application.isPlaying)
            {
                string message = string.Empty;
                if (!solver.IsValid(ref message))
                {
                    return;
                }
            }
            Handles.color = color;

            // Selecting solvers
            if (Application.isPlaying)
            {
                SelectChain(solver.chains, ref selected, color);
            }

            AddSceneChain(solver.chains, color, selected);

            // Root pin
            Handles.color = new Color(Mathf.Lerp(1f, color.r, solver.rootPin), Mathf.Lerp(1f, color.g, solver.rootPin), Mathf.Lerp(1f, color.b, solver.rootPin), Mathf.Lerp(0.5f, 1f, solver.rootPin));
            if (solver.GetRoot() != null)
            {
                Handles.DrawLine(solver.chains[0].ik.solver.bones[0].transform.position, solver.GetRoot().position);
                Handles.CubeHandleCap(0, solver.GetRoot().position, Quaternion.identity, GetHandleSize(solver.GetRoot().position), EventType.Repaint);
            }
        }
예제 #9
0
        void BulkNodes(int id)
        {
            EditorGUI.BeginChangeCheck();
            float handleSize = HandleUtility.GetHandleSize(bulkControl.Position);

            bulkControl.Position = Handles.PositionHandle(bulkControl.Position, Quaternion.identity);
            bulkControl.Scale    = Handles.ScaleHandle(bulkControl.Scale, bulkControl.Position, Quaternion.identity, handleSize + 1);
            Handles.color        = Color.cyan;
            Handles.DrawWireCube(bulkControl.Position, bulkControl.Scale);

            Vector3Int extension = bulkControl.Extension;

            int controlID = GUIUtility.GetControlID(FocusType.Keyboard);

            Handles.color = Color.green;
            for (int x = -extension.x; x < extension.x; x += graph.m_bulkNodeDistanceGap)
            {
                for (int y = -extension.y; y < extension.y; y += graph.m_bulkNodeDistanceGap)
                {
                    for (int z = -extension.z; z < extension.z; z += graph.m_bulkNodeDistanceGap)
                    {
                        Handles.CubeHandleCap(controlID, new Vector3(x, y, z) + bulkControl.Position, Quaternion.identity, 1f, EventType.Repaint);
                    }
                }
            }

            EditorGUI.EndChangeCheck();
        }
예제 #10
0
    public void OnSceneGUI()
    {
        hallway.PositionUpdate();

        int[] gridSize = hallway.GridSize;

        for (int i = 0; i < gridSize[0]; i++)
        {
            for (int j = 0; j < gridSize[1]; j++)
            {
                Handles.color = StateColor(i, j);
                Vector3 absolutePosition = hallway.GetPosition(i, j);

                if (hallway.HasAdjacents(i, j) && Handles.Button(absolutePosition, Quaternion.identity, 0.5f, 0.5f, Handles.CubeHandleCap))
                {
                    hallway.SwitchState(i, j, MaskState.FILL);
                    hallway.DrawGeometry();
                    SceneUpdater.UpdateScene();
                }

                var state = hallway.GetState(i, j);
                if (NeedsToDrawCube(state))
                {
                    Handles.color = ColorForState(state);
                    Vector3 cubePosition = new Vector3(absolutePosition.x, DoorDefinition.GlobalSize / 2f, absolutePosition.z);
                    Handles.CubeHandleCap(0, cubePosition, Quaternion.identity, DoorDefinition.GlobalSize, EventType.Repaint);
                }
            }
        }
    }
예제 #11
0
    /// <summary>
    /// Draws wire spheres on top of each tile in the current path and a line to visualize the path
    /// </summary>
    protected virtual void OnDrawGizmosSelected()
    {
        if (m_DebugDrawPath)
        {
            if (Path != null && Path.Count > 0)
            {
                Handles.color = Color.grey;
                for (int i = 0; i < Path.Count; i++)
                {
                    var height = Vector3.up * .5f;

                    if (i == Path.Count - 1)
                    {
                        Handles.color = Color.green;
                    }

                    Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
                    Handles.DrawWireCube(Path[i].m_WorldPosition + height, Vector3.one * 0.3f);
                    Handles.CubeHandleCap(0, Path[i].m_WorldPosition + height, Quaternion.identity, 0.3f, EventType.Repaint);

                    if (i > 0)
                    {
                        Debug.DrawLine(Path[i - 1].m_WorldPosition + height, Path[i].m_WorldPosition + height, Color.yellow, 0.0f, true);
                    }
                }
            }
        }
    }
    private void OnSceneGui(SceneView sceneView)
    {
        //geting camera data based on if the active object exists and has custom settings
        var(camPos, camRot, camForward, targetPos) =
            activeObject != null && activeObject.hasCustomSettings ?
            GetCameraTransformTuple(
                activeObject.orbitYaw,
                activeObject.orbitPitch,
                activeObject.orbitDistance,
                activeObject.orbitHeight) :
            GetCameraTransformTuple(
                settings.orbitYaw,
                settings.orbitPitch,
                settings.orbitDistance,
                settings.orbitHeight);

        var binormal = Vector3.Cross(Vector3.up, camForward).normalized; //camera right
        var normal   = Vector3.Cross(camForward, binormal).normalized;   //camera up

        //if there is no active object, just draw a 1x1x1m ghost cube at the center
        if (activeObject == null)
        {
            Handles.color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
            Handles.CubeHandleCap(0, Vector3.zero, Quaternion.identity, 1, EventType.Repaint);
        }

        //drawing the forward vector of the camera
        Handles.color = new Color(0f, 0f, 1f, 0.5f);
        Handles.DrawLine(camPos, targetPos);

        //showing the verticle angle of view
        var upFOVVector   = Quaternion.AngleAxis(settings.cameraFOV / 2, binormal) * camForward;
        var downFOVVector = Quaternion.AngleAxis(settings.cameraFOV / 2, -binormal) * camForward;

        //camera local y
        Handles.color = new Color(0f, 1f, 0f, 0.5f);
        Handles.DrawLine(camPos, camPos + normal * .4f);
        //camera local x
        Handles.color = new Color(1f, 0f, 0f, 0.25f);
        Handles.DrawLine(camPos, camPos + binormal * .4f);
        //camera FOV
        Handles.color = new Color(1f, 1f, 0f, 0.25f);
        Handles.DrawLine(camPos, camPos + upFOVVector * .3f);
        Handles.DrawLine(camPos, camPos + downFOVVector * .3f);
        // drawing the box to represent the frame of the thumbnail
        Handles.color = new Color(1f, 1f, 0f, 0.5f * .75f);
        Handles.RectangleHandleCap(
            0, targetPos,
            camRot,
            //quick and dirty field of view as a function of distance math
            (camPos - targetPos).magnitude * Mathf.Tan(settings.cameraFOV / 2 * Mathf.Deg2Rad),
            EventType.Repaint);

        //drawing a little cube to represent the camera
        Handles.color  = new Color(0f, 0.82f, 1f, 0.5f);
        Handles.matrix = Matrix4x4.TRS(camPos, camRot, Vector3.one);
        Handles.DrawWireCube(Vector3.zero, new Vector3(.25f, .25f, .5f));

        sceneView.Repaint();
    }
예제 #13
0
        private void DrawHitList(List <Vector3Int> coords, EditableTileVolume volume)
        {
            Vector3 cellSize = Vector3.one;

            Vector3 offset = new Vector3(volume.DataXSize * -0.5f * cellSize.x + 0.5f * cellSize.x,
                                         volume.DataYSize * -0.5f + 0.5f * cellSize.y,
                                         volume.DataZSize * -0.5f + 0.5f * cellSize.z);
            Vector3 prev = Vector3.zero;

            foreach (var c in coords)
            {
                var position = new Vector3(c.x + offset.x, c.y + offset.y, c.z + offset.z);
                Handles.color = Color.red;
                Handles.DrawWireCube(position, Vector3.one);
                Handles.color = Color.magenta;
                Handles.CubeHandleCap(0, position, Quaternion.identity, 0.5f, EventType.Used);

                Handles.color = Color.white;

                if (prev != Vector3.zero)
                {
                    Handles.DrawLine(prev, position);
                }
                prev = position;
            }

            Handles.color = Color.yellow;
            Handles.DrawDottedLine(rayStart, rayEnd, 0.2f);
        }
        void CurveEditor(SceneView scene)
        {
            if (connectedObject == null)
            {
                return;
            }

            PathGuide[] points = connectedObject.gameObject.GetComponentsInChildren <PathGuide>();
            Vector3[]   curve  = connectedObject.CurvePath(connectedObject.res);
            if (curve != null)
            {
                Handles.color = Color.green;
                Handles.DrawAAPolyLine(2f, curve);

                Vector3[] pointsPos = new Vector3[points.Length];
                Handles.color = Color.yellow;
                for (int i = 0; i < points.Length; i++)
                {
                    pointsPos[i] = points[i].transform.position;
                    Handles.CubeHandleCap(i, points[i].transform.position, Quaternion.identity, .1f, EventType.Repaint);
                }
                Handles.color = Color.white;
                Handles.DrawAAPolyLine(1f, pointsPos);
            }
        }
예제 #15
0
        private void OnSceneGUI()
        {
            if (Event.current.type == EventType.Repaint)
            {
                Handles.color = Color.red;
                Handles.CubeHandleCap(0, Vector3.zero, Quaternion.identity, .1f, EventType.Repaint);

                var t = target as Trigger;

                float size = HandleUtility.GetHandleSize(t.transform.position) * 1f;
                float snap = 0.5f;

                EditorGUI.BeginChangeCheck();

                float scale = Handles.ScaleSlider(t.f, t.transform.position, -t.transform.right, t.transform.rotation, size, snap);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(target, "Change Scale Value");
                    t.f = scale;
                }

                /*EditorGUI.BeginChangeCheck();
                 * t.f = Handles.ScaleSlider(t.f, t.transform.position, -t.transform.forward, t.transform.rotation, size, snap);
                 *
                 * EditorGUI.EndChangeCheck();*/
            }
        }
예제 #16
0
    private void OnSceneGUI()
    {
        MapGrid grid = (MapGrid)target;

        // Draw white cube around entire grid area
        Handles.color = Color.white;
        Handles.DrawWireCube(grid.transform.position, new Vector3(grid.gridWorldSize.x, 1.0f, grid.gridWorldSize.y));

        if (grid.getTiles() != null) // If tiles have been created (only when running)
        {
            int controlID = 0;

            // Loop through tiles array
            for (int x = 0; x < grid.getGridDimensions().x; x++)
            {
                for (int y = 0; y < grid.getGridDimensions().y; y++)
                {
                    if (grid.getTile(new iVector2(x, y)).walkable) // If walkable, draw in white, if not, draw in red
                    {
                        Handles.color = Color.white;
                    }
                    else
                    {
                        Handles.color = Color.red;
                    }

                    // Draw cube over tile
                    Handles.CubeHandleCap(controlID, grid.getTile(new iVector2(x, y)).position, Quaternion.LookRotation(Vector3.forward), grid.tileSize, EventType.Repaint);
                }
            }
        }
    }
예제 #17
0
    private static void LayoutSelectionHandles(PathMovementProxy path)
    {
        for (int i = 0; i < path.NumPoints; ++i)
        {
            PathMovementProxy.Point p = path[i];

            if (!p.makeSmoothTangent)
            {
                Handles.CubeHandleCap(
                    p.controlId,
                    p.position,
                    Quaternion.identity,
                    .3f,
                    EventType.Layout);
            }
            else
            {
                Handles.SphereHandleCap(
                    p.controlId,
                    p.position,
                    Quaternion.identity,
                    .3f,
                    EventType.Layout);
            }
        }
    }
예제 #18
0
    private void OnSceneGUI()
    {
        Handles.BeginGUI();
        if (GUILayout.Button("按钮", GUILayout.Width(100)))
        {
            Debug.Log("点击按钮");
        }

        GUILayout.Label("你好");

        Handles.EndGUI();

        HandleTest test = (HandleTest)target;

        Handles.CubeHandleCap(0, test.transform.position + Vector3.one, Quaternion.identity, 0.5f, EventType.Repaint);

        //绘制3d按钮
        HandleTest buttonExample = (HandleTest)target;
        Vector3    position      = buttonExample.transform.position + Vector3.up * 2f;
        float      size          = 2f;
        float      pickSize      = size * 2f;

        if (Handles.Button(position, Quaternion.identity, size, pickSize, Handles.RectangleHandleCap))
        {
            Debug.Log("The button was pressed!");
        }
    }
예제 #19
0
    /// <summary>
    /// 핸들을 그립니다.
    /// </summary>
    static void DrawHandle()
    {
        float heightMid = myScript.limitRect.height * 0.5f;
        float widthMid  = myScript.limitRect.width * 0.5f;

        // 점들을 찍어줍니다.
        Handles.CubeHandleCap(0, new Vector2(myScript.limitRect.left, heightMid), Quaternion.identity, Camera.current.orthographicSize * 0.02f, EventType.Repaint);
        Handles.CubeHandleCap(0, new Vector2(myScript.limitRect.right, heightMid), Quaternion.identity, Camera.current.orthographicSize * 0.02f, EventType.Repaint);
        Handles.CubeHandleCap(0, new Vector2(widthMid, myScript.limitRect.top), Quaternion.identity, Camera.current.orthographicSize * 0.02f, EventType.Repaint);
        Handles.CubeHandleCap(0, new Vector2(widthMid, myScript.limitRect.bottom), Quaternion.identity, Camera.current.orthographicSize * 0.02f, EventType.Repaint);

        // 마우스와 가까이 있는 점에는 빨간 점을 찍어줍니다.
        Handles.color = Color.red;
        Vector2 minPoint = myScript.FindMinPosition(MouseInfo.Position, out nowFocus);

        if (HandleUtility.DistanceToRectangle(minPoint, Quaternion.identity, Camera.current.orthographicSize * 0.02f * 0.5f)
            < 50)
        {
            Handles.CubeHandleCap(0, minPoint, Quaternion.identity, Camera.current.orthographicSize * 0.02f, EventType.Repaint);
        }
        else
        {
            nowFocus = CameraLimit.RectEnum.None;
        }
        Handles.color = Color.white;

        // 씬을 다시 그려줍니다.
        SceneView.lastActiveSceneView.Repaint();
    }
예제 #20
0
 public void DrawSelection()
 {
     if (!HasSelection())
     {
         return;
     }
     foreach (var type in currentSystem.Types)
     {
         foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public))
         {
             foreach (var attribute in field.CustomAttributes)
             {
                 if (attribute.AttributeType == typeof(SceneViewWorldPositionAttribute))
                 {
                     foreach (var id in GetSelection())
                     {
                         var data = GetObjectFromArray(type, id);
                         var f3   = (float3)field.GetValue(data);
                         var v3   = new Vector3(f3.x, f3.y, f3.z);
                         Handles.color = Color.red;
                         Handles.CubeHandleCap(0, v3, Quaternion.identity, 1f, EventType.Repaint);
                     }
                 }
             }
         }
     }
 }
예제 #21
0
        public static void DrawScatterBrush(Vector3 point, Vector3 normal, z_BrushSettings settings, Matrix4x4 localToWorldMatrix)
        {
            Vector3 p = localToWorldMatrix.MultiplyPoint3x4(point);
            Vector3 n = localToWorldMatrix.MultiplyVector(normal).normalized;

            float      r        = settings.radius;
            Vector3    a        = Vector3.zero;
            Quaternion rotation = Quaternion.LookRotation(normal, Vector3.up);

            for (int i = 0; i < 10; i++)
            {
                a.x = Mathf.Cos(Random.Range(0f, 360f));
                a.y = Mathf.Sin(Random.Range(0f, 360f));
                a   = a.normalized * Random.Range(0f, r);

                Vector3 v = localToWorldMatrix.MultiplyPoint3x4(point + rotation * a);

                Handles.DrawLine(v, v + (n * .5f));
#if UNITY_5_4_OR_LOWER
                Handles.CubeCap(i + 2302, v, Quaternion.identity, .01f);
#else
                Handles.CubeHandleCap(i + 2302, v, Quaternion.identity, .01f, Event.current.type);
#endif
            }

            /// radius
            Handles.DrawWireDisc(p, n, settings.radius);
        }
예제 #22
0
    public static void DrawPoint(RoadCreatorSettings.PointShape pointShape, Vector3 position, float size, bool showMoveHandle = true)
    {
        if (pointShape == RoadCreatorSettings.PointShape.Cube)
        {
            Handles.CubeHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint);
        }
        else if (pointShape == RoadCreatorSettings.PointShape.Cylinder)
        {
            Handles.CylinderHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint);
        }
        else if (pointShape == RoadCreatorSettings.PointShape.Sphere)
        {
            Handles.SphereHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint);
        }
        else if (pointShape == RoadCreatorSettings.PointShape.Cone)
        {
            Handles.ConeHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint);
        }

        /*if (showMoveHandle == true)
         * {
         *  Handles.Slider(15, position, Vector3.forward, size * 3, Handles.ArrowHandleCap, 1);
         *  return position;// Handles.FreeMoveHandle(position, Quaternion.Euler(0, 90, 0), size * 10, Vector3.one, Handles.ArrowHandleCap);
         *  //return Handles.PositionHandle(position + new Vector3(0, size, 0), Quaternion.identity) - new Vector3(0, size, 0);
         * }
         * else
         * {
         *  return position;
         * }*/
    }
예제 #23
0
    private void OnSceneGUI(SceneView sceneView)
    {
        Grid tGrid = FindObjectOfType <Grid>();

        Node[,] grid;
        float nodeDiameter;
        int   gridSizeX;
        int   gridSizeY;

        nodeDiameter = tGrid.getRadius * 2;
        gridSizeX    = Mathf.RoundToInt(tGrid.gridWorldSize.x / nodeDiameter);
        gridSizeY    = Mathf.RoundToInt(tGrid.gridWorldSize.y / nodeDiameter);
        grid         = new Node[gridSizeX, gridSizeY];

        Vector3 worldBottomLeft = tGrid.transform.position - Vector3.right * tGrid.gridWorldSize.x / 2 - Vector3.forward * tGrid.gridWorldSize.y / 2;

        for (int x = 0; x < gridSizeX; x++)
        {
            for (int y = 0; y < gridSizeY; y++)
            {
                Vector3 worldPoint = worldBottomLeft + Vector3.right * (x * nodeDiameter + tGrid.getRadius) + Vector3.forward * (y * nodeDiameter + tGrid.getRadius);
                grid[x, y] = new Node(worldPoint, x, y, false, null);
            }
        }

        bool tempCheck = true;

        if (grid != null)
        {
            sp = serializedObject.FindProperty("spawns");
            foreach (Node n in grid)
            {
                for (int i = 0; i < sp.arraySize; i++)
                {
                    if (n.gridX == sp.GetArrayElementAtIndex(i).FindPropertyRelative("X").intValue &&
                        n.gridY == sp.GetArrayElementAtIndex(i).FindPropertyRelative("Y").intValue)
                    {
                        Handles.color = new Color(sp.GetArrayElementAtIndex(i).FindPropertyRelative("color").colorValue.r,
                                                  sp.GetArrayElementAtIndex(i).FindPropertyRelative("color").colorValue.g,
                                                  sp.GetArrayElementAtIndex(i).FindPropertyRelative("color").colorValue.b, 0.25f);
                        Handles.CubeHandleCap(0, n.worldPosition, tGrid.transform.rotation, (nodeDiameter - .5f), EventType.Repaint);
                        tempCheck = false;
                        break;
                    }
                    else
                    {
                        Handles.color = new Color(0, 64, 64, 0.00005f);
                    }
                }

                if (tempCheck)
                {
                    Handles.CubeHandleCap(0, n.worldPosition, tGrid.transform.rotation, (nodeDiameter - .5f), EventType.Repaint);
                }

                tempCheck = true;
            }
        }
    }
예제 #24
0
        private static void CubeCapSafe(Vector3 position, Quaternion rotation, float size)
        {
#if UNITY_5_6_OR_NEWER
            Handles.CubeHandleCap(0, position, rotation, size, EventType.Repaint);
#else
            Handles.CubeCap(0, position, rotation, size);
#endif
        }
예제 #25
0
        private void DrawVoxel(Vector3 origin, Vector3 size, Color color)
        {
            var prevColor = Handles.color;

            Handles.color = color;
            Handles.CubeHandleCap(0, origin + size / 2, Quaternion.identity, size.x, EventType.Repaint);
            Handles.color = prevColor;
        }
		public static void DrawCubeCap(int controlID, Vector3 position, Quaternion rotation, float size)
		{
#if UNITY_2017_1_OR_NEWER
			Handles.CubeHandleCap(controlID, position, rotation, size, EventType.Repaint);
#else
			Handles.CubeCap(controlID, position, rotation, size);
#endif
		}
예제 #27
0
 public void OnSceneGUI()
 {
     if (Selected != null)
     {
         Handles.color = new Color32(255, 0, 0, 50);
         Handles.CubeHandleCap(0, Selected.transform.position, Quaternion.identity, 1F, EventType.Repaint);
     }
 }
예제 #28
0
    protected virtual void OnSceneGUI()
    {
        Tools.current = Tool.None;
        WayPointManager wpManager = (WayPointManager)target;

        int count = wpManager.WayPoints.Count;

        for (int i = 0; i < count - 1; i++)
        {
            if (!wpManager.persistentGizmos)
            {
                // Draw handles for waypoint positions
                Handles.color = wpManager.pointColor;
                Handles.CubeHandleCap(0, wpManager.WayPoints[i].position, Quaternion.identity, wpManager.debugRadius, EventType.Repaint);
                Handles.color = wpManager.lineColor;
                Handles.DrawLine(wpManager.WayPoints[i].position, wpManager.WayPoints[i + 1].position);

                if (wpManager.useLookPoints)
                {
                    // Draw handles for waypoint look positions
                    Handles.color = wpManager.lookPointColor;
                    Handles.SphereHandleCap(0, wpManager.WayPoints[i].lookPoint, Quaternion.identity, wpManager.debugRadius, EventType.Repaint);
                    Handles.color = wpManager.lineOfSightColor;
                    Handles.DrawLine(wpManager.WayPoints[i].position, wpManager.WayPoints[i].lookPoint);
                }
            }
            // Update positions using standard xyz position handles
            wpManager.WayPoints[i].position = Handles.PositionHandle(wpManager.WayPoints[i].position, Quaternion.identity);

            if (wpManager.useLookPoints)
            {
                // Update lookpoint positions using xyz handles
                wpManager.WayPoints[i].lookPoint = Handles.PositionHandle(wpManager.WayPoints[i].lookPoint, Quaternion.identity);
            }
        }
        if (count >= 1)
        {
            if (!wpManager.persistentGizmos)
            {
                // Draw waypoint positions
                Handles.color = wpManager.pointColor;
                Handles.CubeHandleCap(0, wpManager.WayPoints[count - 1].position, Quaternion.identity, wpManager.debugRadius, EventType.Repaint);

                if (wpManager.useLookPoints)
                {
                    // Draw lookpoints
                    Handles.color = wpManager.lookPointColor;
                    Handles.SphereHandleCap(0, wpManager.WayPoints[count - 1].lookPoint, Quaternion.identity, wpManager.debugRadius, EventType.Repaint);
                    Handles.DrawLine(wpManager.WayPoints[count - 1].position, wpManager.WayPoints[count - 1].lookPoint);
                }
            }
            wpManager.WayPoints[count - 1].position = Handles.PositionHandle(wpManager.WayPoints[count - 1].position, Quaternion.identity);
            if (wpManager.useLookPoints)
            {
                wpManager.WayPoints[count - 1].lookPoint = Handles.PositionHandle(wpManager.WayPoints[count - 1].lookPoint, Quaternion.identity);
            }
        }
    }
예제 #29
0
        /// <summary>
        /// visualise the bones and joints for generic rigs
        /// </summary>
        private void DrawGenericChainsScene()
        {
            if (system.otherChains == null)
            {
                return;
            }
            if (system.otherChains.Length <= 0)
            {
                return;
            }

            Color yellow = Color.yellow;
            Color blue   = Color.blue;
            Color green  = Color.green;
            Color red    = Color.red;
            Dictionary <int, Color> colorMap = new Dictionary <int, Color>();

            Action <Vector3> drawCube       = v => Handles.CubeHandleCap(0, v, Quaternion.identity, 0.03f, EventType.Repaint);
            Action <int>     alternateColor = i => Handles.color = colorMap[(int)Mathf.Pow(-1, i)];

            Func <float, Color> lerpColor = x => Color.Lerp(green, red, x);
            Action <Core.Chain> toTarget  = x => Handles.DrawLine(x.GetEndEffector().position, x.Target && x.Weight > 0 ? x.Target.position : x.GetEndEffector().position);

            colorMap.Add(1, yellow);
            colorMap.Add(-1, green);

            for (int i = 0; i < system.otherChains.Length; i++)
            {
                for (int j = 0; j < system.otherChains[i].Joints.Count - 1; j++)
                {
                    if (!system.otherChains[i].Joints[j].joint)
                    {
                        return;
                    }
                    if (!system.otherChains[i].Joints[j + 1].joint)
                    {
                        return;
                    }
                    alternateColor(j);

                    Vector3 p0 = system.otherChains[i].Joints[j].joint.position;
                    Vector3 p1 = system.otherChains[i].Joints[j + 1].joint.position;
                    Handles.DrawLine(p0, p1);

                    alternateColor(j + 1);
                }

                if (!system.otherChains[i].GetEndEffector())
                {
                    return;
                }

                Handles.color = lerpColor(system.otherChains[i].Weight);
                toTarget(system.otherChains[i]);
                drawCube(system.otherChains[i].GetEndEffector().position);
                drawCube(system.otherChains[i].Target ? system.otherChains[i].Target.position : system.otherChains[i].GetEndEffector().position);
            }
        }
    void RemoveHandle()
    {
        myMeshCreator.CheckRemoveAbleAll();
        Handles.color = Color.green;
        int[]     triangles  = myMeshCreator.GetMesh().triangles;
        Vector3[] vertices   = myMeshCreator.GetMesh().vertices;
        bool[]    removeAble = myMeshCreator.GetRemoveAble().ToArray();

        Vector3 minVertPos = Vector3.zero;
        // Focus Index 계산
        {
            minVert       = myMeshCreator.FindMinDistanceVertex();
            minMidVertPos = myMeshCreator.FindMinDistanceMidVertex();

            if (Vector3.Distance(vertices[minVert] + myMeshCreator.transform.position, MouseInfo.Position) <
                Vector3.Distance(minMidVertPos + myMeshCreator.transform.position, MouseInfo.Position))
            {
                minMidVertPos = Vector3.zero;
            }
        }


        // 기즈모
        {
            // Vertex 점 찍기
            for (int i = 0; i < vertices.Length; ++i)
            {
                if (removeAble[i] == true)
                {
                    Handles.color = Color.green;
                }
                else
                {
                    Handles.color = Color.gray;
                }
                Handles.CubeHandleCap(0, vertices[i] + myMeshCreator.transform.position, Quaternion.identity, Camera.current.orthographicSize * 0.02f, EventType.Repaint);
            }


            if (removeAble[minVert] == true)
            {
                Handles.color = Color.red;
            }
            else
            {
                Handles.color = Color.black;
            }

            // 가장 가까운 Vertex에 점 찍기
            if (HandleUtility.DistanceToRectangle(
                    vertices[minVert] + myMeshCreator.transform.position,
                    Quaternion.identity, Camera.current.orthographicSize * 0.02f * 0.5f)
                < 50)
            {
                Handles.CubeHandleCap(0, vertices[minVert] + myMeshCreator.transform.position, Quaternion.identity, Camera.current.orthographicSize * 0.02f, EventType.Repaint);
            }
        }
    }