diff --git a/Editor/Files/PreloadedAsset.cs b/Editor/Files/PreloadedAsset.cs index 1619e93..b7c9956 100644 --- a/Editor/Files/PreloadedAsset.cs +++ b/Editor/Files/PreloadedAsset.cs @@ -16,8 +16,6 @@ namespace Depra.Assets.Editor.Files { public sealed class PreloadedAsset : IAssetFile, IDisposable where TAsset : Object { - public static implicit operator TAsset(PreloadedAsset self) => self.Load(); - private readonly Type _assetType; private readonly IAssetFile _asset; diff --git a/Runtime/Files.Bundles/Files/AssetBundleAssetFile.cs b/Runtime/Files.Bundles/Files/AssetBundleAssetFile.cs index a09a280..8661f02 100644 --- a/Runtime/Files.Bundles/Files/AssetBundleAssetFile.cs +++ b/Runtime/Files.Bundles/Files/AssetBundleAssetFile.cs @@ -16,8 +16,6 @@ namespace Depra.Assets.Files.Bundles { public sealed class AssetBundleAssetFile : IAssetFile, IDisposable where TAsset : Object { - public static implicit operator TAsset(AssetBundleAssetFile self) => self.Load(); - private readonly AssetBundle _assetBundle; private TAsset _loadedAsset; diff --git a/Runtime/Files.Bundles/Files/AssetBundleFile.cs b/Runtime/Files.Bundles/Files/AssetBundleFile.cs index 461ab05..883cf01 100644 --- a/Runtime/Files.Bundles/Files/AssetBundleFile.cs +++ b/Runtime/Files.Bundles/Files/AssetBundleFile.cs @@ -15,8 +15,6 @@ namespace Depra.Assets.Files.Bundles { public sealed class AssetBundleFile : IAssetFile, IDisposable { - public static implicit operator AssetBundle(AssetBundleFile self) => self.Load(); - private readonly AssetBundleUri _uri; private readonly IAssetBundleSource _source; @@ -42,7 +40,7 @@ public AssetBundle Load() } var loadedAssetBundle = _source.Load(by: _uri.AbsolutePathWithoutExtension); - Guard.AgainstNull(loadedAssetBundle, () => new AssetBundleNotLoaded(_uri.AbsolutePath)); + Guard.AgainstNull(loadedAssetBundle, () => new AssetBundleNotLoaded(_uri.Absolute)); _loadedAssetBundle = loadedAssetBundle; Metadata.Size = _source.Size(of: _loadedAssetBundle); @@ -62,7 +60,7 @@ public async Task LoadAsync(DownloadProgressDelegate onProgress = n var loadedAssetBundle = await _source .LoadAsync(_uri.AbsolutePathWithoutExtension, OnProgress, cancellationToken); - Guard.AgainstNull(loadedAssetBundle, () => new AssetBundleNotLoaded(_uri.AbsolutePath)); + Guard.AgainstNull(loadedAssetBundle, () => new AssetBundleNotLoaded(_uri.Absolute)); _loadedAssetBundle = loadedAssetBundle; onProgress?.Invoke(DownloadProgress.Full); diff --git a/Runtime/Files.Bundles/Files/AssetBundleUri.cs b/Runtime/Files.Bundles/Files/AssetBundleUri.cs index 4da65d0..b2f16e1 100644 --- a/Runtime/Files.Bundles/Files/AssetBundleUri.cs +++ b/Runtime/Files.Bundles/Files/AssetBundleUri.cs @@ -4,7 +4,6 @@ using System.IO; using Depra.Assets.Extensions; using Depra.Assets.ValueObjects; -using JetBrains.Annotations; namespace Depra.Assets.Files.Bundles { @@ -27,7 +26,7 @@ public AssetBundleUri(string path) ? _fileInfo.Name : _fileInfo.Name.Replace(Extension, string.Empty); - AbsolutePathWithoutExtension = AbsolutePath.Replace(EXTENSION, string.Empty); + AbsolutePathWithoutExtension = Absolute.Replace(EXTENSION, string.Empty); } public AssetBundleUri(string name, string directory = null) : this(name, directory, EXTENSION) { } @@ -35,24 +34,14 @@ public AssetBundleUri(string name, string directory = null) : this(name, directo public AssetBundleUri(string name, string directory, string extension = null) : this( Path.Combine(directory, name + extension)) { } - [UsedImplicitly] public string Name { get; } - - [UsedImplicitly] public string Extension => EXTENSION; - - [UsedImplicitly] public string NameWithExtension => Name + Extension; - [UsedImplicitly] - public string AbsolutePath => _fileInfo.FullName; - - [UsedImplicitly] + public string Absolute => _fileInfo.FullName; public string AbsoluteDirectoryPath => _fileInfo.DirectoryName; - public string AbsolutePathWithoutExtension { get; } string IAssetUri.Relative => Name; - string IAssetUri.Absolute => AbsolutePath; } } \ No newline at end of file diff --git a/Runtime/Files.Database/DatabaseAsset.cs b/Runtime/Files.Database/DatabaseAsset.cs index 305a80f..fa9a901 100644 --- a/Runtime/Files.Database/DatabaseAsset.cs +++ b/Runtime/Files.Database/DatabaseAsset.cs @@ -16,8 +16,6 @@ namespace Depra.Assets.Files.Database { public sealed class DatabaseAsset : IAssetFile, IDisposable where TAsset : ScriptableObject { - public static implicit operator TAsset(DatabaseAsset self) => self.Load(); - private readonly Type _assetType; private readonly DatabaseAssetUri _uri; @@ -43,7 +41,7 @@ public TAsset Load() #if UNITY_EDITOR if (_uri.Exists()) { - loadedAsset = AssetDatabase.LoadAssetAtPath(_uri.RelativePath); + loadedAsset = AssetDatabase.LoadAssetAtPath(_uri.Relative); } #endif if (loadedAsset == null) @@ -67,7 +65,7 @@ public void Unload() } #if UNITY_EDITOR - AssetDatabase.DeleteAsset(_uri.RelativePath); + AssetDatabase.DeleteAsset(_uri.Relative); #endif _loadedAsset = null; } @@ -101,7 +99,7 @@ private Object ActivateAsset(Object asset) _uri.Directory.CreateIfNotExists(); asset.name = _uri.Name; - AssetDatabase.CreateAsset(asset, _uri.RelativePath); + AssetDatabase.CreateAsset(asset, _uri.Relative); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); diff --git a/Runtime/Files.Database/DatabaseAssetUri.cs b/Runtime/Files.Database/DatabaseAssetUri.cs index 8736e12..51291db 100644 --- a/Runtime/Files.Database/DatabaseAssetUri.cs +++ b/Runtime/Files.Database/DatabaseAssetUri.cs @@ -3,7 +3,6 @@ using System.IO; using Depra.Assets.ValueObjects; -using JetBrains.Annotations; namespace Depra.Assets.Files.Database { @@ -21,31 +20,22 @@ public DatabaseAssetUri(string relativeDirectory, string name, string extension) Name = name; Extension = extension; NameWithExtension = Name + Extension; - RelativePath = Path.Combine(relativeDirectory, NameWithExtension).Replace(@"\", "/"); - AbsolutePath = Path.GetFullPath(RelativePath).Replace(@"\", "/"); - AbsoluteDirectoryPath = Path.GetFullPath(relativeDirectory).Replace(@"\", "/"); - Directory = new DirectoryInfo(AbsoluteDirectoryPath); + Relative = Path.Combine(relativeDirectory, NameWithExtension).Replace(@"\", "/"); + Absolute = Path.GetFullPath(Relative).Replace(@"\", "/"); + AbsoluteDirectory = Path.GetFullPath(relativeDirectory).Replace(@"\", "/"); + Directory = new DirectoryInfo(AbsoluteDirectory); } public string Name { get; } - - [UsedImplicitly] public string Extension { get; } - - [UsedImplicitly] public string NameWithExtension { get; } - public string RelativePath { get; } - public string AbsolutePath { get; } - - [UsedImplicitly] - public string AbsoluteDirectoryPath { get; } + public string Relative { get; } + public string Absolute { get; } + public string AbsoluteDirectory { get; } internal DirectoryInfo Directory { get; } - string IAssetUri.Relative => RelativePath; - string IAssetUri.Absolute => AbsolutePath; - - public bool Exists() => File.Exists(AbsolutePath); + public bool Exists() => File.Exists(Absolute); } } \ No newline at end of file diff --git a/Runtime/Files.Resource/ResourcesAsset.cs b/Runtime/Files.Resource/ResourcesAsset.cs index d297676..af51a5c 100644 --- a/Runtime/Files.Resource/ResourcesAsset.cs +++ b/Runtime/Files.Resource/ResourcesAsset.cs @@ -15,8 +15,6 @@ namespace Depra.Assets.Files.Resource { public sealed class ResourcesAsset : IAssetFile, IDisposable where TAsset : Object { - public static implicit operator TAsset(ResourcesAsset self) => self.Load(); - private TAsset _loadedAsset; public ResourcesAsset(ResourcesPath path)