CodeSmile AssetDatabase 1.10
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 162 of file Asset.cs.

163 {
164 ThrowIf.ArgumentIsNull(asset, nameof(asset));
165 ThrowIf.ArgumentIsNull(path, nameof(path));
166 ThrowIf.AlreadyAnAsset(asset);
167
168 path = Path.UniquifyAsNeeded(path, overwriteExisting);
169 File.CreateInternal(asset, path);
170 InitWithMainObject(asset);
171 }