コード例 #1
0
    // @Brief : OnDrawGizmos
    void OnDrawGizmos()
    {
        if (m_pLive2dModel != null)
        {
            float     fModelWidth      = m_pLive2dModel.getCanvasWidth();
            float     fModelHeight     = m_pLive2dModel.getCanvasHeight();
            Matrix4x4 mOrthoProjection = Matrix4x4.Ortho(0, fModelWidth, fModelWidth, 0, -50.0f, 50.0f);
            Matrix4x4 mWorldPosition   = transform.localToWorldMatrix;
            mWorldPosition[13] += (fModelHeight / fModelWidth) * mWorldPosition[5];

            Gizmos.color = Color.red;
            float     fWeight   = (fModelWidth / fModelWidth) * transform.lossyScale.y;
            float     fHeight   = (fModelHeight / fModelWidth) * transform.lossyScale.y;
            Vector3[] pVertices = new Vector3[4];
            pVertices[0] = new Vector3(mWorldPosition[12] + fWeight, mWorldPosition[13] + fHeight, mWorldPosition[14]);
            pVertices[1] = new Vector3(mWorldPosition[12] - fWeight, mWorldPosition[13] + fHeight, mWorldPosition[14]);
            pVertices[2] = new Vector3(mWorldPosition[12] - fWeight, mWorldPosition[13] - fHeight, mWorldPosition[14]);
            pVertices[3] = new Vector3(mWorldPosition[12] + fWeight, mWorldPosition[13] - fHeight, mWorldPosition[14]);

            Gizmos.DrawLine(pVertices[0], pVertices[1]);
            Gizmos.DrawLine(pVertices[1], pVertices[2]);
            Gizmos.DrawLine(pVertices[2], pVertices[3]);
            Gizmos.DrawLine(pVertices[3], pVertices[0]);
        }
    }
コード例 #2
0
ファイル: SimpleModel.cs プロジェクト: johndpope/ToiletGod
    void load()
    {
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

        // モーションのインスタンスの作成(mtnの読み込み)と設定
        motionAppeal = Live2DMotion.loadMotion(mtnFiles[0].bytes);
        motionAppeal.setFadeOut(5000);
        motionAppeal.setLoop(this.isMotionLoop);

        motionManager = new MotionQueueManager();        //モーション管理クラスの作成.
        //play
        motionManager.startMotion(motionAppeal, true);

        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);

        if (physicsFile != null)
        {
            physics = L2DPhysics.load(physicsFile.bytes);
        }
    }
コード例 #3
0
 private void setModel(Live2DModelUnity LModel)
 {
     if (live2DModelUnity != null)
     {
         if (isDontRelease)
         {
             live2DModelUnity = null;
         }
         else
         {
             live2DModelUnity.releaseModel();
         }
     }
     if (LModel != null)
     {
         live2DModelUnity = LModel;
     }
     else
     {
         live2DModelUnity = Live2DModelUnity.loadModel(mocFile.bytes);
     }
     for (int i = 0; i < textureFiles.Length; i++)
     {
         live2DModelUnity.setTexture(i, textureFiles[i]);
     }
     modelW          = live2DModelUnity.getCanvasWidth();
     modelH          = live2DModelUnity.getCanvasHeight();
     live2DCanvasPos = Matrix4x4.Ortho(0f, modelW, modelH, 0f, -50f, 50f);
     aspect          = modelH / modelW;
     motion          = Live2DMotion.loadMotion(motionFile.bytes);
     motion.setLoop(loop: true);
     motionMgr.startMotion(motion);
 }
コード例 #4
0
    void Load(byte[] moc, Texture2D[] textures, byte[] pose)
    {
        if (live2DModel != null)
        {
            live2DModel.releaseModel();
        }

        live2DModel = Live2DModelUnity.loadModel(moc);

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

        float modelWidth = live2DModel.getCanvasWidth();

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

        if (pose != null)
        {
            live2dPose = L2DPose.load(pose);
        }
        else
        {
            live2dPose = null;
        }
    }
コード例 #5
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);
    }
コード例 #6
0
        /// <summary>
        /// 外部初始化入口
        /// </summary>
        public void InitModel(byte[] modelDatas, byte[] animationDatas, Texture2D[] textures)
        {
            enabled = true;
            //载入模型
            live2DModel = Live2DModelUnity.loadModel(modelDatas);

            //载入贴图
            Texture2D texture2D = Resources.Load <Texture2D>("");

            live2DModel.setTexture(0, texture2D);
            for (int i = 0; i < textures.Length; i++)
            {
                live2DModel.setTexture(i, textures[i]);
            }
            float modelWidth = live2DModel.getCanvasWidth();

            live2DCanvansPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50, 50);

            //载入动作
            motions = new Live2DMotion[1];
            for (int i = 0; i < motions.Length; i++)
            {
                motions[i] = Live2DMotion.loadMotion(animationDatas);
            }
            motions[0].setLoopFadeIn(true);
            motions[0].setFadeOut(FadeOutTime);
            motions[0].setFadeIn(FadeInTime);
            motions[0].setLoop(true);

            //播放第一个动作
            motionQueueManager.startMotion(motions[0]);
        }
コード例 #7
0
        public void load()
        {
            if (mocFile != null)
            {
                live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

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

                float modelWidth = live2DModel.getCanvasWidth();
                live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
            }

            if (physicsFile != null)
            {
                physics = L2DPhysics.load(physicsFile.bytes);
            }

            if (poseFile != null)
            {
                pose = L2DPose.load(poseFile.bytes);
            }
        }
コード例 #8
0
ファイル: Live2DModel.cs プロジェクト: Rinsunsama/Live2D
    // Use this for initialization
    void Start()
    {
        Live2D.init();
        //Live2DModelUnity asset = Live2DModelUnity.loadModel(Application.dataPath + "/Resources/Epsilon/runtime/Epsilon.moc");
        live2DMode = Live2DModelUnity.loadModel(textAst.bytes);
        for (int i = 0; i < textures.Length; i++)
        {
            live2DMode.setTexture(i, textures[i]);
        }
        float canvasWidth = live2DMode.getCanvasWidth();

        transformMar = Matrix4x4.Ortho(0, canvasWidth, canvasWidth, 0, -50, 50);
        motions      = new Live2DMotion[motionFile.Length];
        for (int i = 0; i < motions.Length; i++)
        {
            motions[i] = Live2DMotion.loadMotion(motionFile[i].bytes);
        }
        motions[0].setLoopFadeIn(true);
        motions[0].setLoop(true);

        motionManager.startMotion(motions[0]);

        //眨眼
        eyeBlink.setParam(live2DMode);
    }
コード例 #9
0
    void Start()
    {
        motions = new Live2DMotion[motionFiles.Length];

        if (live2DModel != null)
        {
            return;
        }
        Live2D.init();

        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);
        live2DModel.setRenderMode(Live2D.L2D_RENDER_DRAW_MESH);

        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);

        for (int i = 0; i < motionFiles.Length; i++)
        {
            motions[i] = Live2DMotion.loadMotion(motionFiles[i].bytes);
        }

        motions[0].setLoop(true);
        motions[0].setLoopFadeIn(false);

        motionMgr = new MotionQueueManager();
    }
コード例 #10
0
ファイル: DemoAndMotion.cs プロジェクト: ydaniel1018/006805
    void load()
    {
        // .moc.bytes 파일을 불러와서 설정한다
        m_live2DModel = Live2DModelUnity.loadModel(m_mocFile.bytes);

        // 텍스쳐 파일 수만큼 읽어들여 설정한다
        for (int i = 0; i < m_textureFiles.Length; i++)
        {
            m_live2DModel.setTexture(i, m_textureFiles[i]);
        }

        // 캔버스 준비
        float modelWidth = m_live2DModel.getCanvasWidth();

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

        // 물리 설정 파일이 비어 있으면 불러온다
        if (m_physicsFile != null)
        {
            m_physics = L2DPhysics.load(m_physicsFile.bytes);
        }

        // 모션 관리용 변수를 준비한다
        m_motionMgr = new MotionQueueManager();

        // 메션 파일 수만큼 모션 관리용 배열을 확보한다
        m_motions = new Live2DMotion[m_motionFiles.Length];
        // 모션 파일 수만큼 모션을 읽어들인다
        for (int i = 0; i < m_motionFiles.Length; i++)
        {
            m_motions[i] = Live2DMotion.loadMotion(m_motionFiles[i].bytes);
        }
    }
コード例 #11
0
    void Start()
    {
        Live2D.init();
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);


        live2DModel.setRenderMode(Live2D.L2D_RENDER_DRAW_MESH);
        live2DModel.setLayer(gameObject.layer);


        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();
        if (motionFile != null)
        {
            motion = Live2DMotion.loadMotion(motionFile.bytes);
        }
    }
コード例 #12
0
    void load()
    {
        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);

        if (physicsFile != null)
        {
            physics = L2DPhysics.load(physicsFile.bytes);
        }

        motionMgr    = new MotionQueueManager();
        motionBattle = Live2DMotion.loadMotion(idleMotionFile[0].bytes);
        motionPort   = Live2DMotion.loadMotion(idleMotionFile[1].bytes);
        motionSecret = Live2DMotion.loadMotion(idleMotionFile[2].bytes);
        //motionLoop = Live2DMotion.loadMotion(motionFile[3].bytes);
        //motionВерныйOne = Live2DMotion.loadMotion(motionFile[4].bytes);
        //motionВерныйNewYear = Live2DMotion.loadMotion(motionFile[5].bytes);
        //motionTwoHour = Live2DMotion.loadMotion(motionFile[6].bytes);
    }
コード例 #13
0
ファイル: Live2DSimpleModel.cs プロジェクト: kesumu/dokidoki
    void load()
    {
        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*zoom, modelWidth*zoom, 0, -50.0f, 50.0f);

        if (physicsFile != null) physics = L2DPhysics.load(physicsFile.bytes);
    }
コード例 #14
0
    void Start()
    {
        Live2D.init();

        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);
    }
コード例 #15
0
ファイル: SimpleModel.cs プロジェクト: kreeds/TestProjectDemo
    void load()
    {
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);
        live2DModel.setRenderMode (Live2D.L2D_RENDER_DRAW_MESH);

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

        float modelWidth = live2DModel.getCanvasWidth();
        live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -2.0f, 2.0f);

        if (physicsFile != null) physics = L2DPhysics.load(physicsFile.bytes);
    }
コード例 #16
0
    void load()
    {
        //讀取model資料
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

        for (int i = 0; i < textureFiles.Length; i++)
        {
            //將texture與model關聯起來
            live2DModel.setTexture(i, textureFiles[i]);
        }

        //指定live2dmodel的描繪位置
        float modelWidth = live2DModel.getCanvasWidth();

        live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
    }
コード例 #17
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();
    }
コード例 #18
0
    // Start is called before the first frame update
    void Start()
    {
        Live2D.init();
        live2DModel = Live2DModelUnity.loadModel(modelFile.bytes);
        live2DModel.setTexture(0, texture);
        float modelWidth = live2DModel.getCanvasWidth();

        live2DCanvansPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50, 50);

        live2DmotionIdle = Live2DMotion.loadMotion(idleMotionFile.bytes);

        live2DmotionIdle.setLoop(true);

        motionQueueManager.startMotion(live2DmotionIdle);
        initPos = transform.position;
    }
コード例 #19
0
    private int motioncnt = 0;                                          // ファイル項番


    /// <summary>
    /// 初期化処理
    /// </summary>
    void Start()
    {
        // JSONを読込
        Json_Read();
        // Live2D初期化
        Live2D.init();
        // モーション管理クラスのインスタンス
        motionManager = new MotionQueueManager();
        // モーションのインスタンス
        motion = Live2DMotion.loadMotion(mtnFiles[0].bytes);
        // モーションの再生
        motionManager.startMotion(motion, false);
        // 表示位置
        float modelWidth = live2DModel.getCanvasWidth();

        live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
    }
コード例 #20
0
    void Start()
    {
        //初始化环境
        Live2D.init();
        //string path = Application.dataPath + "/Resources/Epsilon/runtime/Epsilon.moc";
        //Live2DModelUnity.loadModel(path);
        //加载模型文件
        live2dModel = Live2DModelUnity.loadModel(modelTxt.bytes);
        for (int i = 0; i < texture2d.Length; i++)
        {
            live2dModel.setTexture(i, texture2d[i]);
        }
        float modelWidth = live2dModel.getCanvasWidth();

        live2dCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50, 50);

        //加载模型动作文件
        motions = new Live2DMotion[motionTxt.Length];
        for (int i = 0; i < motions.Length; i++)
        {
            motions[i] = Live2DMotion.loadMotion(motionTxt[i].bytes);
        }
        l2dMotionManager = new L2DMotionManager();

        expressionMotions = new L2DExpressionMotion[expressionTxt.Length];
        for (int i = 0; i < expressionMotions.Length; i++)
        {
            expressionMotions[i] = L2DExpressionMotion.loadJson(expressionTxt[i].bytes);
        }

        eyeBlinkMotion = new EyeBlinkMotion();
        eyeBlinkMotion.setParam(live2dModel);
        drag           = new L2DTargetPoint();
        physicHairBack = new PhysicsHair();
        physicHairSide = new PhysicsHair();
        physicHairSide.setup(0.2f, 0.5f, 0.14f);
        PhysicsHair.Src srcX = PhysicsHair.Src.SRC_TO_X;                  //横向摇摆
        physicHairSide.addSrcParam(srcX, "PARAM_ANGLE_X", 0.005f, 1);
        PhysicsHair.Target target = PhysicsHair.Target.TARGET_FROM_ANGLE; //表现形式
        physicHairSide.addTargetParam(target, "PARAM_HAIR_SIDE_L", 0.005f, 1);

        //motions[0].setLoop(true);
        motionQueueManager = new MotionQueueManager();
        //motionQueueManager.startMotion(motions[0]);
    }
コード例 #21
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();
    }
コード例 #22
0
    //加载模型文件与贴图文件,并初始化画布
    private void LoadModelAndTextures()
    {
        //读取模型,bytes形式读取
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

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

        //初始化显示的画布,后面的参数一定不要错,😭
        float modelWidth = live2DModel.getCanvasWidth();

        live2DCancasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50, 50);

        print("模型文件和贴图文件加载成功!");
    }
コード例 #23
0
    void Start()
    {
        //Live2D.init();

        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);
        if (motionMgr == null)
        {
            motionMgr = new MotionQueueManager();
        }
    }
コード例 #24
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);
    }
コード例 #25
0
    void Start()
    {
        Live2D.init();

        String dataDir = Application.streamingAssetsPath + "/";

        live2DModel = Live2DModelUnity.loadModel(dataDir + MODEL_PATH);

        for (int i = 0; i < TEXTURE_PATHS.Length; i++)
        {
            var texture = TextureUtil.LoadTexture(dataDir + TEXTURE_PATHS [i]);


            live2DModel.setTexture(i, texture);
        }

        float modelWidth = live2DModel.getCanvasWidth();

        live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
    }
コード例 #26
0
        public void setMocFileFromBytes(byte[] bytes)
        {
            if (bytes.Length == 0)
            {
                return;
            }
            live2DModel = Live2DModelUnity.loadModel(bytes);

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

            float modelWidth = live2DModel.getCanvasWidth();

            live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
        }
コード例 #27
0
    //程序入口点
    private void initModel()
    {
        Live2D.init();
        //初始化
        //Live2DModelUnity.loadModel(Application.dataPath + /*root*/"/Md/AyaX/aya_live_sr01_t03.moc");
        live2DModel = Live2DModelUnity.loadModel(modelFile.bytes);
        Texture2D texture2D = Resources.Load <Texture2D>("");

        //载入模型
        live2DModel.setTexture(0, texture2D);
        for (int i = 0; i < textures.Length; i++)
        {
            live2DModel.setTexture(i, textures[i]);
        }
        //循环取值贴图
        float modelWidth = live2DModel.getCanvasWidth();

        live2DCanvansPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50, 50);
        //加载贴图材质
        //live2DMotionIdle = Live2DMotion.loadMotion(Application.dataPath + "/Md/AyaX/idle01.mtn");
        //TextAsset mtnFile = Resources.Load<TextAsset>("");
        //live2DMotionIdle = Live2DMotion.loadMotion(mtnFile.bytes);
        //指定默认动作
        motions = new Live2DMotion[motionFile.Length];
        for (int i = 0; i < motions.Length; i++)
        {
            motions[i] = Live2DMotion.loadMotion(motionFile[i].bytes);
        }
        //循环取值动作文件
        motions[0].setLoopFadeIn(true);
        motions[0].setFadeOut(2000);
        motions[0].setFadeIn(2000);
        motions[0].setLoop(true);
        //默认动作行为
        motionQueueManager = new MotionQueueManager();
        //新建动作队列
        motionQueueManager.startMotion(motions[0]);
        //加载动作队列第一个
        drag = new L2DTargetPoint();
        //定义拖拽
    }
コード例 #28
0
    public Live2DModelUnity CreateLive2DModelUnity(int MstID)
    {
        Texture2D[]      array            = new Texture2D[4];
        int              resourceMstId    = Utils.GetResourceMstId(MstID);
        string           path             = "Live2D/" + resourceMstId + "/" + resourceMstId + ".moc";
        TextAsset        textAsset        = Resources.Load(path) as TextAsset;
        Live2DModelUnity live2DModelUnity = Live2DModelUnity.loadModel(textAsset.bytes);

        for (int i = 0; i < 4; i++)
        {
            array[i] = Resources.Load <Texture2D>("Live2D/" + MstID + "/texture_0" + i);
        }
        for (int j = 0; j < textureFiles.Length; j++)
        {
            live2DModelUnity.setTexture(j, array[j]);
        }
        modelW          = live2DModelUnity.getCanvasWidth();
        modelH          = live2DModelUnity.getCanvasHeight();
        live2DCanvasPos = Matrix4x4.Ortho(0f, modelW, modelH, 0f, -50f, 50f);
        aspect          = modelH / modelW;
        return(live2DModelUnity);
    }
コード例 #29
0
    void _Load()
    {
        _live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);


        _live2DModel.setTexture(0, textureFile);

        _layout = TextureAtlasLayout.loadJson(layoutFile.bytes);

        var frames = _layout.getFrames();
        int n      = frames.Count;

        for (int i = 0; i < n; i++)
        {
            var item = frames [i];
            _SetTextureMap(i, 0, _layout.width, _layout.height, item.srcWidth, item.srcHeight, item.x, item.y, item.trimX, item.trimY);
        }


        float modelWidth = _live2DModel.getCanvasWidth();

        _live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
    }
コード例 #30
0
    void load()
    {
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

		// モーションのインスタンスの作成(mtnの読み込み)と設定
		motionAppeal = Live2DMotion.loadMotion( mtnFiles[ 0 ].bytes );
		motionAppeal.setFadeOut (5000);
		motionAppeal.setLoop( this.isMotionLoop );

		motionManager = new MotionQueueManager();//モーション管理クラスの作成.
		//play
		motionManager.startMotion(motionAppeal,true);

        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);

        if (physicsFile != null) physics = L2DPhysics.load(physicsFile.bytes);
    }
コード例 #31
0
ファイル: live2d_setting.cs プロジェクト: johndpope/game-1
    void Update()
    {
        //if (Input.GetButtonDown("Fire1"))
        //{
        //    motion = Live2DMotion.loadMotion(mtnFiles[2].bytes);
        //    //motion.setLoop(true);
        //    motionManager.startMotion(motion, false);
        //    Debug.Log("Fire1");
        //    //motionoff = true;
        //}
        //if (Input.GetButtonDown("Fire2"))
        //{
        //    motion = Live2DMotion.loadMotion(mtnFiles[1].bytes);
        //    //motion.setLoop(true);
        //    motionManager.startMotion(motion, false);
        //   // motionManager.stopAllMotions();
        //    Debug.Log("Jump");
        //   // motionoff = true;
        //}


        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.setParamFloat("PARAM_WEAPON01", 1.0f);
        live2DModel.setMatrix(m3);
        live2DModel.update();
    }
コード例 #32
0
    public bool mouthcheck = false; //テキストを読み上げているかいないか
    void Start()
    {
        //live2d初期化
        if (live2DModel != null)
        {
            return;
        }
        Live2D.init();

        //テクスチャー読み込み
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

        //テクスチャー読み込み
        for (int i = 0; i < textureFiles.Length; i++)
        {
            live2DModel.setTexture(i, textureFiles[i]);
        }

        //モデルの幅を獲得
        float modelWidth = live2DModel.getCanvasWidth();

        //canvas作成
        live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);
    }
コード例 #33
0
    void load()
    {
        // .moc.bytesファイルをロードしてセット
        m_live2DModel = Live2DModelUnity.loadModel(m_mocFile.bytes);

        // テクスチャのファイル数だけ読み込んでセット
        for (int i = 0; i < m_textureFiles.Length; i++)
        {
            m_live2DModel.setTexture(i, m_textureFiles[i]);
        }

        // キャンバスを用意
        float modelWidth = m_live2DModel.getCanvasWidth();
        m_live2DCanvasPos = Matrix4x4.Ortho(0, modelWidth, modelWidth, 0, -50.0f, 50.0f);

        // 物理設定ファイルが空ならロード
        if (m_physicsFile != null) m_physics = L2DPhysics.load(m_physicsFile.bytes);

        // モーション管理用変数を用意
        m_motionMgr = new MotionQueueManager();

        // モーションファイルの数だけモーション管理用配列を確保
        m_motions = new Live2DMotion[m_motionFiles.Length];
        // モーションファイルの数だけモーションを読み込み
        for (int i = 0; i < m_motionFiles.Length; i++)
        {
            m_motions[i] = Live2DMotion.loadMotion(m_motionFiles[i].bytes);
        }
    }
コード例 #34
0
    void Start()
    {
        //初始化
        Live2D.init();

        //读取模型
        //Live2DModelUnity.loadModel(Application.dataPath+"/Resources/Epsilon/runtime/Epsilon.moc");

        //第二种读取形式
        //TextAsset mocFile = Resources.Load<TextAsset>("Epsilon/runtime/Epsilon.moc");
        live2DModel = Live2DModelUnity.loadModel(modelFile.bytes);
        #region
        //与贴图建立关联
        //Texture2D texture2D1 = Resources.Load<Texture2D>("Epsilon/runtime/Epsilon.1024/texture_00");
        //Texture2D texture2D2 = Resources.Load<Texture2D>("Epsilon/runtime/Epsilon.1024/texture_01");
        //Texture2D texture2D3 = Resources.Load<Texture2D>("Epsilon/runtime/Epsilon.1024/texture_02");

        //live2DModel.setTexture(0,texture2D1);
        //live2DModel.setTexture(1,texture2D2);
        //live2DModel.setTexture(2,texture2D3);
        #endregion
        for (int i = 0; i < textures.Length; i++)
        {
            live2DModel.setTexture(i, textures[i]);
        }

        //指定显示位置与尺寸
        float modelWidth = live2DModel.getCanvasWidth();

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

        //播放动作
        //实例化动作
        //live2DMotionIdle = Live2DMotion.loadMotion(Application.dataPath + "/Resources/Epsilon/runtime/motions/Epsilon_idle_01");
        motions = new Live2DMotion[motionFiles.Length];
        for (int i = 0; i < motionFiles.Length; i++)
        {
            motions[i] = Live2DMotion.loadMotion(motionFiles[i].bytes);
        }
        #region
        //设置某一动画的一些属性
        //重复播放不淡入
        motions[0].setLoopFadeIn(false);
        motions[0].setFadeOut(1000);//毫秒
        motions[0].setFadeIn(1000);
        motions[0].setLoop(true);

        //motionQueueManager = new MotionQueueManager();
        //motionQueueManager.startMotion(motions[motionIndex]);

        //motions[5].setLoop(true);
        //motionQueueManagerB = new MotionQueueManager();
        //motionQueueManagerB.startMotion(motions[5]);
        #endregion

        //动作优先级使用
        motionManager = new L2DMotionManager();

        //眨眼
        eyeBlinkMotion = new EyeBlinkMotion();

        drag = new L2DTargetPoint();
        #region 头发物理效果处理
        sideHairLeft  = new PhysicsHair();
        sideHairRight = new PhysicsHair();
        backHairLeft  = new PhysicsHair();
        backHairRight = new PhysicsHair();

        //套用物理运算
        sideHairLeft.setup(0.2f, 0.5f, 0.14f);
        sideHairRight.setup(0.2f, 0.5f, 0.14f);
        PhysicsHair.Src srcX = PhysicsHair.Src.SRC_TO_X;//横向摇摆
        PhysicsHair.Src srcZ = PhysicsHair.Src.SRC_TO_G_ANGLE;

        sideHairLeft.addSrcParam(srcX, "PARAM_ANGLE_X", 0.005f, 1);
        sideHairRight.addSrcParam(srcX, "PARAM_ANGLE_X", 0.005f, 1);

        backHairLeft.setup(0.24f, 0.5f, 0.18f);
        backHairRight.setup(0.24f, 0.5f, 0.18f);

        backHairLeft.addSrcParam(srcX, "PARAM_ANGLE_X", 0.005f, 1);
        backHairLeft.addSrcParam(srcZ, "PARAM_ANGLE_Z", 0.8f, 1);
        backHairRight.addSrcParam(srcX, "PARAM_ANGLE_X", 0.005f, 1);
        backHairRight.addSrcParam(srcZ, "PARAM_ANGLE_Z", 0.8f, 1);

        //设置输出表现
        PhysicsHair.Target target = PhysicsHair.Target.TARGET_FROM_ANGLE;
        sideHairLeft.addTargetParam(target, "PARAM_HAIR_SIDE_L", 0.005f, 1);
        sideHairRight.addTargetParam(target, "PARAM_HAIR_SIDE_R", 0.005f, 1);
        backHairLeft.addTargetParam(target, "PARAM_HAIR_BACK_L", 0.005f, 1);
        backHairRight.addTargetParam(target, "PARAM_HAIR_BACK_R", 0.005f, 1);
        #endregion

        //表情
        expressionManager = new MotionQueueManager();
        expressions       = new L2DExpressionMotion[expressionFiles.Length];
        for (int i = 0; i < expressionFiles.Length; i++)
        {
            expressions[i] = L2DExpressionMotion.loadJson(expressionFiles[i].bytes);
        }
    }