private AssetInstance ProvideAsset(string path, AssetContainer container, Type typ) { var hash = AssetInstance.GenerateHash(path); if (container.TryGetAsset(hash) is AssetInstance asset && asset.IsFinished) { return(asset); } asset = typ == typeof(GameObject) ? new PrefabAssetInstance(path) : new AssetInstance(path); Object unityObject; if (ConvertPath(ref path) || path.StartsWith("Assets")) { #if UNITY_EDITOR unityObject = UnityEditor.AssetDatabase.LoadAssetAtPath(path, typ); #else unityObject = null; #endif } else { unityObject = Resources.Load(path, typ); } asset.SetAsset(unityObject, null); return(asset); }
private static AssetBundleInstance FindOrCreateABInstance(string path, AssetContainer container) { var hash = AssetBundleInstance.GenerateHash(path); var abInstance = container.TryGetAsset(hash) as AssetBundleInstance ?? new AssetBundleInstance(path); return(abInstance); }
private AssetInstance ProvideAsset(string path, AssetContainer container, Type typ) { var hash = AssetInstance.GenerateHash(path); if (container.TryGetAsset(hash) is AssetInstance asset) { return(asset); } if (!TryGetABContext(path, out var abPathContext)) { Debug.LogWarning($"Can not get ab context : {path}"); return(null); } asset = typ == typeof(GameObject) ? new PrefabAssetInstance(path) : new AssetInstance(path); var abInstance = FindOrCreateABInstance(abPathContext.ABName, container); asset.SetAsset(abInstance.LoadAsset(abPathContext.Path, typ), abInstance); return(asset); }