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

スクリプト言語

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

EditorGUI.RectField

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 RectField(position: Rect, label: GUIContent, value: Rect): Rect;
public static Rect RectField(Rect position, GUIContent label, Rect value);
public static def RectField(position as Rect, label as GUIContent, value as Rect) as Rect

Parameters

position Rectangle on the screen to use for the field.
label Optional label to display above the field.
value The value to edit.

Returns

Rect The value entered by the user.

Description

Make an X, Y, W & H field for entering a Rect.


Rect field in an Editor Window.

	// Find all the cameras in the scene and shows all their viewports togheter
	
	class EditorGUIRectField extends EditorWindow {
		
		var cameras : Camera[];
		
		@MenuItem("Examples/Editor GUI RectField usage")
		static function Init() {
			var window = GetWindow(EditorGUIRectField);
			window.position = Rect(0,0,150,120);
			window.Show();
		}
		
		function OnGUI() {
			if(GUI.Button(Rect(3,3,position.width-6,20),"Update list"))	
				cameras = FindObjectsOfType(Camera);
			
			if(cameras)
			for(var i = 0; i < cameras.Length; i++) {
				cameras[i].rect = EditorGUI.RectField(
						Rect(3,25+45*i,position.width - 6, 25),
						cameras[i].name,
						cameras[i].rect);
			}
		}
	}

Description

Make an X, Y, W & H for Rect using SerializedProperty (not public).