Api Editor Asset
class

Asset

public abstract class Asset

Properties

Name Type Description
Tags AssetTags Tags for this asset, for filtering purposes in the Asset Browser.
Name String Name of the asset, usually the filename.
Path String The relative path with the asset extension. ie .wav becomes .vsnd
RelativePath String The relative path as it is on disk (ie .wav not .vsnd)
AbsolutePath String The absolute path as it is on disk (ie .wav not .vsnd)
LastOpened DateTime? When the asset was last opened through the editor.
AssetType AssetType The type of this asset.
Package Package If this asset was downloaded from sbox.game then this will be the package from which this asset was downloaded. If not then it'll be null.
IsDeleted Boolean Whether the asset is deleted or not. This can happen after Delete was called on it, or AbsolutePath is empty.
IsProcedural virtual Boolean If true then this asset is generated at runtime somehow. Possibly from a mount system.
IsTransient virtual Boolean This asset is generated in the transient folder. You don't need to see it, or keep it around. It will re-generate from something else.
IsCloud virtual Boolean This asset is from the cloud, it's in the cloud folder
IsTrivialChild Boolean The asset was generated from another asset compile and has no source asset of its own. For example model break gibs .vmdl, .vtex files for materials, etc.
CanRecompile virtual Boolean Can this asset be recompiled?
HasCachedThumbnail Boolean
MetaData MetaData Asset type specific key-value based data storage.
IsCompiled virtual Boolean Whether the asset is compiled.
IsCompiledAndUpToDate virtual Boolean Whether the asset is compiled and all dependencies are up to date. (Slower than IsCompiled)
IsCompileFailed virtual Boolean Whether the asset failed to compile.
HasSourceFile virtual Boolean True if we have a source file, and aren't just a _c file
HasCompiledFile virtual Boolean True if we have a compiled file, and aren't just a source file
HasUnsavedChanges Boolean A free-use variable for the editor to use to portray that this asset somehow has changes that need to be saved to disk.
Publishing PublishSettings Access the asset publisher config.

Methods

Void Delete()

Delete this asset. Will send the source and compiled files to the recycle bin.

virtual String GetCompiledFile(Boolean absolute = False)

Returns the compiled file path, if the asset is compiled.

absolute — Whether the path should be absolute or relative.
returns — The compiled file path, or null if the asset was not compiled.
virtual String GetSourceFile(Boolean absolute = False)

Returns the source file path, if the sources are present.

absolute — Whether the path should be absolute or relative.
returns — The source file path, or null if the source files are not present.
Pixmap GetAssetThumb(Boolean generateIfNotInCache = True)

Returns the asset preview thumbnail, with fallback to the asset type icon if there is no preview.

Void CancelThumbBuild()
virtual String FindStringEditInfo(String name)
Void RebuildThumbnail(Boolean startBuild = True)

Delete existing cached thumbnail, optionally queuing for building a new one ASAP.

startBuild — Queue building the new thumbnail ASAP, as opposed to waiting when it is actually needed and doing it then.
virtual Void OpenInEditor(String nativeEditor = null)

Try to open this asset in a supported editor. You can specify nativeEditor to open in a specific editor.

nativeEditor — A native editor specified in enginetools.txt (e.g modeldoc_editor, hammer, pet..)
virtual List<Asset> GetReferences(Boolean deep)

Returns assets that this asset references/uses.

deep — Whether to recurse. For example, will also include textures referenced by the materials used by this model asset, as opposed to returning just the materials.
virtual List<Asset> GetDependants(Boolean deep)

Returns assets that depend/use this asset.

deep — Whether to recurse. For example, will also include maps that are using models which use this material asset, as opposed to returning just the models.
virtual List<String> GetAdditionalContentFiles()

Gets additional content-side related files. This includes like .rect files for materials, all .fbx and .lxo files for models, etc.

virtual List<String> GetAdditionalGameFiles()

Gets additional game-side files to be packaged (e.g. navdata). These are files that are loaded by managed code, not as native resources.

virtual List<String> GetInputDependencies()

Gets input dependencies for an asset. This'll be tga's for a texture and stuff like that.

virtual List<String> GetUnrecognizedReferencePaths()

Unrecognized reference paths listed by the data that could not be resolved into Asset*s

virtual Boolean Compile(Boolean full)

Forcibly recompile the asset.

full — TODO
Task DumpThumbnail()

Renders the thumbnail and then saves it to disk.

Task<Pixmap> RenderThumb()

Immediately render a preview thumbnail for this asset, and return it.

returns — The rendered preview thumbnail, or null if asset type does not support previews.
virtual Model GetPreviewModel()

Try to create a preview model if we're fbx, obj, etc

Resource LoadResource()

Try to load this asset as an automatically determined resource type. If this isn't a resource type (like an Image) then it will return null.

T LoadResource()

Try to load this asset as a Resource of given type.

returns — The loaded Resource instance of given type, or null on failure.
Resource LoadResource(Type resourceType)

Try to load this asset as a Resource of given type.

returns — The loaded Resource instance of given type, or null on failure.
Boolean TryLoadResource(T obj)

Try to load this asset as a Resource of given type.

obj — Output resource on success, null on failure.
returns — true if was successfully set.
String ReadJson()

Try to get the raw Json string, for a managed asset type (a GameResource)

virtual Boolean SaveToDisk(GameResource obj)

Save a game resource instance to disk. This is used internally by asset inspector and for asset creation.

obj — The instance data to save.
returns — Whether the instance was successfully saved or not.
virtual Void RecordOpened()

Tell asset system that this asset was opened. Sticks it on the recent opened list.

virtual ValueTask<Boolean> CompileIfNeededAsync(Single timeout = 30)

Returns a task that will resolve when the asset is compiled. If the asset is already compiled, do nothing. Does not support maps.

returns — true if the compile was needed, and was successful.
Void OverrideThumbnail(Pixmap pixmap)

Override the Assets thumbnail with given one.

virtual Boolean SetInMemoryReplacement(String sourceData)

Set data for this asset which will be compiled in memory. This is used to preview asset changes (like materials) before committing to disk.

virtual Void ClearInMemoryReplacement()

Reverse the changes of SetInMemoryReplacement

Assembly: Sandbox.Tools Namespace: Editor Full Name: Editor.Asset