示例#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);
    }
示例#2
0
    public void CreateAnimationBeingTargetAndInitializeDefaultValue <T>(T targetProperty)
    {
        targetField = new AnimationBeingTargetField();
        if (targetProperty is Material)
        {
            Material target = (Material)Convert.ChangeType(targetProperty, typeof(Material));
        }
        if (targetProperty is Vector3)
        {
            Vector3 target = (Vector3)Convert.ChangeType(targetProperty, typeof(Vector3));

            targetField.SetVector3(target);
            return;
        }
        if (targetProperty is Color)
        {
            Color target = (Color)Convert.ChangeType(targetProperty, typeof(Color));

            targetField.SetColor(target);
            return;
        }
        if (targetProperty is Color32)
        {
            Color32 target = (Color32)Convert.ChangeType(targetProperty, typeof(Color32));

            targetField.SetColor(target);
            return;
        }
        if (targetProperty is AnimationVectorStuct)
        {
            AnimationVectorStuct target = (AnimationVectorStuct)Convert.ChangeType(targetProperty, typeof(AnimationVectorStuct));

            Debug.Log("Taaaaaa: " + target.initial + " " + target.target);

            targetField.SetAnimationVectorStruct(target);
            return;
        }
    }
示例#3
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);
    }