void RegisterCustomMethod(CustomPlayMethod method, bool showWarning)
        {
            if (method == null)
            {
                return;
            }

            string methodName = method.Method.Name;

            if (customPlayMethods.ContainsKey(methodName))
            {
                if (showWarning)
                {
                    Debug.LogWarning("<i>'" + methodName + "'</i>" + " Can't be registered, a Custom Play Method with the same name is already registered.");
                }
            }
            else
            {
                customPlayMethods.Add(methodName, method);
            }

            for (int i = 0; i < states.Count; i++)
            {
                MLPASAnimatorSFX.StateSFX state = states[i];

                if (state.useCustomPlayMethod && state.methodName == methodName)
                {
                    states[i].customPlayMethod = method;
                }
            }
        }
        /// <summary>
        /// Unregister a Custom Play Method in this <see cref="MLPASAnimatorSFXController"/>.
        /// </summary>
        /// <param name="method"></param>
        public void UnregisterCustomMethod(CustomPlayMethod method)
        {
            if (method == null)
            {
                return;
            }

            string methodName = method.Method.Name;

            if (customPlayMethods.ContainsKey(methodName))
            {
                customPlayMethods.Remove(methodName);

                for (int i = 0; i < states.Count; i++)
                {
                    MLPASAnimatorSFX.StateSFX state = states[i];

                    if (state.useCustomPlayMethod && state.methodName == methodName)
                    {
                        states[i].customPlayMethod = null;
                    }
                }
            }
            else
            {
                Debug.LogWarning("Custom Play Method: " + "<i>'" + methodName + "'</i>" + " is already unregisted.");
            }

            if (registeredPlayMethods.Contains(method))
            {
                registeredPlayMethods.Remove(method);
            }
        }
        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);
                    }
                }
            }
        }