EditorPrefs 编辑偏好设定
Stores and accesses Unity editor preferences.
储存和访问Unity编辑器偏好设定。
Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。
On Mac OS X, EditorPrefs are stored in ~/Library/Preferences/com.unity3d.UnityEditor.plist.
在Mac OS X,EditorPrefs储存在~/Library/Preferences/com.unity3d.UnityEditor.plist。
On Windows, EditorPrefs are stored in the registry under the HKCUSoftwareUnity TechnologiesUnityEditor key.
在WindowsEditorPrefs储存在注册表HKCUSoftwareUnity TechnologiesUnityEditor。
Class Functions类函数
- SetIntSets the value of the preference identified by key.
设置由键确定的偏好值。 - GetIntReturns the value corresponding to key in the preference file if it exists.
- SetFloatSets the value of the preference identified by key.
- GetFloatReturns the value corresponding to key in the preference file if it exists.
- SetStringSets the value of the preference identified by key.
- GetStringReturns the value corresponding to key in the preference file if it exists.
- SetBoolSets the value of the preference identified by key.
- GetBoolReturns the value corresponding to key in the preference file if it exists.
- HasKeyReturns true if key exists in the preferences.
- DeleteKeyRemoves key and its corresponding value from the preferences.
从偏好设定删除键和它对应的值。 - DeleteAllRemoves all keys and values from the preferences. Use with caution.
从偏好设定删除所有键和值。请谨慎使用。