コード例 #1
0
        private static void CreateSprite(MenuCommand menuCommand)
        {
            GameObject parent     = menuCommand.context as GameObject;
            GameObject gameObject = GOCreationCommands.CreateGameObject(parent, "New Sprite", new Type[]
            {
                typeof(SpriteRenderer)
            });
            Sprite sprite = Selection.activeObject as Sprite;

            if (sprite == null)
            {
                Texture2D texture2D = Selection.activeObject as Texture2D;
                if (texture2D)
                {
                    string assetPath = AssetDatabase.GetAssetPath(texture2D);
                    sprite = AssetDatabase.LoadAllAssetsAtPath(assetPath).OfType <Sprite>().First <Sprite>();
                    if (sprite == null)
                    {
                        TextureImporter textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
                        if (textureImporter != null && textureImporter.textureType != TextureImporterType.Sprite)
                        {
                            EditorUtility.DisplayDialog("Sprite could not be assigned!", "Can not assign a Sprite to the new SpriteRenderer because the selected Texture is not configured to generate Sprites.", "OK");
                        }
                    }
                }
            }
            if (sprite != null)
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprite;
            }
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #2
0
        private static void CreateAndPlacePrimitive(PrimitiveType type, GameObject parent)
        {
            string     uniqueNameForSibling = GameObjectUtility.GetUniqueNameForSibling((!(parent != null)) ? null : parent.transform, type.ToString());
            GameObject gameObject           = ObjectFactory.CreatePrimitive(type);

            gameObject.name = uniqueNameForSibling;
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #3
0
        private static void CreateVideoPlayer(MenuCommand menuCommand)
        {
            GameObject parent = menuCommand.context as GameObject;

            GOCreationCommands.Place(GOCreationCommands.CreateGameObject(parent, "Video Player", new Type[]
            {
                typeof(VideoPlayer)
            }), parent);
        }
コード例 #4
0
        private static void CreateAudioReverbZone(MenuCommand menuCommand)
        {
            GameObject parent = menuCommand.context as GameObject;

            GOCreationCommands.Place(GOCreationCommands.CreateGameObject(parent, "Audio Reverb Zone", new Type[]
            {
                typeof(AudioReverbZone)
            }), parent);
        }
コード例 #5
0
        private static void CreateLightProbeGroup(MenuCommand menuCommand)
        {
            GameObject parent = menuCommand.context as GameObject;

            GOCreationCommands.Place(GOCreationCommands.CreateGameObject(parent, "Light Probe Group", new Type[]
            {
                typeof(LightProbeGroup)
            }), parent);
        }
コード例 #6
0
        private static void CreateReflectionProbe(MenuCommand menuCommand)
        {
            GameObject parent = menuCommand.context as GameObject;

            GOCreationCommands.Place(GOCreationCommands.CreateGameObject(parent, "Reflection Probe", new Type[]
            {
                typeof(ReflectionProbe)
            }), parent);
        }
コード例 #7
0
        private static void CreateCamera(MenuCommand menuCommand)
        {
            GameObject parent = menuCommand.context as GameObject;

            GOCreationCommands.Place(GOCreationCommands.CreateGameObject(parent, "Camera", new Type[]
            {
                typeof(Camera),
                typeof(FlareLayer),
                typeof(AudioListener)
            }), parent);
        }
コード例 #8
0
        private static void CreatePointLight(MenuCommand menuCommand)
        {
            GameObject parent     = menuCommand.context as GameObject;
            GameObject gameObject = GOCreationCommands.CreateGameObject(null, "Point Light", new Type[]
            {
                typeof(Light)
            });

            gameObject.GetComponent <Light>().type = LightType.Point;
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #9
0
        private static void CreateTrail(MenuCommand menuCommand)
        {
            GameObject parent     = menuCommand.context as GameObject;
            GameObject gameObject = GOCreationCommands.CreateGameObject(parent, "Trail", new Type[]
            {
                typeof(TrailRenderer)
            });

            gameObject.GetComponent <TrailRenderer>().material = Material.GetDefaultLineMaterial();
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #10
0
        private static void CreateAreaLight(MenuCommand menuCommand)
        {
            GameObject parent     = menuCommand.context as GameObject;
            GameObject gameObject = GOCreationCommands.CreateGameObject(null, "Area Light", new Type[]
            {
                typeof(Light)
            });

            gameObject.GetComponent <Light>().type = LightType.Area;
            gameObject.GetComponent <Transform>().SetLocalEulerAngles(new Vector3(90f, 0f, 0f), RotationOrder.OrderZXY);
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #11
0
        private static void CreateEmptyChild(MenuCommand menuCommand)
        {
            GameObject gameObject = menuCommand.context as GameObject;

            if (gameObject == null)
            {
                gameObject = Selection.activeGameObject;
            }
            GameObject go = GOCreationCommands.CreateGameObject(gameObject, "GameObject", new Type[0]);

            GOCreationCommands.Place(go, gameObject);
        }
コード例 #12
0
        private static void CreateLine(MenuCommand menuCommand)
        {
            GameObject parent     = menuCommand.context as GameObject;
            GameObject gameObject = GOCreationCommands.CreateGameObject(parent, "Line", new Type[]
            {
                typeof(LineRenderer)
            });
            LineRenderer component = gameObject.GetComponent <LineRenderer>();

            component.material        = Material.GetDefaultLineMaterial();
            component.widthMultiplier = 0.1f;
            component.useWorldSpace   = false;
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #13
0
        static void Create3DText(MenuCommand command)
        {
            var parent = command.context as GameObject;
            var go     = ObjectFactory.CreateGameObject("New Text", typeof(MeshRenderer), typeof(TextMesh));

            var      font = Selection.activeObject as Font ?? Font.GetDefault();
            TextMesh tm   = go.GetComponent <TextMesh>();

            tm.text = "Hello World";
            tm.font = font;
            go.GetComponent <MeshRenderer>().material = font.material;

            GOCreationCommands.Place(go, parent);
        }
コード例 #14
0
        private static void Create3DText(MenuCommand command)
        {
            GameObject parent     = command.context as GameObject;
            GameObject gameObject = GOCreationCommands.CreateGameObject(parent, "New Text", new Type[]
            {
                typeof(MeshRenderer),
                typeof(TextMesh)
            });
            Font     font      = (Selection.activeObject as Font) ?? Font.GetDefault();
            TextMesh component = gameObject.GetComponent <TextMesh>();

            component.text = "Hello World";
            component.font = font;
            gameObject.GetComponent <MeshRenderer>().material = font.material;
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #15
0
        private static void CreateParticleSystem(MenuCommand menuCommand)
        {
            GameObject parent     = menuCommand.context as GameObject;
            GameObject gameObject = GOCreationCommands.CreateGameObject(parent, "Particle System", new Type[]
            {
                typeof(ParticleSystem)
            });

            gameObject.GetComponent <Transform>().SetLocalEulerAngles(new Vector3(-90f, 0f, 0f), RotationOrder.OrderZXY);
            ParticleSystemRenderer component = gameObject.GetComponent <ParticleSystemRenderer>();
            Renderer arg_62_0 = component;

            Material[] expr_5A = new Material[2];
            expr_5A[0]         = Material.GetDefaultParticleMaterial();
            arg_62_0.materials = expr_5A;
            GOCreationCommands.Place(gameObject, parent);
        }
コード例 #16
0
 public static void PlaceGameObject(GameObject go, GameObject parent = null)
 {
     GOCreationCommands.Place(go, parent);
 }
コード例 #17
0
 private static void CreateQuad(MenuCommand menuCommand)
 {
     GOCreationCommands.CreateAndPlacePrimitive(PrimitiveType.Quad, menuCommand.context as GameObject);
 }
コード例 #18
0
        private static void CreateEmpty(MenuCommand menuCommand)
        {
            GameObject parent = menuCommand.context as GameObject;

            GOCreationCommands.Place(GOCreationCommands.CreateGameObject(parent, "GameObject", new Type[0]), parent);
        }