CubeHandleCap() public static method

Draw a cube handle. Pass this into handle functions.

public static CubeHandleCap ( int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType ) : void
controlID int The control ID for the handle.
position Vector3 The world-space position of the handle's start point.
rotation UnityEngine.Quaternion The rotation of the handle.
size float The size of the handle in world-space units.
eventType EventType Event type for the handle to act upon. By design it handles EventType.Layout and EventType.Repaint events.
return void
示例#1
0
        private void DrawCollisions(GameObject brushTarget, Vector3Int position)
        {
            Tilemap[] tilemaps = null;

            if (justEnabled)
            {
                justEnabled = false;
                if (brushTarget.transform.parent == null)
                {
                    return;
                }
                tilemaps = brushTarget.transform.parent.GetComponentsInChildren <Tilemap> ();
                if (tilemaps != null)
                {
                    foreach (var tilemap in tilemaps)
                    {
                        tilemap.RefreshAllTiles();
                    }
                }
            }

            if ((brushTarget.layer != 31 && CollisionBrush.PaletteOnlyMode) || Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (brushTarget.transform.parent == null)
            {
                return;
            }

            if (tilemaps == null)
            {
                tilemaps = brushTarget.transform.parent.GetComponentsInChildren <Tilemap>();
            }

            foreach (var tilemap in tilemaps)
            {
                var tilesBounds = tilemap.cellBounds;

                //for (int x = tilesBounds.min.x; x < tilesBounds.max.x; x++) {
                //	for (int y = tilesBounds.min.y; y < tilesBounds.max.y; y++) {
                var maxEachDir = 35;
                for (int x = position.x - maxEachDir; x <= position.x + maxEachDir; x++)
                {
                    for (int y = position.y - maxEachDir; y <= position.y + maxEachDir; y++)
                    {
                        var pos = new Vector3Int(x, y, 0);
                        if (!tilesBounds.Contains(pos))
                        {
                            continue;
                        }

                        var colType = tilemap.GetColliderType(pos);
                        switch (colType)
                        {
                        case Tile.ColliderType.None:
                            continue;

                        case Tile.ColliderType.Grid:
                        {
                            Handles.color = Color.red;
                            Handles.CubeHandleCap(0, pos + new Vector3(.5f, .5f), Quaternion.identity, .9f, EventType.Repaint);
                            Handles.color = Color.white;
                            Handles.CubeHandleCap(0, pos + new Vector3(.5f, .5f), Quaternion.identity, .8f, EventType.Repaint);
                        } break;

                        case Tile.ColliderType.Sprite:
                        {
                            Handles.color = Color.red;
                            Handles.SphereHandleCap(0, pos + new Vector3(.5f, .5f), Quaternion.identity, .9f, EventType.Repaint);
                            Handles.color = Color.white;
                            Handles.SphereHandleCap(0, pos + new Vector3(.5f, .5f), Quaternion.identity, .8f, EventType.Repaint);
                        } break;
                        }
                    }
                }
            }
        }