言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

EditorUtility.CreateGameObjectWithHideFlags

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function CreateGameObjectWithHideFlags(name: string, flags: HideFlags, params components: Type[]): GameObject;
public static GameObject CreateGameObjectWithHideFlags(string name, HideFlags flags, params Type[] components);
public static def CreateGameObjectWithHideFlags(name as string, flags as HideFlags, *components as Type[]) as GameObject

Description

HideFlagsと特定のコンポーネントをアタッチしたゲームオブジェクトを作成します

これは通常のGameObjectの作成方法と似ており、この関数は HideFlagsを設定することが可能です ゲームオブジェクトの非表示を設定するEditorWindow

	// Simple script that lets you manage the flags of an instanceID from a
	// GameObject or lets you create a new empty GameObject with custom flags set

	class GameObjectFlags extends EditorWindow {

		var objName : String = "GameObject";
		var instanceID : int = 0;
		var create : boolean = true;
		var go : GameObject = null;

		var hideHierarchy : boolean = false;

		@MenuItem("Examples/GameObject flags")
		static function Init() {
			var window = GetWindow(GameObjectFlags);
			window.Show();
		}

		function OnGUI() {
			create = EditorGUILayout.Toggle("Create a GO:", create);
			GUI.enabled = create;
				objName = EditorGUILayout.TextField("GameObject Name:", objName);
				if(GUILayout.Button("Create")) {
					var created = EditorUtility.CreateGameObjectWithHideFlags(
							objName,
							hideHierarchy ? HideFlags.HideInHierarchy : 0);
					Debug.Log("Created GameObject ID: " + created.GetInstanceID());
				}
			GUI.enabled = !create;
				EditorGUILayout.BeginHorizontal();
					instanceID = EditorGUILayout.IntField("Instance ID:", instanceID);
					if(GUILayout.Button("Search & Update flags")) {
						go = null;
						go = EditorUtility.InstanceIDToObject(instanceID);
						if(go)
							go.hideFlags = hideHierarchy ?  HideFlags.HideInHierarchy : 0;
					}
				EditorGUILayout.EndHorizontal();

				if(!go)
					EditorGUILayout.LabelField("Object: ","No object was found");
				else
					EditorGUILayout.LabelField("Object: ", go.name);

			GUI.enabled = true;
			hideHierarchy = EditorGUILayout.Toggle("HideInHierarchy", hideHierarchy);

		}
	}