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

◆ Asset() [2/6]

Asset ( String contents,
Path path,
Boolean overwriteExisting = false )

Creates an asset file from a string.

Parameters
contentsThe string 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
ArgumentNullExceptionIf contents is null.
ArgumentNullExceptionIf the path is null.
See also

Definition at line 129 of file Asset.cs.

130 {
131 ThrowIf.ArgumentIsNull(contents, nameof(contents));
132 ThrowIf.ArgumentIsNull(path, nameof(path));
133
134 path = Path.UniquifyAsNeeded(path, overwriteExisting);
135 var asset = File.CreateInternal(contents, path);
136 InitWithMainObject(asset);
137 }