using UnityEngine; #if LITMOTION_SUPPORT_ZSTRING using Cysharp.Text; #endif namespace LitMotion.Extensions { /// /// Provides binding extension methods for Logger /// public static class LitMotionLoggerExtensions { /// /// Create a motion data and bind it to Debug.unityLogger /// /// The type of value to animate /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// Handle of the created motion data. public static MotionHandle BindToUnityLogger(this MotionBuilder builder) where TValue : unmanaged where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { return builder.Bind(static x => Debug.unityLogger.Log(x)); } /// /// Create a motion data and bind it to Debug.unityLogger /// /// The type of value to animate /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// Log format /// Handle of the created motion data. public static MotionHandle BindToUnityLogger(this MotionBuilder builder, string format) where TValue : unmanaged where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { return builder.Bind(format, static (x, format) => { #if LITMOTION_SUPPORT_ZSTRING var str = ZString.Format(format, x); #else var str = string.Format(format, x); #endif Debug.unityLogger.Log(str); }); } /// /// Create a motion data and bind it to UnityEngine.ILogger /// /// The type of value to animate /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// Handle of the created motion data. public static MotionHandle BindToUnityLogger(this MotionBuilder builder, ILogger logger) where TValue : unmanaged where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(logger); return builder.Bind(logger, static (x, logger) => logger.Log(x)); } /// /// Create a motion data and bind it to UnityEngine.ILogger /// /// The type of value to animate /// The type of special parameters given to the motion data /// The type of adapter that support value animation /// This builder /// Logger /// Log format /// Handle of the created motion data. public static MotionHandle BindToUnityLogger(this MotionBuilder builder, ILogger logger, string format) where TValue : unmanaged where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(logger); return builder.Bind(logger, format, static (x, logger, format) => { #if LITMOTION_SUPPORT_ZSTRING var str = ZString.Format(format, x); #else var str = string.Format(format, x); #endif logger.Log(str); }); } } }