示例#1
0
    private MotionBehaviour mtnBehaviour; // MotionBehaviour

    void Start()
    {
        Live2D.init();
        anim         = GetComponent <Animator>();
        mtnBehaviour = anim.GetBehaviour <MotionBehaviour>();

        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

        for (int i = 0; i < textureFiles.Length; i++)
        {
            live2DModel.setTexture(i, textureFiles[i]);
        }

        float modelWidth = live2DModel.getCanvasWidth();

        live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);

        motionMgr = new MotionQueueManager();
        motion    = Live2DMotion.loadMotion(motionFile.bytes);
    }
示例#2
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        transform = playerData as Transform;

        if (transform == null)
        {
            Debug.Log("Transform Null");
            return;
        }

        if (!firstFrameHappened)
        {
            defaultPosition    = transform.position;
            firstFrameHappened = true;
        }

        int inputCount = playable.GetInputCount();

        Vector3 blendedPosition = Vector3.zero;
        float   totalHeight     = 0f;

        for (int i = 0; i < inputCount; ++i)
        {
            float inputWeight = playable.GetInputWeight(i);
            ScriptPlayable <MotionBehaviour> inputPlayable = (ScriptPlayable <MotionBehaviour>)playable.GetInput(i);
            MotionBehaviour behaviour = inputPlayable.GetBehaviour();

            blendedPosition += behaviour.trackPosition * inputWeight;
            totalHeight     += inputWeight;
        }

        //float remainingWeight = 1 - totalHeight;
        //Debug.Log($"Blend: {blendedPosition} \n  Default: {defaultPosition} * remaining: {remainingWeight}");

        transform.position = blendedPosition + defaultPosition; // * remainingWeight;
    }
示例#3
0
 void Awake()
 {
     this.explosionScript = this.GetComponent <ItemExplosionBehaviour>();
     this.motionScript    = this.GetComponent <MotionBehaviour>();
 }