public override void OnInspectorGUI() { if (myController == null) { myController = (AnimationController2D)target; } if (animationClips == null) { var arr = myController.animator.runtimeAnimatorController.animationClips; if (arr != null) { animationClips = arr.ToList(); } } if (animationClips == null || animationClips.Count == 0) { EditorGUILayout.LabelField("No animation clips found on this controller"); return; } string[] animationClipsNames = animationClips.Select(c => c.name).ToArray(); Type myType = myController.GetType(); var methodsInfo = myType.GetMethods(BindingFlags.Public | BindingFlags.Instance); List <String> methodsNames = methodsInfo.ToList().Select(elm => elm.Name).ToList(); foreach (AnimationEffect effect in myController.effects) { effect.fold = EditorGUILayout.Foldout(effect.fold, effect.targetAnimationClip.name + " // " + effect.methodName); if (effect.fold) { effect.selectedParameterType = (AnimationEffect.parameterType)EditorGUILayout.EnumPopup("Parameter type", effect.selectedParameterType); switch (effect.selectedParameterType) { case AnimationEffect.parameterType.OBJECT: var prefab = EditorGUILayout.ObjectField(effect.objectValue, typeof(GameObject)) as GameObject; effect.objectValue = prefab; break; case AnimationEffect.parameterType.BOOLEAN: var boolValue = EditorGUILayout.Toggle(effect.booleanValue == -1 ? false : true) == true ? 1 : -1; effect.booleanValue = boolValue; break; case AnimationEffect.parameterType.FLOAT: var floatValue = EditorGUILayout.FloatField(effect.floatValue); effect.floatValue = floatValue; break; } if (effect.targetAnimationClip != null) { int index = animationClips.FindIndex(c => c.name == effect.targetAnimationClip.name); var selectedClipIndex = EditorGUILayout.Popup(index, animationClipsNames); if (animationClips[selectedClipIndex] != effect.targetAnimationClip) { effect.targetAnimationClip = animationClips[selectedClipIndex]; return; } int methodNameIndex = !String.IsNullOrEmpty(effect.methodName) ? methodsNames.FindIndex(m => m == effect.methodName) : 0; var selectedMethodIndex = EditorGUILayout.Popup(methodNameIndex, methodsNames.ToArray()); if (methodsNames[selectedMethodIndex] != effect.methodName) { effect.methodName = methodsNames[selectedMethodIndex]; return; } } else { effect.targetAnimationClip = animationClips.FirstOrDefault(); return; } var frameToPlayIn = EditorGUILayout.IntField("Frame to play in", effect.frameToPlayIn); effect.frameToPlayIn = frameToPlayIn; if (GUILayout.Button("Remove")) { myController.effects.Remove(effect); return; } GUILayout.Space(5); } } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add effect")) { myController.effects.Add(new AnimationEffect() { targetAnimationClip = animationClips.FirstOrDefault(), methodName = methodsNames.FirstOrDefault(), selectedParameterType = AnimationEffect.parameterType.OBJECT }); } if (GUILayout.Button("Set animation effects")) { myController.SetAnimationEffects(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Clear all effects")) { myController.ClearAllAnimationEffects(); } }