making a button and text appear on collision????

I have a player and a crate. I want some text and 2 buttons to appear. Can you help me? I have no idea how to do it.

You can use OnCollisionEnter() function to instantiate text and button using Unity UI. If you are not familiar with Unity UI, google it you will find a lot of tutorials.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    
    public Button but;
    public Text tex;
    void Start()
    {
    }
    
    void OnCollisionEnter(Collision collision) {
         if(collision.gameObject.tag == "catre")
         {
              but.gameObject.SetActive(true);
              tex.gameObject.SetActive(true);
         }
    }
}

First, create a Monobehaviour script and attach it to the player or crate.
Then implement the OnCollisionEnter() method.
If the method is called, then a collision occured.
Now you can check which object was the other collider, if it is the other one (if attached to player, check for crate and vice versa), then you have a collision.
If that collision happend, you can enable the text and buttons.
Don’t forget to reference the objects in the inspector.

Example:

[SerializeField]
private GameObject crate;

[SerializeField]
private GameObject buttonAndTextDrawer;

public void OnCollisionEnter(Collision col)
{
    if(col.gameObject == crate)
    {
        buttonAndTextDrawer.SetActive(true);
    }
}

Note 1: I’ve writen this code from the top of my head, so if there are errors, please let me know so I can fix my post.

Note 2: Please ask nicely. One question mark is enough.
If you don’t believe me, consult the Answers guideline.

Greetings
Chillersanim

I don’t know why, but for reason it gives an error for the closing bracket in GameObject.SetActive(bool). It says unexpected symbol ‘)’, expecting ‘.’

@chillersanim
I don’t know why, but for reason it gives an error for the closing bracket in GameObject.SetActive(bool). It says unexpected symbol ‘)’, expecting ‘.’

I don’t know why, but for reason it gives an error for the closing bracket in GameObject.SetActive(bool). It says unexpected symbol ‘)’, expecting ‘.’

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {

[SerializeField]
private GameObject crate;
[SerializeField]
private GameObject buttonAndTextDrawer;

public void OnCollisionEnter(Collision col)
{
	if(col.gameObject == crate)
	{
		GameObject.SetActive(bool);
		buttonAndTextDrawer.enabled = true;
	}
}

}

this is my current code