Ejemplo n.º 1
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="loaderMode">加载方式</param>
        /// <param name="pathMode">路径方式</param>
        /// <param name="maxLoadingCount">同时加载的最大数量</param>
        /// <param name="assetRootDir">资源存放根路径</param>
        /// <param name="initCallback">回调</param>
        public void InitLoader(AssetLoaderMode loaderMode,
                               AssetPathMode pathMode,
                               int maxLoadingCount,
                               string assetRootDir,
                               Action <bool> initCallback)
        {
            Leyoutech.Utility.DebugUtility.Log(LOG_TAG, $"Begin init loader AssetLoaderMode({loaderMode}) AssetPathMode({pathMode}) MaxLoadingCount({maxLoadingCount}) AssetRootDir({assetRootDir})");

            if (loaderMode == AssetLoaderMode.AssetBundle)
            {
                m_AssetLoader = new AssetBundleLoader();
            }
            else if (loaderMode == AssetLoaderMode.AssetDatabase)
            {
                m_AssetLoader = new AssetDatabaseLoader();
#if !UNITY_EDITOR
                Debug.LogError("AssetManager::InitLoader->AssetLoaderMode(AssetDatabase) can be used in Editor");
#endif
            }
            m_AssetLoader?.Initialize((isSuccess) =>
            {
                m_IsInit = isSuccess;
                if (isSuccess)
                {
                    m_SceneLoader = new SceneAssetLoader(loaderMode, m_AssetLoader);
                }

                Leyoutech.Utility.DebugUtility.Log(LOG_TAG, "End init loader");
                initCallback?.Invoke(isSuccess);
            }, pathMode, maxLoadingCount, assetRootDir);
        }
 public static UnityEngine.Object CreateAsset(ScriptableObject asset, AssetPathMode type = AssetPathMode.ScriptableObjectAssetPath)
 {
     return(CreateAsset(asset, (type == AssetPathMode.ScriptableObjectAssetPath ? asset.GetScriptableObjectPath() : QuickPathUtils.SelectionAssetPath)));
 }
        public static T CreateAsset <T>(AssetPathMode type = AssetPathMode.ScriptableObjectAssetPath) where T : ScriptableObject
        {
            T asset = ScriptableObject.CreateInstance <T>();

            return(CreateAsset(asset, (type == AssetPathMode.ScriptableObjectAssetPath ? asset.GetScriptableObjectPath() : QuickPathUtils.SelectionAssetPath)) as T);
        }