Skip to content

Game.Prefabs.InitialResourceItem

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: System.Object

Summary:
A small serializable container used by the prefab/editor system to store an initial resource stack for a prefab (e.g., a building, prop or item). The class is marked [Serializable] so Unity can serialize instances for saving and inspector display. It simply exposes a single public field that holds a ResourceStackInEditor describing the resource type and quantity to apply at initialization.


Fields

  • public ResourceStackInEditor m_Value
    Holds the resource stack data used by the prefab/editor. ResourceStackInEditor is defined elsewhere in the codebase and typically contains the resource type/ID and the amount. Because the field is public and the containing class is [Serializable], Unity can serialize it for prefab data and display it in the editor. If not assigned, this field will be null.

Properties

  • (none)

Constructors

  • public InitialResourceItem()
    The default parameterless constructor is provided by the runtime. It does not initialize m_Value (it will be null unless explicitly assigned).

Methods

  • (none)

Usage Example

// Create and populate an InitialResourceItem.
// ResourceStackInEditor members are illustrative — set actual fields according to its definition.
var initialItem = new InitialResourceItem
{
    m_Value = new ResourceStackInEditor
    {
        // resourceId = someResourceId,
        // amount = 100
    }
};

// When attaching to a prefab or serializing, ensure m_Value is not null.
if (initialItem.m_Value != null)
{
    // use initialItem.m_Value to apply resources to the prefab/item
}

Additional notes: - Because the class is [Serializable] and simple, it's intended for use in editor/prefab data rather than runtime logic. - When writing mods that interact with this type, perform null checks on m_Value and avoid assuming internal layout of ResourceStackInEditor without checking its definition in the game assembly (Assembly-CSharp).