コード例 #1
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);
 }
コード例 #2
0
    /**
     * モデルのパラメータを更新。
     * @param model
     */
    public void updateParam(ALive2DModel model)
    {
        if (model == null)
        {
            return;
        }

        //前回のモデルと同じではないので初期化が必要
        if (model != lastModel)
        {
            // パラメータインデックスの初期化
            initParam(model);
        }
        lastModel = (Live2DModelUnity)model;

        long  curTime      = UtSystem.getUserTimeMSec();
        float deltaTimeSec = ((lastTime == 0) ? 0 : (curTime - lastTime) / 1000.0f);

        lastTime = curTime;

        // 設定から時間を変更すると、経過時間がマイナスになることがあるので、経過時間0として対応。
        if (deltaTimeSec < 0)
        {
            deltaTimeSec = 0;
        }

        for (int i = 0; i < partsGroupList.Count; i++)
        {
            normalizePartsOpacityGroup(model, partsGroupList[i], deltaTimeSec);
            copyOpacityOtherParts(model, partsGroupList[i]);
        }
    }
コード例 #3
0
    public ALive2DModel loadLive2DModel(string path)
    {
        var data        = FileManager.LoadBin(path);
        var live2DModel = Live2DModelUnity.loadModel(data);

        return(live2DModel);
    }
コード例 #4
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);
    }
コード例 #5
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);
        }
    }
コード例 #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
ファイル: 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);
        }
    }
コード例 #8
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);
    }
コード例 #9
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]);
        }
コード例 #10
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;
        }
    }
コード例 #11
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);
    }
コード例 #12
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();
    }
コード例 #13
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);
            }
        }
コード例 #14
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);
    }
コード例 #15
0
 public void ReleaseModel()
 {
     if (live2DModel != null)
     {
         live2DModel.releaseModel();
         live2DModel = null;
     }
 }
コード例 #16
0
        public ALive2DModel loadLive2DModel(string path)
        {
            path = path.Replace(".", "_");

            var data        = loadBytes(path);
            var live2DModel = Live2DModelUnity.loadModel(data);

            return(live2DModel);
        }
コード例 #17
0
        public void ChangeCharacter(Live2DModelUnity Live2D, ShipModel model)
        {
            this.L2dBias            = new Vector3((float)model.Offsets.GetLive2dBias().x, (float)model.Offsets.GetLive2dBias().y, 0f);
            this.ShipIn             = new Vector3((float)model.Offsets.GetBoko(false).x, (float)model.Offsets.GetBoko(false).y, 0f);
            this.ShipIn2            = new Vector3((float)model.Offsets.GetCutinSp1_InBattle(false).x, (float)model.Offsets.GetCutinSp1_InBattle(false).y, 0f);
            this.ShipOut            = new Vector3(1300f, (float)model.Offsets.GetBoko(false).y, 0f);
            this.Render.mainTexture = SingletonMonoBehaviour <Live2DModel> .Instance.ChangeCharacter(Live2D, model);

            this.Render.width  = (int)((float)model.Offsets.GetLive2dSize().x * 1.25f);
            this.Render.height = model.Offsets.GetLive2dSize().y;
            base.get_transform().localPositionY((float)(model.Offsets.GetBoko(false).y + model.Offsets.GetLive2dBias().y));
        }
コード例 #18
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]);
        }
    }
コード例 #19
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++;
        }
    }
コード例 #20
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);
    }
コード例 #21
0
 private void load()
 {
     this.live2DModel = Live2DModelUnity.loadModel(this.mocFile.bytes);
     for (int i = 0; i < this.textureFiles.Length; i++)
     {
         this.live2DModel.setTexture(i, this.textureFiles[i]);
     }
     float right = this.live2DModel.getCanvasWidth();
     this.live2DCanvasPos = Matrix4x4.Ortho(0f, right, right, 0f, -50f, 50f);
     if (this.physicsFile != null)
     {
         this.physics = L2DPhysics.load(this.physicsFile.bytes);
     }
 }
コード例 #22
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;
 }
コード例 #23
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);
    }
コード例 #24
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++;
        }
    }
コード例 #25
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);
    }
コード例 #26
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;
    }
コード例 #27
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);
    }
コード例 #28
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);
    }
コード例 #29
0
    public Texture ChangeCharacter(Live2DModelUnity Live2D, ShipModel Ship)
    {
        motionMgr.stopAllMotions();
        NowMstID = Ship.MstId;
        int resourceMstId = Utils.GetResourceMstId(NowMstID);

        live2DModelUnity = Live2D;
        motionFile       = (ResourceManager.LoadResourceOrAssetBundle("Live2D/" + resourceMstId + "/" + resourceMstId + "_loop.mtn") as TextAsset);
        motion           = Live2DMotion.loadMotion(motionFile.bytes);
        motion.setLoop(loop: true);
        motionMgr.startMotion(motion);
        isDrawed = false;
        Play();
        isLive2DChange = ((!isLive2DModel) ? true : false);
        isLive2DModel  = true;
        return(myCamera.targetTexture);
    }
コード例 #30
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]);
    }
コード例 #31
0
ファイル: LAppModel.cs プロジェクト: zhixu/live2DTest
    public void loadModelData(string modelFile, string[] texFiles)
    {
        if (modelFile == null || texFiles == null)
        {
            return;
        }

        try
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Load model : " + modelFile);
            }


            TextAsset modelMoc = FileManager.loadTextAsset(modelFile);
            live2DModel = Live2DModelUnity.loadModel(modelMoc.bytes);


            for (int i = 0; i < texFiles.Length; i++)
            {
                var texPath = texFiles[i];
                if (LAppDefine.DEBUG_LOG)
                {
                    Debug.Log("Load texture " + texPath);
                }
                texPath = Regex.Replace(texPath, ".png$", "");//不要な拡張子を削除

                Texture2D texture = (Texture2D)Resources.Load(texPath, typeof(Texture2D));

                live2DModel.setTexture(i, texture);
            }
        }
        catch (IOException e)
        {
            Debug.Log(e.StackTrace);

            throw new Exception();
        }

        modelMatrix = new L2DModelMatrix(live2DModel.getCanvasWidth(), live2DModel.getCanvasHeight());
        modelMatrix.setWidth(2);
        modelMatrix.multScale(1, 1, -1);
        modelMatrix.setCenterPosition(0, 0);
    }
コード例 #32
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("模型文件和贴图文件加载成功!");
    }
コード例 #33
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();
        }
    }
コード例 #34
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);*/
    }
コード例 #35
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);
    }
コード例 #36
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);
    }
コード例 #37
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);
        }
    }