nea game doesnt allow me to present and click on sprites
08:24 23 Nov 2025

hey so im making a game for my nea and i have tried multiple times to make me as a user of the game to press on documents that my charecter pressents and the be able to interact with it i have check with chatgpt and it says my code is ok but the clicks on the sprite do not render and now the sprites dont even show

please help

the code:

using System.Collections.Generic;
using UnityEngine;

public class DocumentManager : MonoBehaviour
{
    [Header("Assign document prefabs (different ID cards, etc.)")]
    public GameObject[] documentPrefabs;

    [Header("Parent for spawned docs (optional)")]
    public Transform container;

    [Header("How many to spawn (will clamp to number of prefabs)")]
    public int spawnCount = 3;

    // Keep references so we don't spawn duplicates
    private readonly List spawned = new List();

    // Call this when character reaches center
    public void ShowDocuments()
    {
        if (spawned.Count > 0) return; // already spawned
        if (documentPrefabs == null || documentPrefabs.Length == 0) return;

        Camera cam = Camera.main;
        if (cam == null)
        {
            Debug.LogError("No main camera found.");
            return;
        }

        // center world point — using a z that is the same plane as your docs (0)
        Vector3 screenCenter = new Vector3(Screen.width / 2f, Screen.height / 2f, Mathf.Abs(cam.transform.position.z));
        Vector3 worldCenter = cam.ScreenToWorldPoint(screenCenter);
        worldCenter.z = 0f;

        // choose how wide the documents spread (units)
        float spread = 1.2f;
        int toSpawn = Mathf.Clamp(spawnCount, 1, documentPrefabs.Length);

        // spawn evenly around center
        int midIndex = toSpawn / 2;
        for (int i = 0; i < toSpawn; i++)
        {
            int prefabIndex = i % documentPrefabs.Length;
            Vector3 pos = worldCenter + new Vector3((i - midIndex) * spread, 0f, 0f);
            GameObject prefab = documentPrefabs[prefabIndex];
            GameObject go = Instantiate(prefab, pos, Quaternion.identity, container);
            spawned.Add(go);
        }
    }

    // Removes and destroys spawned documents
    public void ClearDocuments()
    {
        foreach (var g in spawned) if (g != null) Destroy(g);
        spawned.Clear();
    }

    // Convenience: spawn from inspector
#if UNITY_EDITOR
    [UnityEditor.MenuItem("Tools/SpawnDocs_Debug")]
    private static void DebugSpawn() { }
#endif
}
c# unity-game-engine sprite