コード例 #1
0
 /// <summary>
 /// カメラがシーンにレンダリング後に呼ばれる
 /// </summary>
 void OnRenderObject()
 {
     if (live2DModel == null)
     {
         return;
     }
     live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
     // アプリが終了していた場合
     if (!Application.isPlaying)
     {
         live2DModel.update();
         live2DModel.draw();
         return;
     }
     // 再生中のモーションからモデルパラメータを更新
     if (motionManager != null)
     {
         motionManager.updateParam(live2DModel);
     }
     // ポーズの設定
     if (pose != null)
     {
         pose.updateParam(live2DModel);
     }
     // 物理演算の設定
     if (physics != null)
     {
         physics.updateParam(live2DModel);
     }
     // 頂点の更新
     live2DModel.update();
     // モデルの描画
     live2DModel.draw();
 }
コード例 #2
0
    void OnRenderObject()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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

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

        motionMgr.updateParam(live2DModel);

        live2DModel.update();
        live2DModel.draw();
    }
コード例 #3
0
ファイル: SimpleModel.cs プロジェクト: johndpope/ToiletGod
    void Update()
    {
        if (live2DModel == null)
        {
            load();
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        if (!Application.isPlaying)
        {
            live2DModel.update();
            //motionManager.updateParam (live2DModel);
            return;
        }

        /*
         * var pos = Input.mousePosition;
         * if (Input.GetMouseButtonDown(0))
         * {
         * //
         * }
         * else if (Input.GetMouseButton(0))
         * {
         * dragMgr.Set(pos.x / Screen.width * 2 - 1, pos.y / Screen.height * 2 - 1);
         * }
         * else if (Input.GetMouseButtonUp(0))
         * {
         * dragMgr.Set(0, 0);
         * }
         */


        dragMgr.update();
        live2DModel.setParamFloat("PARAM_ANGLE_X", dragMgr.getX() * 30);
        live2DModel.setParamFloat("PARAM_ANGLE_Y", dragMgr.getY() * 30);

        live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", dragMgr.getX() * 10);

        live2DModel.setParamFloat("PARAM_EYE_BALL_X", -dragMgr.getX());
        live2DModel.setParamFloat("PARAM_EYE_BALL_Y", -dragMgr.getY());

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

        eyeBlink.setParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }

        if (motionManager.isFinished())
        {
            StartCoroutine(FadeModel(0, 1));
        }
        live2DModel.update();
        motionManager.updateParam(live2DModel);
    }
コード例 #4
0
    private IEnumerator Routine_Main()
    {
        while (true)
        {
            while (true)
            {
                if (live2DModel == null)
                {
                    break;
                }
                live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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

                if (motionMgr.isFinished() || main != _State)
                {
                    //歩き
                    if (_State == EnemyState.Walk)
                    {
                        motionMgr.startMotion(motions[0]);
                    }
                }

                if (main != _State)
                {
                    //噛みつき
                    if (_State == EnemyState.Attack)
                    {
                        motionMgr.startMotion(motions[1]);
                    }
                    //怯み
                    else if (_State == EnemyState.Stop)
                    {
                        motionMgr.startMotion(motions[2]);
                    }
                    //停止
                    if (_State == EnemyState.Wait)
                    {
                        motionMgr.startMotion(motions[3]);
                    }
                }

                main = _State;

                motionMgr.updateParam(live2DModel);
                live2DModel.update();
                live2DModel.draw();

                yield return(null);
            }
            yield return(null);
        }
    }
コード例 #5
0
    void Update()
    {
        if (live2DModel == null)
        {
            load();
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }

        var pos = Input.mousePosition;

        //滑鼠左鍵壓下事件
        if (Input.GetMouseButtonDown(0))
        {
            //
        }
        else if (Input.GetMouseButton(0))
        {
            dragMgr.Set(pos.x / Screen.width * 2 - 1, pos.y / Screen.height * 2 - 1);
        }
        else if (Input.GetMouseButtonUp(0))
        {
            dragMgr.Set(0, 0);
        }


        dragMgr.update();
        //臉部方向的調整
        live2DModel.setParamFloat("PARAM_ANGLE_X", dragMgr.getX() * 30);
        live2DModel.setParamFloat("PARAM_ANGLE_Y", dragMgr.getY() * 30);

        //身體方向調整
        live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", dragMgr.getX() * 10);

        //眼睛看的方向調整
        live2DModel.setParamFloat("PARAM_EYE_BALL_X", -dragMgr.getX());
        live2DModel.setParamFloat("PARAM_EYE_BALL_Y", -dragMgr.getY());

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

        eyeBlink.setParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }

        live2DModel.update();
    }
コード例 #6
0
        void Update()
        {
            //if (live2DModel == null) load();
            if (live2DModel == null)
            {
                return;
            }
            live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
            if (!Application.isPlaying)
            {
                live2DModel.update();
                return;
            }

            double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
            double t       = timeSec * 2 * Math.PI;

            live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

            //
            live2DModel.setParamFloat("PARAM_ANGLE_X", PARAM_ANGLE.x);
            live2DModel.setParamFloat("PARAM_ANGLE_Y", PARAM_ANGLE.y);
            live2DModel.setParamFloat("PARAM_ANGLE_Z", PARAM_ANGLE.z);
            live2DModel.setParamFloat("PARAM_EYE_L_OPEN", PARAM_EYE_L_OPEN);
            live2DModel.setParamFloat("PARAM_EYE_R_OPEN", PARAM_EYE_R_OPEN);
            live2DModel.setParamFloat("PARAM_EYE_BALL_X", PARAM_EYE_BALL_X);
            live2DModel.setParamFloat("PARAM_EYE_BALL_Y", PARAM_EYE_BALL_Y);
            live2DModel.setParamFloat("PARAM_BROW_L_Y", PARAM_BROW_L_Y);
            live2DModel.setParamFloat("PARAM_BROW_R_Y", PARAM_BROW_R_Y);
            live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", PARAM_MOUTH_OPEN_Y);
            live2DModel.setParamFloat("PARAM_MOUTH_SIZE", PARAM_MOUTH_SIZE);

            live2DModel.setParamFloat("PARAM_MOUTH_FORM", 0.0f);
            //

            if (physics != null)
            {
                physics.updateParam(live2DModel);
            }

            if (pose != null)
            {
                pose.updateParam(live2DModel);
            }


            live2DModel.update();
        }
コード例 #7
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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


        if (motionMgr.isFinished() || main != _State2)
        {
            //歩き
            if (_State2 == Enemy2State.Walk)
            {
                motionMgr.startMotion(motions[0]);
            }
        }

        if (main != _State2)
        {
            //噛みつき
            if (_State2 == Enemy2State.Attack)
            {
                motionMgr.startMotion(motions[1]);
            }
            //怯み
            else if (_State2 == Enemy2State.Stop)
            {
                motionMgr.startMotion(motions[2]);
            }
            //停止
            if (_State2 == Enemy2State.Wait)
            {
                motionMgr.startMotion(motions[3]);
            }
        }


        motionMgr.updateParam(live2DModel);
        live2DModel.update();
        live2DModel.draw();
    }
コード例 #8
0
        void Update()
        {
            if (live2DModel == null)
            {
                return;
            }
            live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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


            if (motionMgr.isFinished() || main != _State)
            {
                //歩き
                if (_State == Main.CharaState.Walk)
                {
                    live2DModel.setParamFloat("Param3", -1);
                    live2DModel.setParamFloat("Param7", 0);

                    motionMgr.startMotion(motions[0]);
                }
                //走り
                else if (_State == Main.CharaState.Run)
                {
                    live2DModel.setParamFloat("Param3", -1);
                    live2DModel.setParamFloat("Param7", 0);

                    motionMgr.startMotion(motions[1]);
                }
                //停止
                if (_State == Main.CharaState.Wait)
                {
                    //live2DModel.setParamFloat("Param3", -1);
                    motionMgr.startMotion(motions[2]);
                    //motionMgr.stopAllMotions();
                }
            }

            main = _State;

            motionMgr.updateParam(live2DModel);
            live2DModel.update();
            live2DModel.draw();
        }
コード例 #9
0
ファイル: Live2dSampleModel.cs プロジェクト: fctony/Live2d
    // Update is called once per frame
    void Update()
    {
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        motionQueueManager.updateParam(live2DModel);
        eyeBlinkMotion.setParam(live2DModel);

        live2DModel.update();
        if (GameManager.Instance.gameOver)
        {
            return;
        }
        //判断当前Boss是否追赶上翠花
        if ((missCui.transform.position.x - transform.position.x) < 3)
        {
            GameManager.Instance.gameOver = true;
        }

        if (isDefeat)
        {
            transform.position = Vector3.Lerp(transform.position, initPos, 0.2f);
        }
        else
        {
            transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);
        }
    }
コード例 #10
0
ファイル: Live2DModel.cs プロジェクト: Rinsunsama/Live2D
    // Update is called once per frame
    void Update()
    {
        live2DMode.setMatrix(transform.localToWorldMatrix * transformMar);
        motionManager.updateParam(live2DMode);

        Vector3 mousePos = Input.mousePosition;

        if (Input.GetMouseButton(0))
        {
            dragEff.Set(mousePos.x / Screen.width * 2 - 1, mousePos.y / Screen.height * 2 - 1);
        }

        if (Input.GetMouseButtonUp(0))
        {
            dragEff.Set(0, 0);
        }
        dragEff.update();
        if (dragEff.getX() != 0 && dragEff.getY() != 0)
        {
            live2DMode.setParamFloat("PARAM_ANGLE_X", dragEff.getX() * 30);
            live2DMode.setParamFloat("PARAM_ANGLE_Y", dragEff.getY() * 30);
            live2DMode.setParamFloat("PARAM_EYE_BALL_X", -dragEff.getX());
            live2DMode.setParamFloat("PARAM_EYE_BALL_Y", -dragEff.getY());
            live2DMode.setParamFloat("PARAM_BODY_ANGLE_X", 10 * dragEff.getX());
            live2DMode.setParamFloat("PARAM_BODY_ANGLE_Y", 10 * dragEff.getY());
        }
        live2DMode.update();
    }
コード例 #11
0
ファイル: L2DView.cs プロジェクト: linxscc/LoveGame
    void OnPostRender()
    {
        Live2DModelUnity live2DModel = (Live2DModelUnity)_model.getLive2DModel();
        var w = live2DModel.getCanvasWidth();
        var h = live2DModel.getCanvasHeight();

        L2DModelMatrix matrix = new L2DModelMatrix(w, h);

        matrix.setWidth(_w);
        matrix.setCenterPosition(0.5f, 0.5f);
        matrix.setX(_x);
        matrix.setY(_y);

        Matrix4x4 m1 = Matrix4x4.identity;

        float[] m2 = matrix.getArray();
        for (int i = 0; i < 16; i++)
        {
            m1[i] = m2[i];
        }

        live2DModel.setMatrix(m1);

        //_model.Update();_model.Draw 中有调用
        UpdateMouth();
        live2DModel.update();
        _model.Draw(Live2dViewType);
    }
コード例 #12
0
    void Update()
    {
        live2dModel.setMatrix(transform.localToWorldMatrix * live2dCanvasPos);
        if (l2dMotionManager.isFinished())
        {
            StartMotion(0, 1);
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            StartMotion(14, 2);
        }
        l2dMotionManager.updateParam(live2dModel);

        Vector3 pos = Input.mousePosition;

        drag.Set(pos.x / Screen.width * 2 - 1, pos.y / Screen.height * 2 - 1);
        live2dModel.setParamFloat("PARAM_ANGLE_X", 30 * drag.getX());
        live2dModel.setParamFloat("PARAM_BODY_ANGLE_X", 10 * drag.getX());
        live2dModel.setParamFloat("PARAM_EYE_BALL_X", -drag.getX());
        live2dModel.setParamFloat("PARAM_EYE_BALL_Y", -drag.getY());
        drag.update();

        long time = UtSystem.getUserTimeMSec();

        physicHairSide.update(live2dModel, time);
        if (Input.GetKeyDown(KeyCode.Space))
        {
            motionIndex = (motionIndex + 1 >= expressionMotions.Length ? 0 : motionIndex + 1);
            //expressionMotions[motionIndex].setLoop(true);
            motionQueueManager.startMotion(expressionMotions[motionIndex]);
        }
        motionQueueManager.updateParam(live2dModel);
        live2dModel.update();
    }
コード例 #13
0
    // Update is called once per frame
    void Update()
    {
        model.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        motionQueueManager.updateParam(model);
        eyeBlinkMotion.setParam(model);

        model.update();
        if (GameManager.Instance.isGameOver)
        {
            return;
        }
        if ((missCui.transform.position.x - transform.position.x) < 3)
        {
            GameManager.Instance.isGameOver = true;
            GameManager.Instance.isCatched  = true;
        }
        if (isDefeat)
        {
            transform.position = Vector3.Lerp(transform.position, initPos, 0.1f);
            Destroy(gameObject);
        }
        else
        {
            transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);
        }
    }
コード例 #14
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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



        double t = (UtSystem.getUserTimeMSec() / 1000.0) * 2 * Math.PI;

        if (Input.GetMouseButtonUp(0))
        {
            mouthcheck = !mouthcheck;
        }

        //テキストを読み上げているか判定
        if (mouthcheck)
        {
            mouth = (float)Mathf.PingPong(time += mouthspeed, 1);           //口動かす
        }
        else
        {
            //徐々に口を閉じる
            if (mouth > 0)
            {
                mouth -= 0.1f;
            }
        }

        live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", mouth);        //口


        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.2345)), 1);        //呼吸


        eyeBlink.setParam(live2DModel);        //目ぱち
         
        live2DModel.update();
    }
コード例 #15
0
    void Update()
    {
        if (live2DModel == null && !Load())
        {
            return;
        }

        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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

        live2DModel.update();
    }
コード例 #16
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            live2DModel.draw();
            return;
        }
        float volume = 0;

        if (smoothing)
        {
            float currentVolume = GetCurrentVolume(GetComponent <AudioSource>());

            if (Mathf.Abs(lastVolume - currentVolume) < 0.2f)
            {
                volume = lastVolume * 0.9f + currentVolume * 0.1f;
            }
            else if (lastVolume - currentVolume > 0.2f)
            {
                volume = lastVolume * 0.7f + currentVolume * 0.3f;
            }
            else
            {
                volume = lastVolume * 0.2f + currentVolume * 0.8f;
            }
            lastVolume = volume;
        }
        else
        {
            volume = GetCurrentVolume(GetComponent <AudioSource>());
        }


        live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", volume * scaleVolume);


        live2DModel.update();
    }
コード例 #17
0
 void Update()
 {
     live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvansPos);
     if (EyeFlag)
     {
         DragMove();
     }
     live2DModel.update();
 }
コード例 #18
0
 private void OnPostRender()
 {
     if (live2DModelUnity == null)
     {
         return;
     }
     live2DModelUnity.setMatrix(base.transform.localToWorldMatrix * live2DCanvasPos);
     if (!IsStop || isOneDraw)
     {
         motionMgr.updateParam(live2DModelUnity);
         live2DModelUnity.update();
         live2DModelUnity.draw();
         isDrawed = true;
         if (motionMgr.isFinished() || isOneDraw)
         {
             isOneDraw = false;
         }
     }
 }
コード例 #19
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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

        double t = (UtSystem.getUserTimeMSec() / 1000.0) * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_ANGLE_X", (float)(30 * Math.Sin(t / 3.0)));

        live2DModel.update();
    }
コード例 #20
0
    void OnRenderObject()
    {
        if (live2DModel == null)
        {
            load();
        }

        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);


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

        dragMgr.update();
        live2DModel.setParamFloat("PARAM_ANGLE_X", dragMgr.getX() * 30);
        live2DModel.setParamFloat("PARAM_ANGLE_Y", dragMgr.getY() * 30);

        live2DModel.setParamFloat("PARAM_BODY_ANGLE_X", dragMgr.getX() * 10);

        live2DModel.setParamFloat("PARAM_EYE_BALL_X", -dragMgr.getX());
        live2DModel.setParamFloat("PARAM_EYE_BALL_Y", -dragMgr.getY());

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        live2DModel.setParamFloat("PARAM_BREATH", (float)(0.5f + 0.5f * Math.Sin(t / 3.0)));

        eyeBlink.setParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }

        live2DModel.update();
        live2DModel.draw();
    }
コード例 #21
0
    void Update()
    {
        if (_live2DModel == null)
        {
            _Load();
        }
        _live2DModel.setMatrix(transform.localToWorldMatrix * _live2DCanvasPos);

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

        double timeSec = UtSystem.getUserTimeMSec() / 1000.0;
        double t       = timeSec * 2 * Math.PI;

        _live2DModel.setParamFloat("PARAM_ANGLE_X", (float)(30f * Math.Sin(t / 3.0)));


        _live2DModel.update();
    }
コード例 #22
0
    void OnRenderObject()
    {
        Matrix4x4 m1 = Matrix4x4.Ortho(
            -200.0f, 200.0f,
            200.0f, -200.0f,
            -0.5f, 0.5f);
        Matrix4x4 m2 = transform.localToWorldMatrix;
        Matrix4x4 m3 = m2 * m1;

        live2DModel.setMatrix(m3);
        live2DModel.update();
        live2DModel.draw();
    }
コード例 #23
0
    void LateUpdate()
    {
        //모션이 끝남
        //모션을 1회 재생했을 때 해당 모션이 완전이 재생되고 종료되었는지는 isFinished 메소드로 체크 가능.
        if (l2dMotionManager.isFinished())
        {
            if (enableAnimationForIdle)
            {
                //idle 애니메이션을 재생하길 원하는 경우
                //기본 모션으로 바꿔준다.
                //l2dMotionManager.startMotion(motionDataManager.GetLiveMotion("IDLE"));
                StartIdleMotion();
                //isBreath = false;
            }
            else
            {
                //모션이 끝나긴 했는데, IDLE 애니메이션을 루프재생 하길 원치 않은 경우
                if (breathMotion != null)
                {
                    //숨쉬기 모션이 있으면 모션이 끝났을때, 모션의 마지막 프레임 자세를 간직한체 그 위에 숨쉬는 모습을 덧칠해줌.
                    l2dMotionManager.startMotion(breathMotion_, false);
                    isBreath = true;
                }
            }
        }


        if (isBreath)
        {
            l2dEyeBlink.updateParam(model);
        }


        //모션 매니저들이 자신들이 가진 모션의 속성들로 모델을 갱신
        l2dMotionManager.updateParam(model);
        l2dExpressioNMotionManager.updateParam(model);

        //만약 캐릭터가 말하는 중이면 입모양 움직여 주세요. 먼저 립싱크값 갱신
        SetLipSync();
        //그 다음에 갱신된 립싱크 값으로 입에 해당하는 속성의 값을 갱신합니다.
        model.setParamFloat(L2DStandardID.PARAM_MOUTH_OPEN_Y, lipSyncValue, 0.7f);


        l2dPhysics.updateParam(model);
        //포즈 업데이트
        l2dPose.updateParam(model);

        //그리고 최종 갱신.
        model.update();
    }
コード例 #24
0
ファイル: DemoAndMotion.cs プロジェクト: ydaniel1018/006805
    // 렌더링할 때 호출된다
    void OnRenderObject()
    {
        // Live2D 모델이 없으면 읽어들인다
        if (m_live2DModel == null)
        {
            load();
        }

        m_live2DModel.setMatrix(transform.localToWorldMatrix * m_live2DCanvasPos);

        // 만일 애플리케이션이 동작 중이 아니라면 모델을 업데이트하여 렌더링하고 돌아온다
        if (!Application.isPlaying)
        {
            m_live2DModel.update();
            m_live2DModel.draw();
            return;
        }

        Idle();          // 아래에 있는 Idle() 함수 내용을 실행하고 여기로 돌아온다
        Drag();          // 아래에 있는 Drag() 함수 내용을 실행하고 여기로 돌아온다 ※이것은 Idle()을 실행한 수에 실행해야 한다

        // 눈깜박임 처리
        m_eyeBlink.setParam(m_live2DModel);

        // 물리 연산 업데이트
        if (m_physics != null)
        {
            m_physics.updateParam(m_live2DModel);
        }

        // 모델 업데이트
        m_live2DModel.update();

        // 모델 렌더링
        m_live2DModel.draw();
    }
コード例 #25
0
    void Update()
    {
        if (live2DModel == null)
        {
            load();
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);
        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            this.gameObject.GetComponent <Animator> ().SetInteger("Motion", 1);
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            this.gameObject.GetComponent <Animator> ().SetInteger("Motion", 0);
        }

        live2DModel.update();
    }
コード例 #26
0
    void Update()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

        if (!Application.isPlaying)
        {
            live2DModel.update();
            return;
        }
        if (motionMgr.isFinished())
        {
            SetMotion(Live2DMotion.loadMotion(motionFiles[0].bytes));
        }

        //double t = (UtSystem.getUserTimeMSec() / 1000.0) * 2 * Math.PI;
        //live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", (float)(2 * Math.Sin(t / 0.5)));

        //Debug.Log(live2DModel.getParamFloat("PARAM_MOUTH_OPEN_Y"));
        motionMgr.updateParam(live2DModel);

        //live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", (float)(2 * Math.Sin(t / 0.5)));
        //Debug.Log(live2DModel.getParamFloat("PARAM_MOUTH_OPEN_Y"));
        /*先播放mtn文件,再setParamFloat,不然会被mtn文件覆盖*/
        if (!GameParam.isTalkEnd)
        {
            //Debug.Log(GameParam.amplitude);
            live2DModel.setParamFloat("PARAM_MOUTH_FORM", (float)1f);
            live2DModel.setParamFloat("PARAM_MOUTH_SIZE", (float)0.8f);
            live2DModel.setParamFloat("PARAM_MOUTH_OPEN_Y", (float)GameParam.amplitude);
        }
        live2DModel.update();
    }
コード例 #27
0
ファイル: L2D.cs プロジェクト: tudou167/MyCode
    void Update()
    {
        if (modelUnity == null)
        {
            return;
        }
        modelUnity.setMatrix(transform.localToWorldMatrix * matrix4X4);

        if (queueManager.isFinished())
        {
            queueManager.startMotion(dMotion);
        }
        queueManager.updateParam(modelUnity);
        modelUnity.update();
    }
コード例 #28
0
    private KrLive2DLipSync m_pLipSync              = null;                 // process for lip sync

    //:::::::::::::::::::::::::::::::::::::::::::::::::::::
    // UNITY FUNCTION
    //:::::::::::::::::::::::::::::::::::::::::::::::::::::
    // @Brief : Update
    void Update()
    {
        // Update motion parameter
        m_pIdleMotionManager.updateParam(m_pLive2dModel);
        m_pMotionManager.updateParam(m_pLive2dModel);

        LipSync();

        m_pLive2dModel.update();

        // Render type is Live2D.L2D_RENDER_DRAW_MESH
        if (m_pLive2dModel.getRenderMode() == Live2D.L2D_RENDER_DRAW_MESH)
        {
            m_pLive2dModel.draw();
        }
    }
コード例 #29
0
    public void Update()
    {
        float     modelWidth = live2DModel.getCanvasWidth();      //モデルのキャンバスの横幅
        Matrix4x4 m1         = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
        Matrix4x4 m2         = transform.localToWorldMatrix;
        Matrix4x4 m3         = m2 * m1;

        live2DModel.setMatrix(m3);

        //まばたきの間隔とモーションにかかる時間を設定
        eyeBlink.setInterval(6000);
        eyeBlink.setEyeMotion(100, 100, 100);
        eyeBlink.setParam(live2DModel);

        live2DModel.update();
    }
コード例 #30
0
ファイル: csDrake.cs プロジェクト: johndpope/game-1
    void Update()
    {
        float     modelWidth = live2DModel.getCanvasWidth();
        Matrix4x4 m1         = Matrix4x4.Ortho(
            0, modelWidth, modelWidth,
            0, -50.0f, 50.0f);
        Matrix4x4 m2 = transform.localToWorldMatrix;
        Matrix4x4 m3 = m2 * m1;

        motionManager.updateParam(live2DModel);
        if (live2DModel == null)
        {
            return;
        }

        live2DModel.setMatrix(m3);
        live2DModel.update();
    }