コード例 #1
0
    // @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);
    }
コード例 #2
0
    protected string m_pName = null;        // asset name

    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // CONSTRUCTOR
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // @Brief  : Constructor
    // @Param  : pPath          => Absolute path of Audio asset.
    //         : bFromResources => From resources file
    // @Return : KrWav instance
    public KrAudioDataFormat(string pPath, bool bFromResources)
    {
        m_pName = System.IO.Path.GetFileNameWithoutExtension(pPath);
        byte[] pBytes = KrResources.LoadBytes(pPath, bFromResources);
        ConvertBytes(pBytes);
    }