public abstract class Sandbox.GameResource : Sandbox.Resource
Assets defined in C# and created through tools. You can define your own Custom Asset Types.
Related Guides
Broader workflow and conceptual references connected to this API.
In the event that you find your JSON files growing too much due to too much data. You can store data as a binary blob. This will work with anything that serializes to JSON.
You can define your own custom asset types as GameResources. They give you a nice inspector window and they're hotloaded in-game, which means you can whip things up pretty quickly if you're using them.
Editor Events are events that are broadcast globally throughout the editor and can be listened to/fired from any Editor Project. These are useful for creating your own custom Editor Tools and making sure they can work in tandem with existing systems.
ResourceExtensions can be used to append additional data to existing GameResources without modifying the original class or assets. This is useful for adding additional properties to resources such as Clothing, Surfaces, Models, ect.
Adding the [Sync] attribute to a property on a Component will have its latest value sent to other players each time it changes.
Assets are the building blocks of your game — models, materials, sounds, textures, and custom resources. S&box provides tools for creating, importing, managing, and distributing assets.
Constructors
Showing 1 constructors
protected GameResource()
No results match this filter.
Methods
Showing 9 methods
public void Deserialize(System.Text.Json.Nodes.JsonObject jso)
Deserialize values from a JsonObject
public System.Collections.Generic.IEnumerable`1<string> GetReferencedPackages()
Get a list of packages that are needed to load this asset
public void LoadFromJson(string json)
protected virtual void OnDestroy()
Called when this resource is being unloaded. Clean up any resources owned by this instance here.
protected virtual void OnJsonSerialize(System.Text.Json.Nodes.JsonObject node)
Called after we serialize, allowing you to store any extra or modify the output.
protected virtual void PostLoad()
Called when the asset is first loaded from disk.
Implementations
protected virtual void PostReload()
Called when the asset is recompiled/reloaded from disk.
public System.Text.Json.Nodes.JsonObject Serialize()
Serialize the current state to a JsonObject
public virtual sealed void StateHasChanged()
Should be called after the resource has been edited by the inspector
No results match this filter.
Properties
Showing 5 properties
protected virtual object Sandbox.GameResource.ActionGraphTarget { get; set; }
Target instance used for any action graphs contained in this resource. Defaults to this resource itself.
protected virtual System.Type Sandbox.GameResource.ActionGraphTargetType { get; set; }
Target type used for any action graphs contained in this resource. Defaults to this resource's type.
public virtual sealed bool Sandbox.GameResource.HasUnsavedChanges { get; set; }
True if this resource has changed but the changes aren't written to disk
public virtual sealed bool Sandbox.GameResource.IsValid { get; set; }
public virtual int Sandbox.GameResource.ResourceVersion { get; set; }
The version of the component. Used by `Sandbox.JsonUpgrader`.
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.GameResource |