5using System.Diagnostics.CodeAnalysis;
7using Object = UnityEngine.Object;
11 public sealed partial class Asset
38 [ExcludeFromCodeCoverage]
39 public static Boolean
Extract([NotNull] Object subAsset, [NotNull]
Path destinationPath)
41 ThrowIf.ArgumentIsNull(subAsset, nameof(subAsset));
42 ThrowIf.ArgumentIsNull(destinationPath, nameof(destinationPath));
44 return Succeeded(AssetDatabase.ExtractAsset(subAsset, destinationPath));
58 public static void Add([NotNull] Object subAssetInstance, [NotNull] Object asset)
60 ThrowIf.ArgumentIsNull(subAssetInstance, nameof(subAssetInstance));
61 ThrowIf.SubObjectIsGameObject(subAssetInstance);
62 ThrowIf.AlreadyAnAsset(subAssetInstance);
63 ThrowIf.ArgumentIsNull(asset, nameof(asset));
65 AssetDatabase.AddObjectToAsset(subAssetInstance, asset);
77 public static void Remove([NotNull] Object subAsset)
79 ThrowIf.ArgumentIsNull(subAsset, nameof(subAsset));
81 AssetDatabase.RemoveObjectFromAsset(subAsset);
96 public static void SetMain([NotNull] Object subAsset, [NotNull]
Path path)
98 AssetDatabase.SetMainObject(subAsset, path);
114 public static void SetMain([NotNull] Object subAsset, [NotNull] Object asset) =>
SetMain(subAsset,
Path.
Get(asset));
135 public static Object[]
LoadAll([NotNull]
Path path) => AssetDatabase.LoadAllAssetsAtPath(path);
158 public static Object[]
LoadVisible([NotNull]
Path path) => AssetDatabase.LoadAllAssetRepresentationsAtPath(path);
static void Import([NotNull] Path path, ImportAssetOptions options=ImportAssetOptions.Default)
Imports a file at a given path that was created or modified 'externally'. Externally refers to any me...
Groups file related operations.
static Path Get([NotNull] Object asset)
Gets the relative path of an asset.
Represents a relative path to an asset file or folder, typically under 'Assets' or 'Packages'.
static Object[] LoadAll([NotNull] Path path)
Loads all sub-asset objects of an asset.
static void SetMain([NotNull] Object subAsset, [NotNull] Object asset)
Sets (changes) an asset's 'main' object to one of its sub-assets.
static void Add([NotNull] Object subAssetInstance, [NotNull] Object asset)
Adds an object as sub-asset to the asset. This change is implicitly saved to disk.
static Object[] LoadVisible([NotNull] Path path)
Loads only the visible (representation) sub-asset objects of an asset.
static Boolean Extract([NotNull] Object subAsset, [NotNull] Path destinationPath)
Extracts a sub-object of an asset as an asset of its own.
static void SetMain([NotNull] Object subAsset, [NotNull] Path path)
Sets (changes) an asset's 'main' object to one of its sub-assets.
static void Remove([NotNull] Object subAsset)
Removes a sub-object from the asset it is contained in.
Groups all Sub-Asset related functionality.