Пример #1
0
    /// <summary>
    /// 给过来的直接是prefab
    /// </summary>
    /// <typeparam name="T">类型</typeparam>
    /// <param name="path">资源相对路径</param>
    /// <param name="callback">加载成功的回调,成功了拿到的是Prefab</param>
    /// <param name="failure">失败的通知</param>
    /// <param name="userData">用户自定义数据数组</param>
    static void Load <T>(string path, AssetType assetType, Action <string, object[], T, OnAssetDestory> callback, Action <string, object[]> failure, params object[] userData) where T : Object
    {
        AssetLoader assetLoader = AssetLoader.Get(path, AssetType.UnityAsset);

        if (assetType == AssetType.UnityAsset)
        {
            assetLoader.AddLoadRequest(new LoadRequest <T>(callback, failure, userData));
        }
        if (assetLoader.LoadState != AssetLoadState.Loaded && assetLoader.LoadState != AssetLoadState.None)
        {
            return;
        }
        helper.StartCoroutine(assetLoader.Load());
    }
Пример #2
0
    /// <summary>
    /// 场景需要专门去处理,暂不管
    /// </summary>
    public static void LoadScene(string path, Action <string, object[], OnAssetDestory> callback, Action <string, object[]> failure, params object[] userData)
    {
        path = "Scenes/" + path + (EditorMode ? "" : BUNDLE_SUFFIX);
        if (EditorMode)
        {
            bool addtive = (bool)userData[0];
            if (addtive)
            {
                SceneManager.LoadScene(System.IO.Path.Combine(Application.dataPath, "Main/BundleEditor/" + path), LoadSceneMode.Additive);
            }
            else
            {
                SceneManager.LoadScene(System.IO.Path.Combine("", "Main/BundleEditor/" + path), LoadSceneMode.Single);
            }
            callback(path, userData, () => { });
            return;
        }
        AssetLoader assetLoader = AssetLoader.Get(path, AssetType.Scene);

        assetLoader.AddLoadRequest(new LoadRequestScene(callback, failure, userData));
        helper.StartCoroutine(assetLoader.Load());
    }