UnityEditor.EditorUtility.CreateGameObjectWithHideFlags C# (CSharp) Method

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
        public static GameObject CreateGameObjectWithHideFlags(string name, HideFlags flags, params Type[] components)
        {
            GameObject obj2 = Internal_CreateGameObjectWithHideFlags(name, flags);
            obj2.AddComponent(typeof(Transform));
            foreach (Type type in components)
            {
                obj2.AddComponent(type);
            }
            return obj2;
        }

Usage Example

        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);
        }
All Usage Examples Of UnityEditor.EditorUtility::CreateGameObjectWithHideFlags
EditorUtility