Question by
CarlHaeggman · Feb 16, 2020 at 07:31 PM ·
unityeditorcustom-inspectorcustomeditor
Custom Editor slider not working inside if statement
[CustomEditor(typeof(QuestingScript))]
public class QuestEditor : Editor
{
public override void OnInspectorGUI()
{
QuestingScript questingScriptAccess = (QuestingScript)target;
GUILayout.BeginHorizontal();
if (GUILayout.Button("Kill Quest"))
{
questingScriptAccess.xRequired = EditorGUILayout.IntSlider("Amount of kills required",
questingScriptAccess.xRequired, 1, 30);
serializedObject.FindProperty("xRequired").intValue = questingScriptAccess.xRequired;
}
}
}
Creating a custom inspector and I'm trying to make a slider popup when a button in the inspector is pressed but of some reason it doesn't seem to work, been looking all over for a solution but haven't found anything. The slider shows and works perfectly fine when outside of the if statement. Anyone have any idea why this?
(Sorry for the messy code sample, not sure how to make it look good)
Comment
Your answer
Follow this Question
Related Questions
Custom Inspector Button Crashing,Custom Inspector Script Crashing 2 Answers
Unity Custom Editor: 1 True Bool Only Within A Group 1 Answer
EditorGUILayout.BeginVertical("Box") not filling the inspector 0 Answers
Custom Editor showing twice? 0 Answers
Help Simple adding a GameObject to an ObjectField() 1 Answer