Exemplo n.º 1
0
 public void forceStop()
 {
     myCamera.enabled = false;
     motionMgr.stopAllMotions();
     IsStop = true;
     FinishCoroutineStop();
 }
    public void LoadFromFile(string[] motionFilePaths)
    {
        motionMgr.stopAllMotions();
        running = false;

        motions = new Live2DMotion[motionFilePaths.Length];
        for (int i = 0; i < motionFilePaths.Length; i++)
        {
            motions[i] = Live2DMotion.loadMotion(File.ReadAllBytes(motionFilePaths[i]));
        }

        currentMotionIndex = motionFiles.Length - 1;
    }
Exemplo n.º 3
0
 public void ChangeMotion()
 {
     if (motionMgr == null)
     {
         motionMgr = new MotionQueueManager();
     }
     motionMgr.stopAllMotions();
     //Debug.Log("--表情--->" + motionList[currentMotionIndex]);
     motion = Live2DMotion.loadMotion(motionFiles[motionList[currentMotionIndex]].bytes);
     SetMotion(motion);
     currentMotionIndex++;
 }
Exemplo n.º 4
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }



        if (auto)
        {
            if (link_animator)
            {
                AnimatorStateInfo state = GetComponent <Animator>().GetCurrentAnimatorStateInfo(0);
                timer = state.length * state.normalizedTime;


                //timer = (float)GetComponent<Animator>().GetTime();
                UtSystem.setUserTimeMSec((long)(timer * 1000.0f));
            }
            else
            {
                delta_timer = (Time.time - temp_real_timer) * speed;

                timer += delta_timer;

                UtSystem.setUserTimeMSec((long)(timer * 1000.0f));

                temp_real_timer = Time.time;
            }
        }

        bool motion_chenged = false;

        if (motionFile == null)
        {
            motion = null;


            temp_motionFile_name = "";
        }
        else
        {
            if (temp_motionFile_name != motionFile.name)
            {
                motion         = Live2DMotion.loadMotion(motionFile.bytes);
                motion_chenged = true;
            }

            temp_motionFile_name = motionFile.name;
        }



        if (live2DModel.getLayer() != gameObject.layer)
        {
            live2DModel.setLayer(gameObject.layer);
        }


        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }



        if (motion != null)
        {
            motion.setLoop(true);
            motion.setFadeIn(0);
            motion.setFadeOut(0);

            if (motionMgr.isFinished())
            {
                motionMgr.startMotion(motion);
            }

            if (motion_chenged)
            {
                motionMgr.stopAllMotions();
                motionMgr.startMotion(motion);
            }


            motionMgr.updateParam(live2DModel);
        }
        else
        {
            motionMgr.stopAllMotions();

            if (motionFile != null)
            {
                motion = Live2DMotion.loadMotion(motionFile.bytes);
            }
        }



        live2DModel.update();

        if (live2DModel.getRenderMode() == Live2D.L2D_RENDER_DRAW_MESH)
        {
            Render();
        }
    }
Exemplo n.º 5
0
 public void ReleaseExpression()
 {
     motionMgr.stopAllMotions();
     motion = null;
 }