Example #1
0
    // 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);
    }
Example #2
0
    public void ani(int num)
    {
        switch (num)
        {
        case 0:    //대기
            motion = Live2DMotion.loadMotion(mtnFiles[num].bytes);
            motion.setLoop(true);
            motionManager.startMotion(motion, false);
            break;

        case 1:    //공격
            motion = Live2DMotion.loadMotion(mtnFiles[num].bytes);
            motionManager.startMotion(motion, false);
            break;

        case 2:    //죽음
            motion = Live2DMotion.loadMotion(mtnFiles[num].bytes);
            motionManager.startMotion(motion, false);
            break;

        case 3:    //방어
            motion = Live2DMotion.loadMotion(mtnFiles[num].bytes);
            motionManager.startMotion(motion, false);
            break;

        case 4:    //점프공격
            motion = Live2DMotion.loadMotion(mtnFiles[num].bytes);
            motionManager.startMotion(motion, false);
            break;
        }
    }
Example #3
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]);
        }
    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);
    }
Example #5
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);
        }
    }
 public void StartMotion(Live2DMotion rawMotionData)
 {
     rawMotionData.setFadeIn(motionFadeSpeed);
     rawMotionData.setFadeOut(motionFadeSpeed);
     l2dMotionManager.startMotionPrio(rawMotionData, 0);
     isBreath = false;
 }
Example #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);
 }
Example #8
0
 public void onIdle()
 {
     //iTween.MoveBy(gameObject, iTween.Hash("x", 1, "easeType", "", "loopType", "", "delay", .1));
     gameObject.GetComponent <live2d_setting>().motion = Live2DMotion.loadMotion(gameObject.GetComponent <live2d_setting>().mtnFiles[2].bytes);
     gameObject.GetComponent <live2d_setting>().motionManager.startMotion(gameObject.GetComponent <live2d_setting>().motion, false);
     enemyUP = 3;
 }
Example #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();
    }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        gameObject.GetComponent <live2d_setting>().motion = Live2DMotion.loadMotion(gameObject.GetComponent <live2d_setting>().mtnFiles[0].bytes);
        gameObject.GetComponent <live2d_setting>().motionManager.startMotion(gameObject.GetComponent <live2d_setting>().motion, false);
        if (Input.GetButtonDown("Fire1"))
        {
            //gameObject.GetComponent<main1>().mtnFiles[0].bytes =
            gameObject.GetComponent <live2d_setting>().motion = Live2DMotion.loadMotion(gameObject.GetComponent <live2d_setting>().mtnFiles[1].bytes);
            //gameObject.GetComponent<live2d_setting>().motion.setLoop(true);
            gameObject.GetComponent <live2d_setting>().motionManager.startMotion(gameObject.GetComponent <live2d_setting>().motion, false);
            enemyUP -= 1;
            if (enemyUP == 0)
            {
                onIdle();
            }

            Debug.Log("Fire1");
        }

        if (Input.GetButtonDown("Fire2"))
        {
            //motionManager.stopAllMotions();
            Debug.Log("Jump");
        }
    }
Example #11
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);
        }
    }
Example #12
0
    // 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);
    }
Example #13
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);
        }
    }
Example #14
0
    void OnRenderObject()
    {
        if (live2DModel == null)
        {
            return;
        }
        live2DModel.setMatrix(transform.localToWorldMatrix * live2DCanvasPos);

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

        // motion播完或是flag改變
        if (motionMgr.isFinished() || mtnBehaviour.changeflg == true)
        {
            // load motion
            motion = Live2DMotion.loadMotion(motionFile.bytes);
            // 播放motion
            motionMgr.startMotion(motion);
            // 設置flag為off
            mtnBehaviour.changeflg = false;
        }

        motionMgr.updateParam(live2DModel);

        live2DModel.update();
        live2DModel.draw();
    }
 // @Brief : Set motion
 // @Param : pMotionName => Motion name
 //        : bIsLoop     => Is loop motion
 public void SetMotion(string pMotionName, bool bIsLoop)
 {
     KrDebug.Assert(m_pMotionDatas.ContainsKey(pMotionName), "Motion is not registered. key = " + pMotionName, typeof(KrLive2DModel));
     byte[] pMotionData = m_pMotionDatas[pMotionName];
     m_pMotion = Live2DMotion.loadMotion(pMotionData);
     m_pMotion.setLoop(bIsLoop);
     m_pMotionManager.startMotion(m_pMotion, false);
 }
Example #16
0
    void Start()
    {
        live2DModel.init();
        motionMgr = new MotionQueueManager();
        motion    = Live2DMotion.loadMotion(motionFile.bytes);


        load();
    }
    public void StartIdleMotion()
    {
        if (idleMotion == null)
        {
            idleMotion = motionDataManager.GetIdleLiveMotion();
        }

        StartMotion(idleMotion);
    }
Example #18
0
    private void ChangeMotion(MotionType type, TextAsset motionFile)
    {
        motion = Live2DMotion.loadMotion(motionFile.bytes);
        bool loop = (type == MotionType.Loop) ? true : false;

        motion.setLoop(loop);
        NowMotion      = type;
        prevMotionFile = motionFile;
    }
Example #19
0
 //加载动作文件,并完成与动作有关的变量的初始化
 private void LoadMotion()
 {
     //读取动作文件
     motions = new Live2DMotion[mtnFiles.Length];
     for (int i = 0; i < mtnFiles.Length; i++)
     {
         motions[i] = Live2DMotion.loadMotion(mtnFiles[i].bytes);
     }
     print("动作文件加载成功!");
 }
 public Live2DMotion GetLiveMotion(string motionName)
 {
     foreach (var i in liveMotionMtnBytesFiles)
     {
         if (i.name == motionName)
         {
             return(Live2DMotion.loadMotion(i.bytes));
         }
     }
     return(null);
 }
Example #21
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++;
 }
    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;
    }
Example #23
0
 private void OnDestroy()
 {
     Mem.DelAry(ref textureFiles);
     if (live2DModelUnity != null)
     {
         live2DModelUnity.releaseModel();
     }
     live2DModelUnity = null;
     motionMgr        = null;
     motionFile       = null;
     mocFile          = null;
     textureFiles     = null;
     motion           = null;
 }
Example #24
0
    /// <summary>
    /// モーションのチェンジ
    /// </summary>
    /// <param name="storage">モーションファイル名</param>
    /// <param name="idle">アイドリング有無</param>
    public void Motion_change(string storage, string idle)
    {
        int cnt = 0;

        for (int m = 0; m < mtnFiles.Length; m++)
        {
            if (mtnFiles[m].name == storage)
            {
                break;
            }
            cnt++;
        }

        // アイドルフラグがONなら、指定したモーションをアイドリングさせる
        if (idle != "")
        {
            motioncnt = cnt;
        }

        /*
         * int cnt = 0;
         * string filenm = Regex.Replace (storage, ".bytes$","");
         * // モーションファイル名を検索
         * foreach (string mtnNm in mtnFilenms)
         * {
         *      if(mtnNm == filenm)
         * {
         * break;
         * }
         * cnt++;
         * }
         */

        // モーションのロードをする
        motion = Live2DMotion.loadMotion(mtnFiles[cnt].bytes);
        // フェードインの設定
        motion.setFadeIn(mtnFadeines[cnt]);
        // フェードアウトの設定
        motion.setFadeOut(mtnFadeoutes[cnt]);
        // モーション再生
        motionManager.startMotion(motion, false);
        // サウンドがあればボイス再生

        if (soundFiles[cnt] != null)
        {
            GetComponent <AudioSource>().clip = soundFiles[cnt];
            GetComponent <AudioSource>().Play();
        }
    }
Example #25
0
    void Start()
    {
        modelManager = GetComponent <LAppModelProxy>();
        live2DModel  = modelManager.GetModel().getLive2DModel();
        motionMgr    = new MotionQueueManager();
        motion       = Live2DMotion.loadMotion(motionFile.bytes);
        int i = 0;

        foreach (TextAsset t in motionFiles)
        {
            motions[i] = Live2DMotion.loadMotion(motionFiles[i].bytes);
            i++;
        }
        InvokeRepeating("RandomMotion", 10, 10);
    }
Example #26
0
    void Start()
    {
        Live2D.init();

        models = new List <Live2DModelUnity>();
        for (int i = 0; i < NUM_MODELS; i++)
        {
            models.Add(CreateModel());
        }

        if (mtnFile != null)
        {
            motion = Live2DMotion.loadMotion(mtnFile.bytes);
        }
    }
    // 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;
    }
    void Start()
    {
        motionMgr = new MotionQueueManager();

        if (modelComponent == null)
        {
            modelComponent = GetComponent <Live2DModelComponent>();
        }

        motions = new Live2DMotion[motionFiles.Length];
        for (int i = 0; i < motionFiles.Length; i++)
        {
            motions[i] = Live2DMotion.loadMotion(motionFiles[i].bytes);
        }
        currentMotionIndex = motionFiles.Length - 1;
    }
Example #29
0
    void Start()
    {
        modelManager = GetComponent <LAppModelProxy>();
        live2DModel  = modelManager.GetModel().getLive2DModel();
        motionMgr    = new MotionQueueManager();
        motion       = Live2DMotion.loadMotion(motionFile.bytes);

        target    = GameObject.FindGameObjectWithTag("Player");
        AtkMotion = Live2DMotion.loadMotion(AttackMotion.bytes);
        attack    = StartCoroutine(Attack());

        int Stage = PlayerPrefs.GetInt("stage", 1);

        Damage = 20 + (5 * Stage);
        HP     = 100 + (10 * Stage);
    }
Example #30
0
    // 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);
    }
    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);
    }