コード例 #1
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]);
        }
コード例 #2
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);
    }
コード例 #3
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();
    }
コード例 #4
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);
        }
    }
コード例 #5
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;
        }
    }
コード例 #6
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);
        }
    }
コード例 #7
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);
 }
コード例 #8
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);
        }
    }
コード例 #9
0
ファイル: live2d_setting.cs プロジェクト: johndpope/game-1
    // Use this for initialization
    void Start()
    {
        Live2D.init();

        motion = Live2DMotion.loadMotion(mtnFiles[0].bytes);

        motion.setLoop(true);

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

        motionManager = new MotionQueueManager();

        motionManager.startMotion(motion, false);

        live2DModel.setPartsOpacity("PARTS_WEAPON01", 0);
        live2DModel.setPartsOpacity("PARTS_WEAPON02", 0);
        live2DModel.setPartsOpacity("PARTS_WEAPON03", 0);
        live2DModel.setPartsOpacity("PARTS_WEAPON04", 0);
        live2DModel.setPartsOpacity("PARTS_WEAPON05", 0);
        live2DModel.setPartsOpacity("PARTS_WEAPON06", 0);
    }
コード例 #10
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);
    }
コード例 #11
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);
            }
        }
コード例 #12
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();
        //定义拖拽
    }
コード例 #13
0
ファイル: main.cs プロジェクト: ruumu/Unity
    // Use this for initialization
    void Start()
    {

        Live2D.init();

        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

        for (int i = 0; i < textures.Length; i++)
        {
            live2DModel.setTexture(i, textures[i]);
        }
    }
コード例 #14
0
ファイル: StandModel.cs プロジェクト: yukpiz/unity-live2d
    public void Start()
    {
        Live2D.init (); //Live2Dの初期化
        //mocファイルの読み込み
        live2DModel = Live2DModelUnity.loadModel (mocFile.bytes);

        //テクスチャファイルの読み込み
        int index = 0;
        foreach (Texture2D textureFile in textureFiles) {
            live2DModel.setTexture (index, textureFile);
            index++;
        }
    }
コード例 #15
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);
    }
コード例 #16
0
    public void Start()
    {
        Live2D.init();          //Live2Dの初期化
        //mocファイルの読み込み
        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

        //テクスチャファイルの読み込み
        int index = 0;

        foreach (Texture2D textureFile in textureFiles)
        {
            live2DModel.setTexture(index, textureFile);
            index++;
        }
    }
コード例 #17
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);
    }
コード例 #18
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);
    }
コード例 #19
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;
    }
コード例 #20
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);
    }
コード例 #21
0
ファイル: main1.cs プロジェクト: johndpope/game-1
    // Use this for initialization
    void OnEnable()
    {
        Live2D.init();

        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);

        for (int i = 0; i < textures.Length; i++)
        {
            live2DModel.setTexture(i, textures[i]);
        }
        motion = Live2DMotion.loadMotion(mtnFiles[0].bytes);
        motion.setLoop(true);

        motionManager = new MotionQueueManager();

        motionManager.startMotion(motion, false);
    }
コード例 #22
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]);
    }
コード例 #23
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("模型文件和贴图文件加载成功!");
    }
コード例 #24
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();
        }
    }
コード例 #25
0
    // Use this for initialization
    void Start()
    {
        Live2D.init();

        live2DModel = Live2DModelUnity.loadModel(mocFile.bytes);         //loads the Live2D model

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



        /*
         * modelMatrix = new L2DModelMatrix(live2DModel.getCanvasWidth(), live2DModel.getCanvasHeight());
         * modelMatrix.setWidth(2);
         * modelMatrix.multScale(1,1,-1);
         * modelMatrix.setCenterPosition(0, 0);*/
    }
コード例 #26
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);
    }
コード例 #27
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);
        }
コード例 #28
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);
    }
コード例 #29
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);
    }
コード例 #30
0
    // @Brief : Initialize
    // @Param : pMocFilePath        => Moc file path
    //        : pTexturePaths       => Texture paths
    //        : pMotionFilePaths    => Motion file paths
    //        : bFromResources      => From resources file
    public void Initialize(string pMocFilePath, string[] pTexturePaths, string[] pMotionFilePaths, bool bFromResources)
    {
        // Initialize live2d
        KrLive2DInitializer.Create();

        // Load model
        byte[] pMocFile = KrResources.LoadBytes(pMocFilePath, bFromResources);
        m_pLive2dModel = Live2DModelUnity.loadModel(pMocFile);

        // Set render mode
        // NOTE : 1. There are advantages and disadvantages depending on the type
        //        2. Each drawing timing is different
        // Ref : http://sites.cybernoids.jp/cubism2/sdk_tutorial/platform-setting/unity/csharp/render-mode
        m_pLive2dModel.setRenderMode(Live2D.L2D_RENDER_DRAW_MESH);

        for (int sIndex = 0; sIndex < pTexturePaths.Length; sIndex++)
        {
            Texture2D pTexture = KrResources.LoadTexture2D(pTexturePaths[sIndex], bFromResources);
            // Set Texture
            m_pLive2dModel.setTexture(sIndex, pTexture);
        }

        // Load Motion
        m_pMotionDatas = new Dictionary <string, byte[]>();
        for (int sIndex = 0; sIndex < pMotionFilePaths.Length; sIndex++)
        {
            m_pMotionDatas.Add(pMotionFilePaths[sIndex], KrResources.LoadBytes(pMotionFilePaths[sIndex], bFromResources));
        }
        m_pMotionManager = new MotionQueueManager();
        // Create idle motion
        m_pIdleMotionManager = new MotionQueueManager();
        // NOTE : Let the 0th position of the motion list be the idle motion
        m_pIdleMotion = Live2DMotion.loadMotion(pMotionFilePaths[0]);
        m_pIdleMotion.setLoop(true);
        m_pIdleMotionManager.startMotion(m_pIdleMotion, false);

        SetPosition(Vector3.zero);
    }
コード例 #31
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);
    }
コード例 #32
0
 private void ResetUI()
 {
     workUI.SetActive(false);
     talkLine.SetActive(false);
     actionBtns.SetActive(true);
     modelProxy.SetVisible(true);
     modelProxy.GetModel().SetExpression("f01");
     bgImg.sprite = dateSprites[0];
     leftDays--;
     if (leftDays == 5)
     {
         Invoke("CreateBadBoy", 2);
     }
     else if (leftDays == 10)
     {
         Live2DModelUnity live2DModelUnity = modelProxy.GetModel().GetLive2DModelUnity();
         live2DModelUnity.setTexture(2, missCuiNewCloth);
     }
     else if (leftDays == 0)
     {
         isGameOver = true;
     }
 }
コード例 #33
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);
    }
コード例 #34
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);
    }
コード例 #35
0
 //重置所有UI
 void ResetUI()
 {
     workUI.SetActive(false);
     talkLine.SetActive(false);
     actionBtns.SetActive(true);
     lAppModelProxy.SetVisible(true);
     lAppModelProxy.GetModel().SetExpression("f01");
     bgImage.sprite = dateSprites[0];
     haveDays--;
     if (haveDays == 5)
     {
         CreateBadBoy();
     }
     else if (haveDays == 10)
     {
         //换装
         Live2DModelUnity live2DModelUnity = lAppModelProxy.GetModel().GetLive2DModelUnity();
         live2DModelUnity.setTexture(2, girlNewClothes);
     }
     else if (haveDays == 0)
     {
         gameOver = true;
     }
 }
コード例 #36
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);
        }
    }