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(); }
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() { 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); }
// @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); }