EditorPrefs.SetFloat("MyFloat", 1.5f); float myFloat = EditorPrefs.GetFloat("MyFloat"); Debug.Log(myFloat);
using UnityEditor; public class MyWindow : EditorWindow { float myFloat; void OnGUI() { myFloat = EditorPrefs.GetFloat("MyFloat", myFloat); myFloat = EditorGUILayout.FloatField("My Float", myFloat); EditorPrefs.SetFloat("MyFloat", myFloat); } }
using UnityEditor; public class MyEditor : Editor { void OnEnable() { float myFloat = EditorPrefs.GetFloat("MyFloat"); Debug.Log(myFloat); } }In this example, we have a custom Editor script called MyEditor. In the OnEnable method, we use GetFloat to retrieve the value of "MyFloat" from the editor preferences. We then log the value of myFloat. The package library for EditorPrefs.GetFloat is the UnityEditor namespace, specifically the EditorPrefs class.