public void OnInspectorGUI() { if (buttonMethods.Count == 0) { return; } for (int index = 0; index < buttonMethods.Count; index++) { MethodInfo methodInfo = buttonMethods[index]; ButtonExAttribute buttonExAttribute = buttonAttributes[index]; bool disabled = false; if (buttonExAttribute.showIfRunTime != ShowIfRunTime.All) { if (buttonExAttribute.showIfRunTime == ShowIfRunTime.Playing != Application.isPlaying) { disabled = true; } } using (new EditorGUI.DisabledScope(disabled)) { string name = buttonExAttribute.txtButtonName ?? methodInfo.Name; if (GUILayout.Button(name)) { methodInfo.Invoke(target, null); } } } }
public void OnInspectorGUI() { if (buttonMethods.Count == 0) { return; } for (int index = 0; index < buttonAttributes.Count; index++) { MethodInfo methodInfo = buttonMethods[index]; ButtonExAttribute buttonExAttribute = buttonAttributes[index]; bool disabled = false; if (buttonExAttribute.showIfRunTime != ShowIfRunTime.All) { if (buttonExAttribute.showIfRunTime == ShowIfRunTime.Playing != Application.isPlaying) { disabled = true; } } using (new EditorGUI.DisabledScope(disabled)) { GUILayout.BeginHorizontal(); string name = methodInfo.Name; if (GUILayout.Button(name)) { for (int i = 0; i < serializedObject.targetObjects.Length; i++) { methodInfo.Invoke(serializedObject.targetObjects[i], null); } //methodInfo.Invoke(target, null); } for (int i = 0; i < buttonExAttribute.funcNames.Length; i++) { string funcName = buttonExAttribute.funcNames[i]; if (GUILayout.Button(funcName)) { for (int j = 0; j < serializedObject.targetObjects.Length; j++) { ButtonAttributeDrawer.CalledFunc(serializedObject.targetObjects[j], funcName); } } } GUILayout.EndHorizontal(); } } }