- Home /
How to prevent IntField update its value while being edited?
Hi.
I want to make an editor for an int value which displays a simple popup if the value is less than 4 and an input field otherwise. Like this:
Here's my enum:
enum NumberOfTaps { One = 1, Two = 2, Three = 3, More = 4 }
But I have a problem that when I have the int field active I can't type "10" because Unity sees "1" and turns int field into enum field with value 1 immediately...
var value = numberOfTapsRequired.intValue;
EditorGUI.BeginChangeCheck();
if (value <= 3) {
var num = value > 3 ? NumberOfTaps.More : (NumberOfTaps)value;
value = (int)(NumberOfTaps)EditorGUILayout.EnumPopup(num, GUILayout.ExpandWidth(true), GUILayout.MinWidth(50));
} else {
value = EditorGUILayout.IntField(value, GUILayout.ExpandWidth(true), GUILayout.MinWidth(50));
}
if (EditorGUI.EndChangeCheck()) numberOfTapsRequired.intValue = Mathf.Max(value, 1);
I wonder how I can make this work. I've tried different combinations of adding a name to this IntField and trying to intercept events... But still can't figure this out.
Has anyone got an idea?
Your answer

Follow this Question
Related Questions
Help with C#(Sharp) to Java Script :) !!! 1 Answer
Logic and datatype existential problem 2 Answers
How can i show enum description in Inspector? 2 Answers
Infinite loop crash System.Enum.ToString() 0 Answers
C# Weapon class generation 2 Answers