コード例 #1
0
        // fill area {from}, {to} by rectangle
        public static RectangleMesh FillRectangle(Vector3 from, Vector3 to, Material meshMat = null, bool attachRigidbody = true)
        {
            GameObject rectangleMesh = new GameObject();

            rectangleMesh.transform.position = (from + to) / 2;
            RectangleMesh rectangleComponent = rectangleMesh.AddComponent <RectangleMesh>();

            rectangleComponent.Build(to - from, meshMat);
            if (attachRigidbody)
            {
                rectangleMesh.AddComponent <Rigidbody2D>();
            }
            return(rectangleComponent);
        }
コード例 #2
0
        // build rectangle from Rect
        public static RectangleMesh FillRectangle(Rect rect, Material meshMat = null, bool attachRigidbody = true)
        {
            GameObject rectangleMesh = new GameObject();

            rectangleMesh.transform.position = rect.center;
            RectangleMesh rectangleComponent = rectangleMesh.AddComponent <RectangleMesh>();

            rectangleComponent.Build(rect.size, meshMat);
            if (attachRigidbody)
            {
                rectangleMesh.AddComponent <Rigidbody2D>();
            }
            return(rectangleComponent);
        }
コード例 #3
0
        public static RectangleMesh AddRectangle(Vector3 position, Vector2 size, Material meshMat = null, bool attachRigidbody = true)
        {
            GameObject rectangleMesh = new GameObject();

            rectangleMesh.transform.position = position;
            RectangleMesh rectangleComponent = rectangleMesh.AddComponent <RectangleMesh>();

            rectangleComponent.Build(size, meshMat);
            if (attachRigidbody)
            {
                rectangleMesh.AddComponent <Rigidbody2D>();
            }
            return(rectangleComponent);
        }