Beispiel #1
0
        void DrawOutLine()
        {
            if (EditorApplication.isCompiling || EditorApplication.isUpdating)
            {
                return;
            }

            Gizmos.color = color;

            PolygonCollider2D[] polygions = gameObject.GetComponents <PolygonCollider2D>();
            for (int i = 0; null != polygions && i < polygions.Length; i++)
            {
                PolygonCollider2D p2d = polygions [i];
                DrawPolygion(p2d.points);
            }

            EdgeCollider2D[] edpos = gameObject.GetComponents <EdgeCollider2D>();
            for (int i = 0; null != edpos && i < edpos.Length; i++)
            {
                EdgeCollider2D p2d = edpos [i];
                DrawPolygion(p2d.points);
            }

            BoxCollider2D[] boxpos = gameObject.GetComponents <BoxCollider2D>();
            for (int i = 0; null != boxpos && i < boxpos.Length; i++)
            {
                BoxCollider2D p2d = boxpos [i];
                Vector2[]     v2  = Vector2DUtils.GetBoxCollider2DScope(p2d);
                DrawBoxOnWorld(Vector2DUtils.BoxScopeToPoints(v2));
            }
        }
Beispiel #2
0
        void Awake()
        {
            _collider = GetComponent <BoxCollider2D>();
            _detector = new TouchDetector(_collider);
            _boxScope = Vector2DUtils.GetBoxCollider2DScope(_collider);
            _vertical = Mathf.Abs(_boxScope [1].y - _boxScope [0].y) > Mathf.Abs(_boxScope [1].x - _boxScope [0].x);

            _detector.OnTouchEvent += OnTouchEvent;
        }
Beispiel #3
0
        void DrawLines()
        {
            if (EditorApplication.isCompiling || EditorApplication.isUpdating)
            {
                return;
            }

            BoxCollider2D[] boxpos = gameObject.GetComponents <BoxCollider2D>();
            for (int i = 0; null != boxpos && i < boxpos.Length; i++)
            {
                BoxCollider2D p2d = boxpos [i];
                Vector2[]     v2  = Vector2DUtils.GetBoxCollider2DScope(p2d);

                //horizontal divide
                if (divideX > 0)
                {
                    float d = (v2 [1].x - v2 [0].x) / divideX;
                    for (int j = 0; j < divideX; j++)
                    {
                        float vx = v2 [0].x + j * d;

                        if (j % 2 != 0)
                        {
                            Gizmos.color = evenColor;
                        }
                        else
                        {
                            Gizmos.color = color;
                        }
                        Gizmos.DrawLine(new Vector2(vx, v2 [0].y), new Vector2(vx, v2 [1].y));
                    }
                }

                //vertical divide
                if (divideY > 0)
                {
                    float d = (v2 [1].y - v2 [0].y) / divideY;
                    for (int j = 0; j < divideY; j++)
                    {
                        float vy = v2 [0].y + j * d;

                        if (j % 2 == 0)
                        {
                            Gizmos.color = evenColor;
                        }
                        else
                        {
                            Gizmos.color = color;
                        }
                        Gizmos.DrawLine(new Vector2(v2 [0].x, vy), new Vector2(v2 [1].x, vy));
                    }
                }
            }
        }