I can not change
(Unity 2020.1)
I can not change
(Unity 2020.1)
It’s a local variable so it won’t persist between OnInspectorGUI() calls. You’re creating it newly every time and giving the value 2 every time. Make it an instance variable and only initialize it once:
public class EditorTarget : Editor {
int select = 2;
public override void OnInspectorGUI() {
select = EditorGUILayout.IntSlider(select, 0, 5);
Thank you so much
Line 11 in the top window declares select as a local variable and initializes it to 2, ever frame that this inspector runs.
Move the variable out to a member in Target, then access it via the target
variable in the editor window.
CAUTION: using Target as your classname in this context may be very confusing! Read more here:
Note the Editor class has a .target variable too.
Ah @Kurt-Dekker is right about the target stuff. Having a variable on the Editor class itself will work in the GUI but it won’t actually become accessible from your Target script (if that’s what you’re going for…)