bool ContainsState(AlmenaraGames.MLPASAnimatorSFX state, out ValuesOverride valuesOverride)
        {
            if (newValues.Exists(x => x.stateName == state.runtimeStateName && x.layer == state.transitionLayer))
            {
                valuesOverride = newValues.Find(x => x.stateName == state.runtimeStateName && x.layer == state.transitionLayer);
                return(true);
            }

            valuesOverride = null;
            return(false);
        }
            bool ContainsStateEditor(AlmenaraGames.MLPASAnimatorSFX state, out ValuesOverride valuesOverride)
            {
                UnityEditor.Animations.StateMachineBehaviourContext[] context = UnityEditor.Animations.AnimatorController.FindStateMachineBehaviourContext(state);
                UnityEditor.Animations.AnimatorState        cState            = (context[0].animatorObject as UnityEditor.Animations.AnimatorState);
                UnityEditor.Animations.AnimatorStateMachine cStateMachine     = (context[0].animatorObject as UnityEditor.Animations.AnimatorStateMachine);

                string stateName = cState != null ? cState.name : cStateMachine.name;
                int    layer     = context[0].layerIndex;

                if ((obj.targetObject as MLPASAnimatorSFXController).newValues.Exists(x => x.stateName == stateName && x.layer == layer))
                {
                    valuesOverride = (obj.targetObject as MLPASAnimatorSFXController).newValues.Find(x => x.stateName == stateName && x.layer == layer);
                    return(true);
                }

                valuesOverride = null;
                return(false);
            }
        public void UpdateValues()
        {
            if (anim != null)
            {
                bool n = false;

                states.Clear();

                foreach (var item in anim.GetBehaviours <AlmenaraGames.MLPASAnimatorSFX>())
                {
                    ValuesOverride newValue = null;

                    item.trf = transform;

                    if (ContainsState(item, out newValue))
                    {
                        newValue.stateName = item.runtimeStateName;
                        newValue.layer     = item.transitionLayer;

                        item.AssignSFXController(this, newValue);
                    }

                    // if (!statesAdded)

                    states.AddRange(item.stateSfxs);



                    n = true;
                }

                if (!n)
                {
                    Debug.LogWarning("The Animator from Game Object: <b>" + gameObject.name + "</b> doesn't have any <i>MLPASAnimatorSFX</i> State Machine Behaviour");
                }
                else
                {
                    if (!inspectorDelegatesAdded)
                    {
                        foreach (var item in inspectorDelegates)
                        {
                            if (item.target == null || string.IsNullOrEmpty(item.methodName))
                            {
                                continue;
                            }

                            System.Reflection.MethodInfo[] methods       = item.target.GetType().GetMethods();
                            System.Reflection.MethodInfo   correctMethod = null;

                            for (int i = 0; i < methods.Length; i++)
                            {
                                bool validMethod = false;
                                System.Reflection.ParameterInfo[] parameters = methods[i].GetParameters();

                                for (int i2 = 0; i2 < parameters.Length; i2++)
                                {
                                    if (item.methodName == methods[i].Name && parameters[i2].ParameterType == typeof(MLPASACustomPlayMethodParameters))
                                    {
                                        correctMethod = methods[i];
                                        validMethod   = true;
                                        break;
                                    }
                                }

                                if (validMethod)
                                {
                                    break;
                                }
                            }

                            CustomPlayMethod action = (CustomPlayMethod)System.Delegate.CreateDelegate(typeof(CustomPlayMethod), item.target, correctMethod);

                            if (correctMethod != null && action != null)
                            {
                                registeredPlayMethods.Add(action);
                                RegisterCustomMethod(action, false);
                            }
                        }
                        inspectorDelegatesAdded = true;
                    }


                    foreach (var m in registeredPlayMethods)
                    {
                        RegisterCustomMethod(m, false);
                    }
                }
            }
        }