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

109 {
110 ThrowIf.ArgumentIsNull(contents, nameof(contents));
111 ThrowIf.ArgumentIsNull(path, nameof(path));
112
113 path = Path.UniquifyAsNeeded(path, overwriteExisting);
114 var asset = File.CreateInternal(contents, path);
115 InitWithMainObject(asset);
116 }