Beispiel #1
0
        public static QuickPolygon Create(string name, MeshType meshIndex, Vector3 position, Quaternion rotation, bool isUI)
        {
            GameObject polygon = new GameObject();

            if (!string.IsNullOrEmpty(name))
            {
                polygon.name = name;
            }
            else
            {
                polygon.name = meshIndex.ToString();
            }
            polygon.transform.position = position;
            polygon.transform.rotation = rotation;
                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                Undo.RegisterCreatedObjectUndo(polygon, "Shape Created");
                Selection.activeObject = polygon;
            }
                        #endif
            QuickPolygon newPolygon = polygon.AddComponent <QuickPolygon>();
            newPolygon.ShapeMeshIndex = meshIndex;
            newPolygon.IsUI           = isUI;
            newPolygon.Reset();
            newPolygon.RecalculateMesh();
            return(newPolygon);
        }