예제 #1
0
        public static TAsset Load <TAsset>(this IAssetSource source, string path) where TAsset : IBasicAsset
        {
            var asset = source.LoadBasic(path);

            if (asset is TAsset)
            {
                return((TAsset)asset);
            }
            else
            {
                asset.Dispose();
                throw new AssetLoadException(path, "Asset is of incorrect type");
            }
        }
예제 #2
0
        private static void LoadBasicAsset(string path, IAssetSource source, bool reloadIfSourceUnchanged)
        {
            var existingBasic = LookupBasic(path);

            if (existingBasic != null)
            {
                // Reload an existing asset
                if (reloadIfSourceUnchanged || existingBasic.Source != source)
                {
                    source.ReloadBasic(existingBasic.Asset);
                    existingBasic.Source = source;
                }
            }
            else
            {
                // Create a new asset
                var asset       = source.LoadBasic(path);
                var loadedAsset = new LoadedBasicAsset(path, asset);
                loadedAsset.Source = source;
                s_loadedBasicAssets.Add(path, loadedAsset);
            }
        }