Show a photo when hitting a collider

Hi,
I work on a simple 2D jump and run game, SuperMario style. Whenever the player hits a coin, I want to:

  • pause the game
  • Show a splash screen with a text and image
  • remove the coin

I am quite far on the first two, but I would like to be able to show a different text and image for each coin. So I would like to have a public field in unity where i can drag in the photo object and another to type in the photo text, for each of the coins. Could you please help me?


using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;



public class Show_Photo : MonoBehaviour
{
    public GameObject Overlay;
    public Image Photo;
    public TextEditor PhotoText;
    
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("Object that entered the trigger : " + other);
        if (other.CompareTag("Player"))
        {
            // Update Photo

            // Show overlay
            Overlay.SetActive(true);
            // Update Headline

            // Pause Game
            Time.timeScale = 0;
        }
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
          // Remove coin

           // resume game
            Overlay.SetActive(false);
            Time.timeScale = 1;
        }
    }
}

I think I solved it. Maybe not perfect, but it works. Would be great if I wouldn’t have to assign the container objects in the inspector window, but could hard-code them into the code…

using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;



public class Show_Photo : MonoBehaviour
{
    public GameObject Overlay;
    public Image PhotoField;
    public Text PhotoTextField;
    public string PhotoText;
    public Sprite Photo;


    bool PhotoRing = false;



    private void OnTriggerEnter2D(Collider2D other)
    {
        
        Debug.Log("Object that entered the trigger : " + other);
        if (other.CompareTag("Player"))
        {
            // Pause Game
            Time.timeScale = 0;
            PhotoRing = true;
            // Update Photo
            PhotoField.sprite = Photo;
            // Update Headline
            PhotoTextField.text = PhotoText;
            // Show overlay
            Overlay.SetActive(true);

        }
    }
    private void Update()
    {
        if (PhotoRing == true && Input.GetKeyDown(KeyCode.Space))
        {
            Overlay.SetActive(false);
            PhotoRing = false;
            Time.timeScale = 1;
            Destroy(this.gameObject);
        }
    }

}