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

◆ Asset() [1/6]

Asset ( Byte[] contents,
Path path,
Boolean overwriteExisting = false )

Creates an asset file from a byte array.

Writes the data to a file, then imports the file and loads the asset object.

Parameters
contentsThe data to save 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
System.ArgumentNullExceptionIf contents is null.
System.ArgumentNullExceptionIf the path is null.
See also

Definition at line 104 of file Asset.cs.

105 {
106 ThrowIf.ArgumentIsNull(contents, nameof(contents));
107 ThrowIf.ArgumentIsNull(path, nameof(path));
108
109 path = Path.UniquifyAsNeeded(path, overwriteExisting);
110 var asset = File.CreateInternal(contents, path);
111 InitWithMainObject(asset);
112 }