diff --git a/Docs/README.RU.md b/Docs/README.RU.md index 3769667..ac6fe84 100644 --- a/Docs/README.RU.md +++ b/Docs/README.RU.md @@ -114,7 +114,8 @@ resourceTexture.Unload(); #### Загрузка AssetBundle ```csharp -var assetBundleFile = new AssetBundleFile("Path/To/MyBundle"); +var assetBundleSource = new AssetBundleFromFile(); +var assetBundleFile = new AssetBundleFile("Path/To/MyBundle", assetBundleSource); AssetBundle loadedBundle = assetBundleFile.Load(); // Использование загруженного ассета. assetBundleFile.Unload(); @@ -127,7 +128,7 @@ var assetBundle = AssetBundle.LoadFromFile("Path/To/MyBundle"); var assetBundleAsset = new AssetBundleAssetFile("MyAsset", assetBundle); GameObject loadedAsset = assetBundleAsset.Load(); // Использование загруженного ассета. -assetBundleAsset.Dispose(); +assetBundleAsset.Unload(); ``` #### Загрузка ассета из редакторской базы данных @@ -136,16 +137,17 @@ assetBundleAsset.Dispose(); var databaseAsset = new DatabaseAsset("Path/To/MyAsset"); MyScriptableObject loadedObject = databaseAsset.Load(); // Использование загруженного ассета. -databaseAsset.Dispose(); +databaseAsset.Unload(); ``` #### Загрузка ассета из настроек проекта ```csharp -var preloadedAsset = new PreloadedAsset("Path/To/MyAsset"); +var anyAsset = new ResourcesAsset("Path/To/MyAsset"); +var preloadedAsset = new PreloadedAsset(anyAsset); GameObject loadedAsset = preloadedAsset.Load(); // Использование загруженного ассета. -preloadedAsset.Dispose(); +preloadedAsset.Unload(); ``` ## 🖇️ Зависимости diff --git a/Docs/README.md b/Docs/README.md index e3c3310..331a354 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -114,7 +114,8 @@ resourceTexture.Unload(); #### Loading an AssetBundle ```csharp -var assetBundleFile = new AssetBundleFile("Path/To/MyBundle"); +var assetBundleSource = new AssetBundleFromFile(); +var assetBundleFile = new AssetBundleFile("Path/To/MyBundle", assetBundleSource); AssetBundle loadedBundle = assetBundleFile.Load(); // Use the loaded asset. assetBundleFile.Unload(); @@ -127,7 +128,7 @@ var assetBundle = AssetBundle.LoadFromFile("Path/To/MyBundle"); var assetBundleAsset = new AssetBundleAssetFile("MyAsset", assetBundle); GameObject loadedAsset = assetBundleAsset.Load(); // Use the loaded asset. -assetBundleAsset.Dispose(); +assetBundleAsset.Unload(); ``` #### Loading an Asset from the Editor Database @@ -136,16 +137,17 @@ assetBundleAsset.Dispose(); var databaseAsset = new DatabaseAsset("Path/To/MyAsset"); MyScriptableObject loadedObject = databaseAsset.Load(); // Use the loaded asset. -databaseAsset.Dispose(); +databaseAsset.Unload(); ``` #### Loading an Asset from Project Settings ```csharp -var preloadedAsset = new PreloadedAsset("Path/To/MyAsset"); +var anyAsset = new ResourcesAsset("Path/To/MyAsset"); +var preloadedAsset = new PreloadedAsset(anyAsset); GameObject loadedAsset = preloadedAsset.Load(); // Use the loaded asset. -preloadedAsset.Dispose(); +preloadedAsset.Unload(); ``` ## 🖇 Dependencies diff --git a/Editor/Drawers/ResourcesReferenceDrawer.cs b/Editor/Drawers/ResourcesReferenceDrawer.cs index fab1fdf..0c2c901 100644 --- a/Editor/Drawers/ResourcesReferenceDrawer.cs +++ b/Editor/Drawers/ResourcesReferenceDrawer.cs @@ -47,7 +47,7 @@ private void ApplyPropertyChange(Object objectAsset) if (objectAsset != null) { var projectPath = AssetDatabase.GetAssetPath(objectAsset); - if (Resources.Load(ResourcesPath.Utility.FindRelativePath(projectPath)) != null) + if (Resources.Load(ResourcesPath.FindRelativePath(projectPath)) != null) { assetProjectPath = projectPath; } diff --git a/Plugins/Depra.Assets.dll b/Plugins/Depra.Assets.dll index 212a14a..5542da3 100644 Binary files a/Plugins/Depra.Assets.dll and b/Plugins/Depra.Assets.dll differ diff --git a/Plugins/Depra.Assets.dll.meta b/Plugins/Depra.Assets.dll.meta index fb918ee..db3b087 100644 --- a/Plugins/Depra.Assets.dll.meta +++ b/Plugins/Depra.Assets.dll.meta @@ -11,23 +11,6 @@ PluginImporter: isExplicitlyReferenced: 0 validateReferences: 1 platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Android: 0 - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude Win: 0 - Exclude Win64: 0 - - first: - Android: Android - second: - enabled: 1 - settings: - CPU: ARMv7 - first: Any: second: @@ -36,35 +19,9 @@ PluginImporter: - first: Editor: Editor second: - enabled: 1 + enabled: 0 settings: - CPU: AnyCPU DefaultValueInitialized: true - OS: AnyOS - - first: - Standalone: Linux64 - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: OSXUniversal - second: - enabled: 1 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 1 - settings: - CPU: x86 - - first: - Standalone: Win64 - second: - enabled: 1 - settings: - CPU: x86_64 - first: Windows Store Apps: WindowsStoreApps second: diff --git a/Runtime/Files.Resource/ResourcesPath.cs b/Runtime/Files.Resource/ResourcesPath.cs index 8f4035b..a22446c 100644 --- a/Runtime/Files.Resource/ResourcesPath.cs +++ b/Runtime/Files.Resource/ResourcesPath.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using System.Runtime.CompilerServices; using Depra.Assets.Exceptions; using Depra.Assets.Extensions; using Depra.Assets.Files.Resource.Exceptions; @@ -24,7 +23,7 @@ public ResourcesPath(string projectPath) { Project = projectPath; Absolute = Path.GetFullPath(Project); - Relative = Utility.FindRelativePath(Project); + Relative = FindRelativePath(Project); Directory = new DirectoryInfo(Path.GetDirectoryName(Absolute)!); } @@ -56,24 +55,20 @@ public ResourcesPath(string name, string extension = null, string relativeDirect public string Project { get; } public DirectoryInfo Directory { get; } - internal static class Utility + internal static string FindRelativePath(string projectPath) { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string FindRelativePath(string projectPath) - { - Guard.AgainstEmptyString(projectPath, () => new NullReferenceException(nameof(projectPath))); + Guard.AgainstEmptyString(projectPath, () => new NullReferenceException(nameof(projectPath))); - projectPath = projectPath.ToUnixPath(); - var folderIndex = projectPath.IndexOf(RESOURCES_FOLDER_PATH, StringComparison.OrdinalIgnoreCase); + projectPath = projectPath.ToUnixPath(); + var folderIndex = projectPath.IndexOf(RESOURCES_FOLDER_PATH, StringComparison.OrdinalIgnoreCase); - Guard.AgainstEqual(folderIndex, -1, () => new PathDoesNotContainResourcesFolder(projectPath)); + Guard.AgainstEqual(folderIndex, -1, () => new PathDoesNotContainResourcesFolder(projectPath)); - folderIndex += RESOURCES_FOLDER_PATH.Length; - var length = projectPath.Length - folderIndex; - length -= projectPath.Length - projectPath.LastIndexOf('.'); + folderIndex += RESOURCES_FOLDER_PATH.Length; + var length = projectPath.Length - folderIndex; + length -= projectPath.Length - projectPath.LastIndexOf('.'); - return projectPath.Substring(folderIndex, length); - } + return projectPath.Substring(folderIndex, length); } } } \ No newline at end of file diff --git a/package.json b/package.json index 5bc3bdc..a4e6bb6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.depra.assets.unity", - "version": "0.2.3", + "version": "0.2.4", "displayName": "Depra.Assets", "description": "Provides an API for loading Unity asset files in multiple ways through a single interface.", "unity": "2021.3",