CreateGameObjectWithHideFlags() public static method

Creates a game object with HideFlags and specified components.

public static CreateGameObjectWithHideFlags ( string name, HideFlags flags ) : GameObject
name string
flags HideFlags
return UnityEngine.GameObject
        protected static GameObject CreateLight()
        {
            GameObject lightGO = EditorUtility.CreateGameObjectWithHideFlags("PreRenderLight", HideFlags.HideAndDontSave, typeof(Light));
            var        light   = lightGO.GetComponent <Light>();

            light.type      = LightType.Directional;
            light.intensity = 1.0f;
            light.enabled   = false;
            return(lightGO);
        }
示例#2
0
        protected static GameObject CreateLight()
        {
            GameObject gameObject = EditorUtility.CreateGameObjectWithHideFlags("PreRenderLight", HideFlags.HideAndDontSave, new Type[]
            {
                typeof(Light)
            });
            Light component = gameObject.GetComponent <Light>();

            component.type      = LightType.Directional;
            component.intensity = 1f;
            component.enabled   = false;
            return(gameObject);
        }
示例#3
0
        private void CreatePreviewBrush()
        {
            this.m_BrushProjector                  = EditorUtility.CreateGameObjectWithHideFlags("TerrainInspectorBrushPreview", HideFlags.HideAndDontSave, typeof(Projector)).GetComponent(typeof(Projector)) as Projector;
            this.m_BrushProjector.enabled          = false;
            this.m_BrushProjector.nearClipPlane    = -1000f;
            this.m_BrushProjector.farClipPlane     = 1000f;
            this.m_BrushProjector.orthographic     = true;
            this.m_BrushProjector.orthographicSize = 10f;
            this.m_BrushProjector.transform.Rotate(90f, 0.0f, 0.0f);
            Material material = EditorGUIUtility.LoadRequired("SceneView/TerrainBrushMaterial.mat") as Material;

            material.SetTexture("_CutoutTex", (Texture)EditorGUIUtility.Load(EditorResourcesUtility.brushesPath + "brush_cutout.png"));
            this.m_BrushProjector.material = material;
            this.m_BrushProjector.enabled  = false;
        }
示例#4
0
        public override void OnCreated()
        {
            Selection.selectionChanged += OnSelectionChanged;

            if (!EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
            }

            m_PreviewCamera = EditorUtility.CreateGameObjectWithHideFlags("Preview Camera",
                                                                          HideFlags.HideAndDontSave,
                                                                          typeof(Camera),
                                                                          typeof(Skybox)).GetComponent <Camera>();
            m_PreviewCamera.enabled = false;
            OnSelectionChanged();
        }
示例#5
0
        public PreviewScene(string sceneName)
        {
            this.m_Scene      = EditorSceneManager.NewPreviewScene();
            this.m_Scene.name = sceneName;
            GameObject gameObject = EditorUtility.CreateGameObjectWithHideFlags("Preview Scene Camera", HideFlags.HideAndDontSave, new Type[]
            {
                typeof(Camera)
            });

            this.AddGameObject(gameObject);
            this.m_Camera                   = gameObject.GetComponent <Camera>();
            this.camera.cameraType          = CameraType.Preview;
            this.camera.enabled             = false;
            this.camera.clearFlags          = CameraClearFlags.Depth;
            this.camera.fieldOfView         = 15f;
            this.camera.farClipPlane        = 10f;
            this.camera.nearClipPlane       = 2f;
            this.camera.renderingPath       = RenderingPath.Forward;
            this.camera.useOcclusionCulling = false;
            this.camera.scene               = this.m_Scene;
        }
示例#6
0
        public PreviewScene(string sceneName)
        {
            m_Scene      = EditorSceneManager.NewPreviewScene();
            m_Scene.name = sceneName;

            var camGO = EditorUtility.CreateGameObjectWithHideFlags("Preview Scene Camera", HideFlags.HideAndDontSave, typeof(Camera));

            AddGameObject(camGO);
            m_Camera             = camGO.GetComponent <Camera>();
            camera.cameraType    = CameraType.Preview;
            camera.enabled       = false;
            camera.clearFlags    = CameraClearFlags.Depth;
            camera.fieldOfView   = 15;
            camera.farClipPlane  = 10.0f;
            camera.nearClipPlane = 2.0f;

            // Explicitly use forward rendering for all previews
            // (deferred fails when generating some static previews at editor launch; and we never want
            // vertex lit previews if that is chosen in the player settings)
            camera.renderingPath       = RenderingPath.Forward;
            camera.useOcclusionCulling = false;
            camera.scene = m_Scene;
        }
        public PreviewRenderUtility(bool renderFullScene)
        {
            GameObject gameObject = EditorUtility.CreateGameObjectWithHideFlags("PreRenderCamera", HideFlags.HideAndDontSave, new Type[]
            {
                typeof(Camera)
            });

            this.m_Camera                     = gameObject.GetComponent <Camera>();
            this.m_Camera.cameraType          = CameraType.Preview;
            this.m_Camera.fieldOfView         = this.m_CameraFieldOfView;
            this.m_Camera.enabled             = false;
            this.m_Camera.clearFlags          = CameraClearFlags.Depth;
            this.m_Camera.farClipPlane        = 10f;
            this.m_Camera.nearClipPlane       = 2f;
            this.m_Camera.backgroundColor     = new Color(0.192156866f, 0.192156866f, 0.192156866f, 1f);
            this.m_Camera.renderingPath       = RenderingPath.Forward;
            this.m_Camera.useOcclusionCulling = false;
            if (!renderFullScene)
            {
                Handles.SetCameraOnlyDrawMesh(this.m_Camera);
            }
            for (int i = 0; i < 2; i++)
            {
                GameObject gameObject2 = EditorUtility.CreateGameObjectWithHideFlags("PreRenderLight", HideFlags.HideAndDontSave, new Type[]
                {
                    typeof(Light)
                });
                this.m_Light[i]           = gameObject2.GetComponent <Light>();
                this.m_Light[i].type      = LightType.Directional;
                this.m_Light[i].intensity = 1f;
                this.m_Light[i].enabled   = false;
            }
            this.m_Light[0].color = SceneView.kSceneViewFrontLight;
            this.m_Light[1].transform.rotation = Quaternion.Euler(340f, 218f, 177f);
            this.m_Light[1].color = new Color(0.4f, 0.4f, 0.45f, 0f) * 0.7f;
        }