Popup Spawner

2 min read

Updated on November 21, 2025

Introduction

Add as a child to either a Resource Node, Item Container or Crafter to spawn popups. It hooks in to the Actions provided to spawn.

Setting up

There is a prefab Popup Spawner located in /prefabs/UI.

Setting up without the prefab is easy and only requires a Popup prefab which contains the Popup component and setting Distance and Fade Rise Duration.

Popups spawn from the position of this component’s transform and have a handy gizmo to show where they will end up.

Popups also parent directly under a transform created at runtime by the Resource And Production Manager for tidyness and for when the originating object gets destroyed, the popup does not go with it and has its own lifetime.

Settings

Popup Prefab
Assign a Popup gameobject/prefab to instantiate. This gameobject should contain the Popup component for this to work.

Rise Distance
How far the Popup will rise up once instantiated.

Rise Fade Duration
How long will it take for the Popup to rise and fade once instantiated.

Rise Curve
Assign a custom easing to the Popup over its Rise Fade Duration.

Scripting

/// <summary>
/// Manually add a popup to be spawned
/// </summary>
/// <param name="itemAmount">The ItemAmount to use for the Item's Icon and the Amount</param>
/// <param name="added">Use "+" if added or "-" before the Amount</param>
public void SpawnPopupDirect(ItemAmount itemAmount, bool added = true)

//The Start function in this component - 
private void Start()
{
    if (resourceNode != null)
        resourceNode.OnResourceTriggerAction += (itemAmount) => StartCoroutine(SpawnPopup(itemAmount, true));

    if (itemContainer != null)
    {
        itemContainer.OnItemAmountAddAction += (itemAmount) => StartCoroutine(SpawnPopup(itemAmount, true));
        itemContainer.OnItemAmountRemoveAction += (itemAmount) => StartCoroutine(SpawnPopup(itemAmount, false));
    }

    if (crafter != null)
        crafter.OnCraftAndStoreAction += (itemAmount, ItemContainer) => StartCoroutine(SpawnPopup(itemAmount, true));
}

//You could hook up very similar actions for your own ItemAmounts to spawn