Example #1
0
        public IObservable <T> Load <T>(string assetPath) where T : UObject
        {
            if (!_assetConfig.Contains(assetPath))
            {
                Log.I("Asset {0} not found in assetconfig ,refresh asset config first!", assetPath);
                return(Observable.Return <T>(null));
            }

            var assetInfo = _assetConfig.GetAssetInfo(assetPath);

            if (!assetInfo.isFromBundle)
            {
                return(Resources.LoadAsync(assetPath).AsAsyncOperationObservable().Select(obj => (T)obj.asset));
            }
            else
            {
                return(_assetBundleLoader.Load(assetInfo.bundleName, assetInfo.assetName).Select(obj => (T)obj));
            }
        }
Example #2
0
        public IObservable <T> Load <T>(string assetPath) where T : UObject
        {
            if (!_assetConfig.Contains(assetPath))
            {
                Log.I("Asset {0} not found in assetconfig ,refresh asset config first!", assetPath);
                return(Observable.Return <T>(null));
            }

            var assetInfo = _assetConfig.GetAssetInfo(assetPath);

            if (!assetInfo.isFromBundle)
            {
                return(Observable.Return(AssetDatabase.LoadAssetAtPath <T>(
                                             assetInfo.fullPath), Scheduler.MainThreadIgnoreTimeScale));
            }
            else
            {
                var assetFullPath = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(
                    assetInfo.bundleName, assetInfo.assetName);
                return(Observable.Return(AssetDatabase.LoadAssetAtPath <T>(assetFullPath[0]),
                                         Scheduler.MainThreadIgnoreTimeScale));
            }
        }