Ejemplo n.º 1
0
        // tween for the audio mixer parameters.
        /// <param name = "mixer">The audio mixer container</param>
        /// <param name = "nameParamMixer">the name of the parameter you want to change</param>
        /// <param name = "timeOrVelocity">the time of tween</param>
        /// <param name = "isAutoKill">Does the tween have to destroy itself when it ends?</param>
        /// <param name = "functionEnum">the function to soften the tween</param>
        /// <param name = "values">The values ​​that the tween must reach</param>

        public static TweenContainer MixerParamTween(this AudioMixer mixer, string nameParamMixer, float timeOrVelocity, bool isAutoKill, FunctionEnum functionEnum, ChangeModes changeMode, params float[] values)
        {
            if (mixer == null)
            {
                return(null);
            }

            void SetNewValue(Vector4 newValue)
            {
                if (mixer != null)
                {
                    mixer.GetFloat(nameParamMixer, out float currentValue);
                    currentValue += newValue.x;
                    mixer.SetFloat(nameParamMixer, currentValue);
                }
                else
                {
                    LogManager.LogWarning("The tween is is referring to object that is not exist", "Tween");
                }
            }

            Vector4 GetInitValue()
            {
                float result = 0;

                if (mixer != null)
                {
                    mixer.GetFloat(nameParamMixer, out result);
                }
                else
                {
                    LogManager.LogWarning("The tween is is referring to object that is not exist", "Tween");
                }
                return(new Vector4(result, 0, 0, 0));
            }

            AnimationCurveInfo curve = new(functionEnum);

            Vector4[] finalValues = ArrayExtend.ConvertNumbersAndVectors <Vector4>(values);

            return(TweenContainer.CreateTween(GetInitValue, timeOrVelocity, SetNewValue, isAutoKill, curve, changeMode, finalValues));
        }
Ejemplo n.º 2
0
 private void OnComplete(TweenContainer tween, float error)
 {
     OnCompleteTween?.Invoke(error);
 }