Skip to content

Commit

Permalink
[0.2.4] Base dependency updated; Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
g0dzZz-coder committed Dec 16, 2023
1 parent 6544898 commit a32ece3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 71 deletions.
12 changes: 7 additions & 5 deletions Docs/README.RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -127,7 +128,7 @@ var assetBundle = AssetBundle.LoadFromFile("Path/To/MyBundle");
var assetBundleAsset = new AssetBundleAssetFile<GameObject>("MyAsset", assetBundle);
GameObject loadedAsset = assetBundleAsset.Load();
// Использование загруженного ассета.
assetBundleAsset.Dispose();
assetBundleAsset.Unload();
```

#### Загрузка ассета из редакторской базы данных
Expand All @@ -136,16 +137,17 @@ assetBundleAsset.Dispose();
var databaseAsset = new DatabaseAsset<MyScriptableObject>("Path/To/MyAsset");
MyScriptableObject loadedObject = databaseAsset.Load();
// Использование загруженного ассета.
databaseAsset.Dispose();
databaseAsset.Unload();
```

#### Загрузка ассета из настроек проекта

```csharp
var preloadedAsset = new PreloadedAsset<GameObject>("Path/To/MyAsset");
var anyAsset = new ResourcesAsset<GameObject>("Path/To/MyAsset");
var preloadedAsset = new PreloadedAsset<GameObject>(anyAsset);
GameObject loadedAsset = preloadedAsset.Load();
// Использование загруженного ассета.
preloadedAsset.Dispose();
preloadedAsset.Unload();
```

## 🖇️ Зависимости
Expand Down
12 changes: 7 additions & 5 deletions Docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -127,7 +128,7 @@ var assetBundle = AssetBundle.LoadFromFile("Path/To/MyBundle");
var assetBundleAsset = new AssetBundleAssetFile<GameObject>("MyAsset", assetBundle);
GameObject loadedAsset = assetBundleAsset.Load();
// Use the loaded asset.
assetBundleAsset.Dispose();
assetBundleAsset.Unload();
```

#### Loading an Asset from the Editor Database
Expand All @@ -136,16 +137,17 @@ assetBundleAsset.Dispose();
var databaseAsset = new DatabaseAsset<MyScriptableObject>("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<GameObject>("Path/To/MyAsset");
var anyAsset = new ResourcesAsset<GameObject>("Path/To/MyAsset");
var preloadedAsset = new PreloadedAsset<GameObject>(anyAsset);
GameObject loadedAsset = preloadedAsset.Load();
// Use the loaded asset.
preloadedAsset.Dispose();
preloadedAsset.Unload();
```

## 🖇 Dependencies
Expand Down
2 changes: 1 addition & 1 deletion Editor/Drawers/ResourcesReferenceDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Binary file modified Plugins/Depra.Assets.dll
Binary file not shown.
45 changes: 1 addition & 44 deletions Plugins/Depra.Assets.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 10 additions & 15 deletions Runtime/Files.Resource/ResourcesPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)!);
}

Expand Down Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit a32ece3

Please sign in to comment.