Ejemplo n.º 1
0
 //:::::::::::::::::::::::::::::::::::::::::::::::::::::
 // PUBLIC FUNCTION
 //:::::::::::::::::::::::::::::::::::::::::::::::::::::
 // @Brief  : Create
 // @Return : KrLive2DInitializer instance
 public static KrLive2DInitializer Create()
 {
     if (I == null)
     {
         GameObject pPrefab = KrResources.LoadDataInApp <GameObject>("Prefabs/Live2DInitializer");
         Instantiate(pPrefab);
     }
     return(I);
 }
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // PUBLIC FUNCTION
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // @Brief  : Create
    // @Param  : pParent        => Charageki manager parent
    //         : pScripts       => Script paths
    //         : pCharaParent   => Character parent
    //         : eViewMode      => Character display mode
    //         : fAutoTime      => Wait time after completion of processing of auto mode
    //         : pAssetBasePath => Asset base path
    //         : pServerBaseUrl => Server base url
    // @Return : KrCharagekiManager instance
    public static KrCharagekiManager Create(Transform pParent, string[] pScripts, Transform pCharaParent, KrCharagekiUICharacterContainer.eVIEW_MODE eViewMode, float fAutoTime, string pAssetBasePath = "", string pServerBaseUrl = "")
    {
        GameObject pPrefab = KrResources.LoadDataInApp <GameObject>(c_pPREFAB_PATH);
        GameObject pObj    = Instantiate <GameObject>(pPrefab, pParent);

        pObj.SetActive(true);
        KrCharagekiManager pManager = pObj.GetComponent <KrCharagekiManager>();

        pManager.Initialize(pScripts, pCharaParent, eViewMode, fAutoTime, pAssetBasePath, pServerBaseUrl);
        return(pManager);
    }
    // @Brief  : Create
    // @Param  : pParent    => Object parent
    //           pData      => Character data
    // @Return : KrCharagekiUI2DCharacter instance
    public static KrCharagekiUILive2DCharacter Create(Transform pParent, KrCharagekiUICharacterData pData)
    {
        GameObject pPrefab = KrResources.LoadDataInApp <GameObject>(c_pPREFAB_PATH);
        GameObject pObject = Instantiate <GameObject>(pPrefab);

        pObject.transform.SetParent(pParent, false);
        KrCharagekiUILive2DCharacter pCharacter = pObject.GetComponent <KrCharagekiUILive2DCharacter>();

        pCharacter.Initialize(pData);
        return(pCharacter);
    }
    //:::::::::::::::::::::::::::::::::::::::::::::::::::::
    // PUBLIC FUNCTION
    //:::::::::::::::::::::::::::::::::::::::::::::::::::::
    // @Brief : Create
    // @Param : pMocFilePath        => Moc file path
    //        : pTexturePaths       => Texture paths
    //        : pMotionFilePaths    => Motion file paths
    //        : bFromResources      => From resources file
    //        : pParent             => Object parent
    public static KrLive2DModel Create(string pMocFilePath, string[] pTexturePaths, string[] pMotionFilePaths, bool bFromResources, Transform pParent = null)
    {
        GameObject pPrefab = KrResources.LoadDataInApp <GameObject>("Prefabs/Live2DModel");
        GameObject pObject = Instantiate(pPrefab);

        pObject.transform.SetParent(pParent);

        KrLive2DModel pLive2DModel = pObject.GetComponent <KrLive2DModel>();

        pLive2DModel.Initialize(pMocFilePath, pTexturePaths, pMotionFilePaths, bFromResources);

        return(pLive2DModel);
    }
    // @Brief  : Load audio clip
    // @Param  : pPath          => Asset path
    //         : bFromResources => From resources file
    // @Return : Audio clip
    private AudioClip LoadAudioClip(string pPath, bool bFromResources = false)
    {
        if (string.IsNullOrEmpty(pPath))
        {
            KrDebug.Warning(false, "The path is empty. path = " + pPath, typeof(KrAudioManager));
            return(null);
        }

        if (bFromResources)
        {
            return(KrResources.LoadDataInApp <AudioClip>(pPath));
        }
        else
        {
            if (!System.IO.File.Exists(pPath))
            {
                KrDebug.Warning(false, "The file of the specified path does not exist. path = " + pPath, typeof(KrAudioManager));
                return(null);
            }

            KrWav pWav = new KrWav(pPath, bFromResources);
            return(pWav.CreateAudioClip());
        }
    }
Ejemplo n.º 6
0
    // @Brief  : Create
    // @Param  : pPath   => Asset path under the resources folder
    //         : pParent => Parent of generated prefab
    // @Return : Component specified in template
    private T Create <T>(string pPath, Transform pParent)
    {
        GameObject pPrefab = KrResources.LoadDataInApp <GameObject>(pPath);

        return(Create <T>(pPrefab, pParent));
    }