public override void OnInspectorGUI() { targetAs = (ReInputMap)target; if (settings == null) { settings = EditorSettings.GetSettings(targetAs); } serializedObject.Update(); if (foldoutStyle == null) { foldoutStyle = new GUIStyle(EditorStyles.foldout); foldoutStyle.normal.textColor = Color.blue; } foreach (var input in targetAs.InputMap) { if (settings.FoldoutToggles == null) { settings.FoldoutToggles = new Dictionary <ReInput, bool>(); foreach (var i in settings.TargetInputMap.InputMap) { settings.FoldoutToggles.Add(i, true); } } if (!settings.FoldoutToggles.ContainsKey(input)) { settings.FoldoutToggles.Add(input, true); } } EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(ContentHelpers.AddButtonLabel)) { targetAs.InputMap.Add(new ReInput()); wasAdded = true; } } EditorGUILayout.EndHorizontal(); settings.FoldoutInputMap = EditorGUILayout.Foldout(settings.FoldoutInputMap, "Input Map"); if (settings.FoldoutInputMap && !wasAdded) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); { inputMapScrollPosition = EditorGUILayout.BeginScrollView(inputMapScrollPosition); { int i = 0; foreach (var input in targetAs.InputMap) { DrawInputFoldout(input); if (wasAdded) { break; } if (settings.FoldoutToggles[input]) { DrawReInput(input); } GUILayout.Space(3f); i++; } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); } if (inputToRemove != null) { targetAs.InputMap.Remove(inputToRemove); inputToRemove = null; } wasAdded = false; serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(target); AssetDatabase.SaveAssets(); } }
void ReloadSettings() { targetAs = (ReInputMap)target; settings = EditorSettings.GetSettings(targetAs); }