示例#1
0
        public void LoadAsync <T>(string asset, OnLoaded <T> onLoaded) where T : UnityEngine.Object
        {
            if (string.IsNullOrEmpty(asset))
            {
                onLoaded(null);
            }

            if (loadMode == LoadMode.Original)
            {
                var request = OriginalResourceLoader.loadResourceAsync <T>(resourcePath, asset);
                keysToAdd.Add(new AsyncRequest(request), new LoadFinishCallback(onLoaded, LoadFinishCallback.Type.TypeT));
            }
            else if (loadMode == LoadMode.AssetBundle)
            {
                var request = bundleResourceLoader.LoadAssetAsync <T>(asset);
                keysToAdd.Add(new AsyncRequest(request), new LoadFinishCallback(onLoaded, LoadFinishCallback.Type.TypeT));
            }
#if UNITY_EDITOR
            else if (loadMode == LoadMode.Editor)
            {
                var result = UnityEditor.AssetDatabase.LoadAssetAtPath <T>(asset);
                onLoaded(result);
            }
#endif
        }