public string changeName = "你的名字"; const string NameField = "changeName"; void OnEnable(){ this.changeName = EditorPrefs.GetString (NameField,this.changeName);//第二个参数为默认值 } void OnWizardUpdate(){ errorString = null; helpString = null; if (Selection.gameObjects.Length > 0) { helpString = "你选择的物体数量为:" + Selection.gameObjects.Length; } else { errorString = "最少需要选择一个物体"; } EditorPrefs.SetString (NameField, this.changeName); }
使用EditorPrefs类的静态方法(对应数据类型),跟PlayerPrefs差不多滴