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