CodeSmile AssetDatabase 1.9
Unity's AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.
Loading...
Searching...
No Matches

◆ Asset() [3/6]

Asset ( Object asset,
Path path,
Boolean overwriteExisting = false )

Creates an asset file from an existing UnityEngine.Object instance.

The object must not already be an asset file (throws exception).

Parameters
assetThe instance to create as an asset file.
pathPath where to save the new asset file, with extension.
overwriteExistingIf true, will overwrite any existing asset at path. Otherwise does not overwrite but generates a unique filename (default).
Exceptions
ArgumentNullExceptionIf the object is null.
ArgumentNullExceptionIf the path is null.
ArgumentExceptionIf the object is already an asset on disk.
See also

Definition at line 158 of file Asset.cs.

159 {
160 ThrowIf.ArgumentIsNull(asset, nameof(asset));
161 ThrowIf.ArgumentIsNull(path, nameof(path));
162 ThrowIf.AlreadyAnAsset(asset);
163
164 path = Path.UniquifyAsNeeded(path, overwriteExisting);
165 File.CreateInternal(asset, path);
166 InitWithMainObject(asset);
167 }