Exemplo n.º 1
0
        public static Mesh GetPrimitiveMesh(PrimitiveType type)
        {
            if (!PrimitiveHelper.primitiveMeshes.ContainsKey(type))
            {
                PrimitiveHelper.CreatePrimitiveMesh(type);
            }

            return(PrimitiveHelper.primitiveMeshes[type]);
        }
Exemplo n.º 2
0
        public static GameObject CreatePrimitive(PrimitiveType type, bool withCollider)
        {
            if (withCollider)
            {
                return(GameObject.CreatePrimitive(type));
            }

            GameObject gameObject = new GameObject(type.ToString());
            MeshFilter meshFilter = gameObject.AddComponent <MeshFilter>();

            meshFilter.sharedMesh = PrimitiveHelper.GetPrimitiveMesh(type);
            gameObject.AddComponent <MeshRenderer>();

            return(gameObject);
        }