Ejemplo n.º 1
0
    public AnimationBeing CreateScaleAnim(GameObject objRef, Vector3 initial, Vector3 target, AnimationType animType, float duration, int direction, bool loop = false)
    {
        AnimationBeingTargetField t = new AnimationBeingTargetField();

        t.SetAnimationVectorStruct(new AnimationVectorStuct(initial, target));

        System.Action <GameObject, AnimationBeingTargetField, float> func = null;
        func = (GameObject obj, AnimationBeingTargetField field, float alpha) =>
        {
            Vector3 res = field.GetAnimationVectorStruct().initial *(1 - alpha) + field.GetAnimationVectorStruct().target *alpha;
            //Debug.Log(res);
            obj.transform.localScale = res;
        };

        //animation being creation
        AnimationBeing being = new AnimationBeing(objRef, func, duration, direction);

        being.SetLoop(loop);
        being.CreateAnimationBeingTargetAndInitializeDefaultValue(t.GetAnimationVectorStruct());

        switch (animType)
        {
        case AnimationType.Parallel:
            Debug.Log("Created");
            animationBeingsParallel.Add(being);
            break;

        case AnimationType.Serial:
            animationBeingsSequence.Add(being);
            break;
        }
        return(being);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Animate the specified property value between 0 and 1
    /// </summary>
    /// <param name="objref"></param>
    /// <param name="material"></param>
    /// <param name="property"></param>
    /// <param name="animType"></param>
    /// <param name="duration"></param>
    /// <param name="direction"></param>
    /// <param name="loop"></param>
    /// <returns></returns>
    public AnimationBeing CreateMaterialAnimation(GameObject objRef, Material material, string property, AnimationType animType, float duration, int direction = 1, bool loop = false)
    {
        AnimationBeingTargetField t = new AnimationBeingTargetField();

        t.SetMaterial(material);

        System.Action <GameObject, AnimationBeingTargetField, float> func = null;
        func = (GameObject obj, AnimationBeingTargetField field, float alpha) =>
        {
            //Vector3 res = t.GetAnimationVectorStruct().initial * (1 - alpha) + t.GetAnimationVectorStruct().target * alpha;
            material.SetFloat(property, alpha);
            //Debug.Log(res);
        };

        //animation being creation
        AnimationBeing being = new AnimationBeing(objRef, func, duration, direction);

        being.SetLoop(loop);
        being.CreateAnimationBeingTargetAndInitializeDefaultValue(t.getMaterial());

        switch (animType)
        {
        case AnimationType.Parallel:
            Debug.Log("Created");
            animationBeingsParallel.Add(being);
            break;

        case AnimationType.Serial:
            animationBeingsSequence.Add(being);
            break;
        }
        return(being);
    }
Ejemplo n.º 3
0
    public AnimationBeing CreateSequenceAnimationBeing <T>(GameObject obj, System.Action <GameObject, AnimationBeingTargetField, float> func,
                                                           T targetComponent, float duration = 1, int direction = 1)
    {
        AnimationBeing being = new AnimationBeing(obj, func, duration, direction);

        //If the target component is specified, always create an animation target being
        if (targetComponent != null)
        {
            being.CreateAnimationBeingTargetAndInitializeDefaultValue(targetComponent);
        }

        animationBeingsSequence.Add(being);

        return(being);
    }
Ejemplo n.º 4
0
    public AnimationBeing CreateRectTransformLocalPositionAnimation(RectTransform rectTransform,
                                                                    Vector3 initial, Vector3 target, AnimationType animType, float duration, int direction = 1, bool loop = false)
    {
        AnimationBeingTargetField t = new AnimationBeingTargetField();

        t.SetAnimationVectorStruct(new AnimationVectorStuct(initial, target));

        System.Action <GameObject, AnimationBeingTargetField, float> func = null;
        func = (GameObject obj, AnimationBeingTargetField field, float alpha) =>
        {
            //Vector3 res = t.GetAnimationVectorStruct().initial * (1 - alpha) + t.GetAnimationVectorStruct().target * alpha;
            obj.GetComponent <RectTransform>().localPosition = field.GetAnimationVectorStruct().initial *(1 - alpha) +
                                                               field.GetAnimationVectorStruct().target *alpha;

            //material.SetFloat(property, alpha);
        };

        //animation being creation
        AnimationBeing being = new AnimationBeing(rectTransform.gameObject, func, duration, direction);

        being.SetLoop(loop);
        being.CreateAnimationBeingTargetAndInitializeDefaultValue(t.GetAnimationVectorStruct());

        switch (animType)
        {
        case AnimationType.Parallel:
            Debug.Log("Created");
            animationBeingsParallel.Add(being);
            break;

        case AnimationType.Serial:
            animationBeingsSequence.Add(being);
            break;
        }
        return(being);
    }