Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

PreferenceItem

class in UnityEditor

マニュアルに切り替える

説明

PreferenceItem 属性により Preferences ウィンドウに Preferences セクションに追加できます。

PreferenceItem 属性により Preferences ウィンドウに Preferences セクションに追加できます。

using UnityEngine;
using UnityEditor;

public class ExampleScript : MonoBehaviour { // Have we loaded the prefs yet private static bool prefsLoaded = false;

// The Preferences public static bool boolPreference = false;

// Add preferences section named "My Preferences" to the Preferences Window [PreferenceItem("My Preferences")] public static void PreferencesGUI() { // Load the preferences if (!prefsLoaded) { boolPreference = EditorPrefs.GetBool("BoolPreferenceKey", false); prefsLoaded = true; }

// Preferences GUI boolPreference = EditorGUILayout.Toggle("Bool Preference", boolPreference);

// Save the preferences if (GUI.changed) EditorPrefs.SetBool("BoolPreferenceKey", boolPreference); } }

コンストラクタ

PreferenceItemPreferences ウィンドウに name というセクションを作成し、セクションの GUI にて続く static 関数を実行します。