The Hidden Object Template relies on a decoupled, data-driven architecture optimized for linear and branching search-and-find mechanics. The core gameplay loop isolates click detection, puzzle validation, and UI list updates using C# Action delegates and ScriptableObject definitions. This prevents rigid dependencies between scene-rendered colliders and Canvas UI elements.
Central to the framework is a data abstraction tier. Interactive objects are defined via HiddenItemData ScriptableObjects, which act as single sources of truth for item identifiers, UI icons, target localized strings, and audio clip assignments. Scene-placed items bind to these assets through a lightweight HiddenObjectInteractable component, minimizing scene file size and streamlining batch edits.
To eliminate expensive continuous polling in Update() cycles, interaction processing operates entirely on event streams. When a player taps or clicks an item in the viewport, an input handler emits an interaction payload. The system validates whether the clicked entity belongs to the current target search array, fires localized collection effects, and updates the search inventory panel without triggering layout recalculations across unrelated Canvas components.
using System;
using UnityEngine;
namespace HiddenObjectTemplate.Core
{
public class HiddenObjectInteractable : MonoBehaviour
{
[SerializeField] private HiddenItemData itemData;
public static event Action<HiddenItemData, Vector3> OnItemFound;
public HiddenItemData ItemData => itemData;
public bool TryCollect()
{
if (itemData == null) return false;
OnItemFound?.Invoke(itemData, transform.position);
gameObject.SetActive(false);
return true;
}
}
}
The system features streamlined inspector drawers and custom editor scripts that automate level layout and list assignment. Creating a level layout requires tagging target interactive game objects and configuring scene-wide level data parameters.
HiddenObjectInteractable transforms.Designers configure levels by dropping static visual assets into the hierarchy, attaching a Collider2D or Collider, and assigning the corresponding HiddenItemData. Editor scripts feature automated level verification utilities that highlight duplicate object IDs or missing collider references prior to build compilation.
Integrating the template into an existing or new Unity project involves a standardized setup sequence that establishes manager prefabs and initial level data.
Drag the [HiddenObjectCore] prefab into your active scene hierarchy. This prefab encapsulates the HiddenObjectManager, InputHandler, HintController, and the base UI Canvas structures.
Create a new Level Data asset via Assets > Create > Hidden Object System > Level Data. Populate the target item array with pre-configured HiddenItemData ScriptableObjects.
Assign the HiddenObjectInputHandler to your main camera or system root. The input handler utilizes non-allocating physics raycasts to evaluate user input against 2D or 3D physics layers, preventing garbage collection allocations during user interaction.
using UnityEngine;
namespace HiddenObjectTemplate.Input
{
public class HiddenObjectInputHandler : MonoBehaviour
{
[SerializeField] private Camera targetCamera;
[SerializeField] private LayerMask interactableLayer;
private readonly RaycastHit2D[] hitBuffer = new RaycastHit2D[4];
private void Update()
{
if (!UnityEngine.Input.GetMouseButtonDown(0)) return;
Ray ray = targetCamera.ScreenPointToRay(UnityEngine.Input.mousePosition);
int count = Physics2D.GetRayIntersectionNonAlloc(ray, hitBuffer, float.MaxValue, interactableLayer);
for (int i = 0; i < count; i++)
{
if (hitBuffer[i].collider.TryGetComponent<Core.HiddenObjectInteractable>(out var interactable))
{
if (interactable.TryCollect()) break;
}
}
}
}
}
The framework maintains low memory overhead and steady frame times across mobile, web, and desktop target platforms. Execution profiling highlights several performance optimization strategies inherent in the C# source design.
Physics2D.GetRayIntersectionNonAlloc avoids array generation on every user click, preventing garbage collector spikes on touch-driven mobile devices.List<T> and fixed arrays. This minimizes C++ code expansion when compiling under IL2CPP across iOS and Android platforms.Instantiate() overhead during active gameplay.| Category | Templates / Systems |
|---|---|
| Latest Version | v1.7 |
| File Size | 73.39 MB |
| Added to Platform | February 6, 2026 |
| Views | 3 views |
| Downloads | 1 downloads |
| Favourites | 0 favourites |
| Issue with Package? | Report Broken Link → |