コード例 #1
0
    public void Set(NetAnimator animator)
    {
        if (Animations == null)
        {
            FDebug.Log.Message("animator was null, trying to reset it");
            Animations = GetComponent <Animator>();
            return;
        }

        foreach (NetAnimationParam component in animator.Parameters)
        {
            if (component is BoolParam)
            {
                BoolParam boolio = component as BoolParam;
                Animations.SetBool(boolio.Name, boolio.State);
            }
            else if (component is FloatParam)
            {
                FloatParam floatio = component as FloatParam;
                Animations.SetFloat(floatio.Name, floatio.State);
            }
            else if (component is IntigerParam)
            {
                IntigerParam intelio = component as IntigerParam;
                Animations.SetInteger(intelio.Name, intelio.State);
            }
            else if (component is TriggerParam)
            {
                TriggerParam triggero = component as TriggerParam;
                Animations.SetTrigger(triggero.Name);
            }
        }
    }
コード例 #2
0
    public static NetAnimator Animator(Animator animator)
    {
        NetAnimator netAnimator = new NetAnimator();

        netAnimator.Parameters = new NetAnimationParam[animator.parameters.Length];

        for (int j = 0; j < animator.parameters.Length; j++)
        {
            switch (animator.parameters[j].type)
            {
            case AnimatorControllerParameterType.Bool:
            {
                BoolParam animBool = new BoolParam();
                animBool.Name             = animator.parameters[j].name;
                animBool.State            = animator.GetBool(animator.parameters[j].name);
                netAnimator.Parameters[j] = animBool;
                continue;
            }

            case AnimatorControllerParameterType.Float:
            {
                FloatParam animfloat = new FloatParam();
                animfloat.Name            = animator.parameters[j].name;
                animfloat.State           = animator.GetFloat(animator.parameters[j].name);
                netAnimator.Parameters[j] = animfloat;
                continue;
            }

            case AnimatorControllerParameterType.Trigger:
            {
                TriggerParam animtrigger = new TriggerParam();
                animtrigger.Name          = animator.parameters[j].name;
                animtrigger.State         = animator.parameters[j].defaultBool;
                netAnimator.Parameters[j] = animtrigger;
                continue;
            }

            case AnimatorControllerParameterType.Int:
            {
                IntigerParam animint = new IntigerParam();
                animint.Name              = animator.parameters[j].name;
                animint.State             = animator.GetInteger(animator.parameters[j].name);
                netAnimator.Parameters[j] = animint;
                continue;
            }
            }
        }
        return(netAnimator);
    }