예제 #1
0
 // 重置数据(初始化成其他脸型)
 public void ResetData(FaceBone initFaceBone, Transform bone, Transform preBone)
 {
     name           = initFaceBone.name;
     this.bone      = bone;
     _preBone       = preBone;
     changeType     = initFaceBone.changeType;
     _preChangeType = changeType;
     startValue     = initFaceBone.startValue;
     endValue       = initFaceBone.endValue;
     _isInit        = true;
 }
예제 #2
0
    // 设置差值(0-1)
    public void SetSlerp(float slerp)
    {
        if (bone == null)
        {
            return;
        }

        if (IsDirty())
        {
            UnInit();
        }
        Init();

        _preBone       = bone;
        _preChangeType = changeType;

        Vector3 pos      = bone.localPosition;
        Vector3 rotation = bone.localEulerAngles;
        Vector3 scale    = bone.localScale;

        float value = Mathf.Lerp(startValue, endValue, slerp);

        switch (changeType)
        {
        case FaceBonesChangeType.PositionX:
            pos.x = value;
            break;

        case FaceBonesChangeType.PositionY:
            pos.y = value;
            break;

        case FaceBonesChangeType.PositionZ:
            pos.z = value;
            break;

        case FaceBonesChangeType.RotationX:
            rotation.x = value;
            break;

        case FaceBonesChangeType.RotationY:
            rotation.y = value;
            break;

        case FaceBonesChangeType.RotationZ:
            rotation.z = value;
            break;

        case FaceBonesChangeType.ScaleX:
            scale.x = value;
            break;

        case FaceBonesChangeType.ScaleY:
            scale.y = value;
            break;

        case FaceBonesChangeType.ScaleZ:
            scale.z = value;
            break;
        }

        bone.localPosition = pos;
        bone.localRotation = Quaternion.Euler(rotation);
        bone.localScale    = scale;
    }