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

スクリプト言語

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

EditorPrefs.GetFloat

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 GetFloat(key: string, defaultValue: float = 0.0F): float;
public static float GetFloat(string key, float defaultValue = 0.0F);
public static def GetFloat(key as string, defaultValue as float = 0.0F) as float

Description

キーが存在する場合、 key に対応する値を取得します

キーが存在しない場合、 defaultValue を返します。

	// Simple scripts that creates an empty window and remembers the position and size
	// of the created window.

	class RememberPosition extends EditorWindow {
		var width : float = 300;
		var height : float = 300;
		var x : float = 100;
		var y : float = 100;

		@MenuItem("Examples/Remember position")
		static function Init() {
			var window = GetWindow(RememberPosition);
			window.Show();
		}
		function Awake() {
			width = EditorPrefs.GetFloat("EditorWindowWidth", 300);
			height = EditorPrefs.GetFloat("EditorWindowHeight", 300);
			x = EditorPrefs.GetFloat("EditorWindowX", 100);
			y = EditorPrefs.GetFloat("EditorWindowY", 100);

			position = Rect(x, y, width, height);
		}
		function OnDestroy() {
			EditorPrefs.SetFloat("EditorWindowWidth", width);
			EditorPrefs.SetFloat("EditorWindowHeight", height);
			EditorPrefs.SetFloat("EditorWindowX", x);
			EditorPrefs.SetFloat("EditorWindowY", y);
		}
		function OnGUI() {
			if(GUILayout.Button("Close"))
				this.Close();
		}
	}