void OnEnable() { this.handler = target as ButtonHandler; var obj = new SerializedObject(handler); drawer = new ObjPropertyReorder <GameObject>(obj, "buttons"); drawer.onAdd += OnAdd; drawer.allowSceneObjects = true; // check validation Action <GameObject> callback = handler.OnButtonClick; string callbackName = callback.Method.Name; bool changed = false; foreach (var o in handler.buttons) { if (o == null) { Debug.LogWarning("There is null element in " + handler.transform.GetScenePath(), handler); } else { UIButton button = o.GetComponent <UIButton>(); if (button == null || button.onClick.IsEmpty() || button.onClick[0].methodName != callbackName || button.onClick[0].parameters.IsEmpty() || button.onClick[0].parameters[0].obj != button.gameObject) { EventDelegateUtil.SetCallback(button.onClick, callback, button.gameObject); EditorUtil.SetDirty(button.gameObject); changed = true; // EditorGUILayout.HelpBox(o.name+" is invalid", MessageType.Error); } } } if (changed) { AssetDatabase.SaveAssets(); } }