Skip to content

Animation system

高凯 edited this page Jan 19, 2018 · 1 revision

Introduction

  One line of code to use the animation system, built-in variety of animation.

Common parameters

animObject animation object
time animation time
isChild affect child nodes
Interp interpolation type
IsIgnoreTimeScale ignores time scaling
repeatType repeat type
repeatCount The number of repetitions
callBack animation completed callback function
parameter animation completed callback function parameters

Animation type

LocalPosition,
Position,
LocalScale,
LocalRotate,
Rotate,

Color,
Alpha,

UGUI_Color,
UGUI_Alpha,
UGUI_AnchoredPosition,
UGUI_SizeDetal,

Custom_Vector4,
Custom_Vector3,
Custom_Vector2,
Custom_Float,

Blink,

Interpolation type

Default,
Linear,
InBack,
OutBack,
InOutBack,
OutInBack,
InQuad,
OutQuad,
InoutQuad,
InCubic,
OutCubic,
InoutCubic,
OutInCubic,
InQuart,
OutQuart,
InOutQuart,
OutInQuart,
InQuint,
OutQuint,
InOutQuint,
OutInQuint,
InSine,
OutSine,
InOutSine,
OutInSine,

InExpo,
OutExpo,
InOutExpo,
OutInExpo,

OutBounce,
InBounce,
InOutBounce,
OutInBounce,

API

AnimSystem

public static AnimData UguiColor (GameObject animObject, Color? from, Color to,
        float time = 0.5f,
        float delayTime = 0,
        InterpType interp = InterpType.Default,
        bool isChild = true,
        bool IsIgnoreTimeScale = false,
        RepeatType repeatType = RepeatType.Once,
        int repeatCount = -1,
        AnimCallBack callBack = null, object [] parameter = null)

Animation over to the target color

public static AnimData CustomMethodToFloat (AnimCustomMethodFloat method, float from, float to,
        float time = 0.5f,
        float delayTime = 0,
        InterpType interp = InterpType.Default,
        bool IsIgnoreTimeScale = false,
        RepeatType repeatType = RepeatType.Once,
        int repeatCount = -1,
        AnimCallBack callBack = null, object [] parameter = null)

Pass in a float-accepted function that calls this function with the specified interpolation change

public static AnimData BezierMove (GameObject animObject, Vector3? from, Vector3 to,
        Vector3 [] bezier_contral,
        float time = 0.5f,
        float delayTime = 0,
        RepeatType repeatType = RepeatType.Once,
        int repeatCount = -1,
        InterpType interp = InterpType.Default,
        bool isLocal = true,
        PathType bezierMoveType = PathType.Bezier2,
        AnimCallBack callBack = null, object [] parameter = null)

Incoming Bessel control points, the target object curve movement

public static AnimData BezierMove (GameObject animObject, Vector3? from, Vector3 to, float time,
        float [] bezierContralRadius,
        RepeatType repeatType,
        int repeatCount = -1,
        float delayTime = 0,
        InterpType interp = InterpType.Default,
        bool isLocal = true,
        PathType bezierMoveType = PathType.Bezier2,
        AnimCallBack callBack = null, object [] parameter = null)

Incoming Bessel control point random radius, the target object for random curve movement

public static void ClearAllAnim (bool isCallBack = false) stop all animation, you can choose whether to trigger a callback
public static void StopAnim (AnimData animData, bool isCallBack = false) Stop an animation, you can choose whether to trigger a callback
public static void StopAnim (GameObject animGameObject, bool isCallBack = false) Stop all animations on an object, optionally triggering a callback

Example

AnimSystem.UguiMove (m_uiRoot, new Vector3 (-2000, 0, 0), Vector3.zero, interp: InterpType.OutExpo);

AnimSystem.UguiAlpha (gameObject, 0, 1, callBack: (object [] obj) =>
{
    StartCoroutine (base.EnterAnim (l_animComplete, l_callBack, objs));
});
   
public void SetCharacterColor (Vector3 value)
{
    for (int i = 0; i <oldMaterials.Count; i ++)
    {
       for (int j = 0; j <oldMaterials [i] .Length; j ++)
       {
           oldMaterials [i] [j] .color = new Color (value.x, value.y, value.z, 1);
       }
    }
}

public void SetRevort ()
{
     AnimSystem.StopAnim (gameObject);

     AnimSystem.CustomMethodToVector3 (SetCharacterColor, new Vector3 (1, 0.2f, 0.2f), new Vector3 (0.5f, 0.5f, 0.5f), time: 0.2f);
}
Clone this wiki locally