Assetclass

objectAsset
Namespace
Editor
Assembly
Sandbox.Tools
Declaration
public abstract class Editor.Asset

Methods31

Showing 31 methods

public void CancelThumbBuild()PUBLIC

Returns:void

public virtual void ClearInMemoryReplacement()PUBLICVIRTUAL

Reverse the changes of SetInMemoryReplacement

Returns:void

public virtual bool Compile(bool full)PUBLICVIRTUAL

Forcibly recompile the asset.

ParameterTypeDescription
fullboolTODO
Returns:bool

public virtual System.Threading.Tasks.ValueTask`1<bool> CompileIfNeededAsync(float timeout = 30)PUBLICVIRTUAL

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

ParameterTypeDescription
timeout = 30float
Returns:ValueTask<bool>true if the compile was needed, and was successful.

public void Delete()PUBLIC

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

Returns:void

public System.Threading.Tasks.Task DumpThumbnail()PUBLIC

Renders the thumbnail and then saves it to disk.

Returns:Task

public virtual string FindStringEditInfo(string name)PUBLICVIRTUAL

ParameterTypeDescription
namestring
Returns:string

public virtual System.Collections.Generic.List`1<string> GetAdditionalContentFiles()PUBLICVIRTUAL

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

Returns:List<string>

public virtual System.Collections.Generic.List`1<string> GetAdditionalGameFiles()PUBLICVIRTUAL

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

Returns:List<string>

public Editor.Pixmap GetAssetThumb(bool generateIfNotInCache = True)PUBLIC

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

ParameterTypeDescription
generateIfNotInCache = Truebool
Returns:Pixmap

public virtual string GetCompiledFile(bool absolute = False)PUBLICVIRTUAL

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

ParameterTypeDescription
absolute = FalseboolWhether the path should be absolute or relative.
Returns:stringThe compiled file path, or null if the asset was not compiled.

public virtual System.Collections.Generic.List`1<Editor.Asset> GetDependants(bool deep)PUBLICVIRTUAL

Returns assets that depend/use this asset.

ParameterTypeDescription
deepboolWhether to recurse. For example, will also include maps that are using models which use this material asset, as opposed to returning just the models.
Returns:List<Asset>

public virtual System.Collections.Generic.List`1<string> GetInputDependencies()PUBLICVIRTUALINGEST

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

Returns:List<string>

public virtual System.Collections.Generic.List`1<Editor.Asset> GetParents(bool deep)PUBLICVIRTUAL

Returns assets that are parents of this asset (i.e. this asset is a compiled child resource of the returned assets).

ParameterTypeDescription
deepboolWhether to recurse up the parent chain.
Returns:List<Asset>

public virtual Sandbox.Model GetPreviewModel()PUBLICVIRTUAL

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

Returns:Model

public virtual System.Collections.Generic.List`1<Editor.Asset> GetReferences(bool deep)PUBLICVIRTUAL

Returns assets that this asset references/uses.

ParameterTypeDescription
deepboolWhether to recurse. For example, will also include textures referenced by the materials used by this model asset, as opposed to returning just the materials.
Returns:List<Asset>

public virtual string GetSourceFile(bool absolute = False)PUBLICVIRTUAL

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

ParameterTypeDescription
absolute = FalseboolWhether the path should be absolute or relative.
Returns:stringThe source file path, or null if the source files are not present.

public virtual System.Collections.Generic.List`1<string> GetUnrecognizedReferencePaths()PUBLICVIRTUAL

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

Returns:List<string>

protected void LoadUserTags()PROTECTED

Returns:void

public virtual void OpenInEditor(string nativeEditor = null)PUBLICVIRTUAL

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

ParameterTypeDescription
nativeEditor = nullstringA native editor specified in enginetools.txt (e.g modeldoc_editor, hammer, pet..)
Returns:void

public void OverrideThumbnail(Editor.Pixmap pixmap)PUBLIC

Override the Assets thumbnail with given one.

ParameterTypeDescription
pixmapPixmap
Returns:void

public string ReadJson()PUBLIC

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

Returns:string

public void RebuildThumbnail(bool startBuild = True)PUBLIC

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

ParameterTypeDescription
startBuild = TrueboolQueue building the new thumbnail ASAP, as opposed to waiting when it is actually needed and doing it then.
Returns:void

public virtual void RecordOpened()PUBLICVIRTUAL

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

Returns:void

public System.Threading.Tasks.Task`1<Editor.Pixmap> RenderThumb()PUBLIC

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

Returns:Task<Pixmap>The rendered preview thumbnail, or null if asset type does not support previews.

public virtual bool SaveToDisk(Sandbox.GameResource obj)PUBLICVIRTUAL

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

ParameterTypeDescription
objGameResourceThe instance data to save.
Returns:boolWhether the instance was successfully saved or not.

public virtual bool SetInMemoryReplacement(string sourceData)PUBLICVIRTUAL

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

ParameterTypeDescription
sourceDatastring
Returns:bool

public bool TryLoadResource(T obj)PUBLIC

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

ParameterTypeDescription
objTOutput resource on success, null on failure.
Returns:booltrue if `obj` was successfully set.

Properties24

Showing 24 properties

public string Editor.Asset.AbsolutePath { get; set; }PUBLICGETSET

The absolute path as it is on disk (ie .wav not .vsnd)

Returns:string

public virtual bool Editor.Asset.CanOpenInEditor { get; set; }PUBLICVIRTUALGETSET

Whether `Editor.Asset.OpenInEditor(System.String)` can do anything useful for this asset. Used to decide whether to offer an "Open" action for assets that have no file on disk (e.g. mounted resources).

Returns:bool

public virtual bool Editor.Asset.CanRecompile { get; set; }PUBLICVIRTUALGETSET

Can this asset be recompiled?

Returns:bool

public bool Editor.Asset.HasCachedThumbnail { get; set; }PUBLICGETSET

Returns:bool

public virtual bool Editor.Asset.HasCompiledFile { get; set; }PUBLICVIRTUALGETSET

True if we have a compiled file, and aren't just a source file

Returns:bool

public virtual bool Editor.Asset.HasSourceFile { get; set; }PUBLICVIRTUALGETSET

True if we have a source file, and aren't just a _c file

Returns:bool

public bool Editor.Asset.HasUnsavedChanges { get; set; }PUBLICGETSET

A free-use variable for the editor to use to portray that this asset somehow has changes that need to be saved to disk.

Returns:bool

public virtual bool Editor.Asset.IsCloud { get; set; }PUBLICVIRTUALGETSET

This asset is from the cloud, it's in the cloud folder

Returns:bool

public virtual bool Editor.Asset.IsCompiled { get; set; }PUBLICVIRTUALGETSET

Whether the asset is compiled.

Returns:bool

public virtual bool Editor.Asset.IsCompiledAndUpToDate { get; set; }PUBLICVIRTUALGETSET

Whether the asset is compiled and all dependencies are up to date. (Slower than IsCompiled)

Returns:bool

public virtual bool Editor.Asset.IsCompileFailed { get; set; }PUBLICVIRTUALGETSET

Whether the asset failed to compile.

Returns:bool

public bool Editor.Asset.IsDeleted { get; set; }PUBLICGETSET

Whether the asset is deleted or not. This can happen after `Editor.Asset.Delete` was called on it, or `Editor.Asset.AbsolutePath` is empty.

Returns:bool

public virtual bool Editor.Asset.IsProcedural { get; set; }PUBLICVIRTUALGETSET

If true then this asset is generated at runtime somehow. Possibly from a mount system.

Returns:bool

public virtual bool Editor.Asset.IsTransient { get; set; }PUBLICVIRTUALGETSET

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.

Returns:bool

public bool Editor.Asset.IsTrivialChild { get; set; }PUBLICGETSET

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.

Returns:bool

public System.Nullable`1<System.DateTime> Editor.Asset.LastOpened { get; set; }PUBLICGETSET

When the asset was last opened through the editor.

Returns:Nullable<DateTime>

public string Editor.Asset.Name { get; set; }PUBLICGETSET

Name of the asset, usually the filename.

Returns:string

public Sandbox.Package Editor.Asset.Package { get; set; }PUBLICGETSET

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.

Returns:Package

public string Editor.Asset.Path { get; set; }PUBLICGETSET

The relative path with the asset extension. ie .wav becomes .vsnd

Returns:string

public string Editor.Asset.RelativePath { get; set; }PUBLICGETSET

The relative path as it is on disk (ie .wav not .vsnd)

Returns:string

public Editor.Asset.AssetTags Editor.Asset.Tags { get; set; }PUBLICGETSET

Tags for this asset, for filtering purposes in the Asset Browser.

Returns:AssetTags

On this page

Methodspublic System.Void CancelThumbBuild()public virtual System.Void ClearInMemoryReplacement()public virtual System.Boolean Compile(System.Boolean full)public virtual System.Threading.Tasks.ValueTask`1<System.Boolean> CompileIfNeededAsync(System.Single timeout = 30)public System.Void Delete()public System.Threading.Tasks.Task DumpThumbnail()public virtual System.String FindStringEditInfo(System.String name)public virtual System.Collections.Generic.List`1<System.String> GetAdditionalContentFiles()public virtual System.Collections.Generic.List`1<System.String> GetAdditionalGameFiles()public Editor.Pixmap GetAssetThumb(System.Boolean generateIfNotInCache = True)public virtual System.String GetCompiledFile(System.Boolean absolute = False)public virtual System.Collections.Generic.List`1<Editor.Asset> GetDependants(System.Boolean deep)public virtual System.Collections.Generic.List`1<System.String> GetInputDependencies()public virtual System.Collections.Generic.List`1<Editor.Asset> GetParents(System.Boolean deep)public virtual Sandbox.Model GetPreviewModel()public virtual System.Collections.Generic.List`1<Editor.Asset> GetReferences(System.Boolean deep)public virtual System.String GetSourceFile(System.Boolean absolute = False)public virtual System.Collections.Generic.List`1<System.String> GetUnrecognizedReferencePaths()public Sandbox.Resource LoadResource()public Sandbox.Resource LoadResource(System.Type resourceType)public T LoadResource()protected System.Void LoadUserTags()public virtual System.Void OpenInEditor(System.String nativeEditor = null)public System.Void OverrideThumbnail(Editor.Pixmap pixmap)public System.String ReadJson()public System.Void RebuildThumbnail(System.Boolean startBuild = True)public virtual System.Void RecordOpened()public System.Threading.Tasks.Task`1<Editor.Pixmap> RenderThumb()public virtual System.Boolean SaveToDisk(Sandbox.GameResource obj)public virtual System.Boolean SetInMemoryReplacement(System.String sourceData)public System.Boolean TryLoadResource(T obj)Propertiespublic System.String Editor.Asset.AbsolutePath { get; set; }public Editor.AssetType Editor.Asset.AssetType { get; set; }public virtual System.Boolean Editor.Asset.CanOpenInEditor { get; set; }public virtual System.Boolean Editor.Asset.CanRecompile { get; set; }public System.Boolean Editor.Asset.HasCachedThumbnail { get; set; }public virtual System.Boolean Editor.Asset.HasCompiledFile { get; set; }public virtual System.Boolean Editor.Asset.HasSourceFile { get; set; }public System.Boolean Editor.Asset.HasUnsavedChanges { get; set; }public virtual System.Boolean Editor.Asset.IsCloud { get; set; }public virtual System.Boolean Editor.Asset.IsCompiled { get; set; }public virtual System.Boolean Editor.Asset.IsCompiledAndUpToDate { get; set; }public virtual System.Boolean Editor.Asset.IsCompileFailed { get; set; }public System.Boolean Editor.Asset.IsDeleted { get; set; }public virtual System.Boolean Editor.Asset.IsProcedural { get; set; }public virtual System.Boolean Editor.Asset.IsTransient { get; set; }public System.Boolean Editor.Asset.IsTrivialChild { get; set; }public System.Nullable`1<System.DateTime> Editor.Asset.LastOpened { get; set; }public Editor.MetaData Editor.Asset.MetaData { get; set; }public System.String Editor.Asset.Name { get; set; }public Sandbox.Package Editor.Asset.Package { get; set; }public System.String Editor.Asset.Path { get; set; }public Editor.Asset.PublishSettings Editor.Asset.Publishing { get; set; }public System.String Editor.Asset.RelativePath { get; set; }public Editor.Asset.AssetTags Editor.Asset.Tags { get; set; }Metadata