using UnityEngine; namespace LitMotion.Extensions { /// /// Provides binding extension methods for RectTransform. /// public static class LitMotionRectTransformExtensions { /// /// Create a motion data and bind it to RectTransform.anchoredPosition /// /// 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 BindToAnchoredPosition(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { target.anchoredPosition = x; }); } /// /// Create a motion data and bind it to RectTransform.anchoredPosition.x /// /// 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 BindToAnchoredPositionX(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var p = target.anchoredPosition; p.x = x; target.anchoredPosition = p; }); } /// /// Create a motion data and bind it to RectTransform.anchoredPosition.y /// /// 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 BindToAnchoredPositionY(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var p = target.anchoredPosition; p.y = x; target.anchoredPosition = p; }); } /// /// Create a motion data and bind it to RectTransform.anchoredPosition3D /// /// 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 BindToAnchoredPosition3D(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { target.anchoredPosition3D = x; }); } /// /// Create a motion data and bind it to RectTransform.anchoredPosition3D.x /// /// 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 BindToAnchoredPosition3DX(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var p = target.anchoredPosition3D; p.x = x; target.anchoredPosition3D = p; }); } /// /// Create a motion data and bind it to RectTransform.anchoredPosition3D.y /// /// 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 BindToAnchoredPosition3DY(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var p = target.anchoredPosition3D; p.y = x; target.anchoredPosition3D = p; }); } /// /// Create a motion data and bind it to RectTransform.anchoredPosition3D.z /// /// 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 BindToAnchoredPosition3DZ(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var p = target.anchoredPosition3D; p.z = x; target.anchoredPosition3D = p; }); } /// /// Create a motion data and bind it to RectTransform.anchorMin /// /// 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 BindToAnchorMin(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { target.anchorMin = x; }); } /// /// Create a motion data and bind it to RectTransform.anchorMax /// /// 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 BindToAnchorMax(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { target.anchorMax = x; }); } /// /// Create a motion data and bind it to RectTransform.sizeDelta /// /// 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 BindToSizeDelta(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { target.sizeDelta = x; }); } /// /// Create a motion data and bind it to RectTransform.sizeDelta.x /// /// 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 BindToSizeDeltaX(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var s = target.sizeDelta; s.x = x; target.sizeDelta = s; }); } /// /// Create a motion data and bind it to RectTransform.sizeDelta.y /// /// 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 BindToSizeDeltaY(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var s = target.sizeDelta; s.y = x; target.sizeDelta = s; }); } /// /// Create a motion data and bind it to RectTransform.pivot /// /// 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 BindToPivot(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { target.pivot = x; }); } /// /// Create a motion data and bind it to RectTransform.pivot.x /// /// 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 BindToPivotX(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var s = target.pivot; s.x = x; target.pivot = s; }); } /// /// Create a motion data and bind it to RectTransform.pivot.y /// /// 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 BindToPivotY(this MotionBuilder builder, RectTransform rectTransform) where TOptions : unmanaged, IMotionOptions where TAdapter : unmanaged, IMotionAdapter { Error.IsNull(rectTransform); return builder.BindWithState(rectTransform, static (x, target) => { var s = target.pivot; s.y = x; target.pivot = s; }); } } }