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); }
/** * モデルのパラメータを更新。 * @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]); } }
public ALive2DModel loadLive2DModel(string path) { var data = FileManager.LoadBin(path); var live2DModel = Live2DModelUnity.loadModel(data); return(live2DModel); }
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); }
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); } }
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); } }
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); } }
// 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); }
/// <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(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; } }
// 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); }
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(); }
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); } }
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); }
public void ReleaseModel() { if (live2DModel != null) { live2DModel.releaseModel(); live2DModel = null; } }
public ALive2DModel loadLive2DModel(string path) { path = path.Replace(".", "_"); var data = loadBytes(path); var live2DModel = Live2DModelUnity.loadModel(data); return(live2DModel); }
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)); }
// 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]); } }
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++; } }
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); }
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); } }
private void OnDestroy() { Mem.DelAry(ref textureFiles); if (live2DModelUnity != null) { live2DModelUnity.releaseModel(); } live2DModelUnity = null; motionMgr = null; motionFile = null; mocFile = null; textureFiles = null; motion = null; }
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); }
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++; } }
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); }
// 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 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); }
// 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); }
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); }
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]); }
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); }
//加载模型文件与贴图文件,并初始化画布 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("模型文件和贴图文件加载成功!"); }
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(); } }
// 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);*/ }
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); }
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); }
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); } }