Displaying GUI on Collision?

Hey guys, I’m trying to only display a GUI once it has hit an object, however I can’t seem to use OnCollisionEnter2D at all for it because of being inside of if statements. Below I’ll post the scripts and see if you guys can think of anything? It’d be much appreciated.

d6GUIController

using UnityEngine;
using System.Collections;

public class d6GUIController : MonoBehaviour {

    public GameObject d6GUI;
    public GameObject d6_0;
    public GameObject d6_1;
    public GameObject d6_2;
    public GameObject d6_3;
    public GameObject d6_4;
    public GameObject d6_5;
    public GameObject d6_6;

    public bool d6_0b;
   
    void Start()
    {
        D6Reset();
    }

    public void D6Reset ()
    {
        d6_0.SetActive (true);
        d6_1.SetActive (false);
        d6_2.SetActive (false);
        d6_3.SetActive (false);
        d6_4.SetActive (false);
        d6_5.SetActive (false);
        d6_6.SetActive (false);
        d6_0b = true;
    }

    public void RolledD6For1 ()
    {
        if(d6_0 == true)
        {
            d6_1.SetActive (true);
            d6_0.SetActive (false);
            d6_0b = false;

        }
    }

    public void RolledD6For2 ()
    {
            if(d6_0 == true)
        {

            d6_0.SetActive (false);
            d6_2.SetActive (true); 
            d6_0b = false;
        }
    }

    public void RolledD6For3 ()
    {
        if(d6_0 == true)
        {
            d6_0.SetActive (false);
            d6_3.SetActive (true);
            d6_0b = false;
        }
    }

    public void RolledD6For4 ()
    {
        if(d6_0 == true)
        {
            d6_0.SetActive (false);
            d6_4.SetActive (true);
            d6_0b = false;
        }
    }

    public void RolledD6For5 ()
    {
        if(d6_0 == true)
        {
            d6_0.SetActive (false);
            d6_5.SetActive (true); 
            d6_0b = false;
        }
    }

    public void RolledD6For6 ()
    {
        if(d6_0 == true)
        {
            d6_0.SetActive (false);
            d6_6.SetActive (true); 
            d6_0b = false;
        }
    }
}

Then the DiceSpawn script that calls the GUI functions

using UnityEngine;
using System.Collections;

public class DiceSpawn : MonoBehaviour {

    public GameObject d6; // D6 Prefab
    public Transform throwPoint;
    public bool HasDice; // Have you picked up the dice?

    public d6GUIController d6gui; // Roll Display

    // Use this for initialization
    void Start () {

        HasDice = true;
        d6gui = GameObject.Find("d6GUI").GetComponent<d6GUIController>();

    }
   
    // Update is called once per frame
    void Update () 
    {
        if(Input.GetKeyDown(KeyCode.Mouse0))
        {
            int randNum = Random.Range(1,7);
            if(randNum == 1) // Rolled a 1
            {
                d6.GetComponent<DiceV2>().damageToGive = 1f;
                if(d6gui.GetComponent<d6GUIController>().d6_0b == true)
                {
                    d6gui.GetComponent<d6GUIController>().RolledD6For1();
                }
            }
           
            if(randNum == 2) // Rolled a 2
            {
                d6.GetComponent<DiceV2>().damageToGive = 2f;
                if(d6gui.GetComponent<d6GUIController>().d6_0b == true)
                {
                    d6gui.GetComponent<d6GUIController>().RolledD6For2();
                }
            }
           
            if(randNum == 3) // Rolled a 3
            {
                d6.GetComponent<DiceV2>().damageToGive = 3f;
                if(d6gui.GetComponent<d6GUIController>().d6_0b == true)
                {
                    d6gui.GetComponent<d6GUIController>().RolledD6For3();
                }
            }
           
            if(randNum == 4) // Rolled a 4
            {
                d6.GetComponent<DiceV2>().damageToGive = 4f;
                if(d6gui.GetComponent<d6GUIController>().d6_0b == true)
                {
                    d6gui.GetComponent<d6GUIController>().RolledD6For4();
                }
            }
           
            if(randNum == 5) // Rolled a 5
            {
                d6.GetComponent<DiceV2>().damageToGive = 5f;
                if(d6gui.GetComponent<d6GUIController>().d6_0b == true)
                {
                    d6gui.GetComponent<d6GUIController>().RolledD6For5();
                }
            }
           
            if(randNum == 6) // Rolled a 6
            {
                d6.GetComponent<DiceV2>().damageToGive = 10f;
                if(d6gui.GetComponent<d6GUIController>().d6_0b == true)
                {
                    d6gui.GetComponent<d6GUIController>().RolledD6For6();
                }
            }

            if(HasDice){
            Instantiate (d6,throwPoint.position,Quaternion.identity);
            Debug.Log(d6.GetComponent<DiceV2>().damageToGive);
            HasDice = false; 
            }
        }
    }

    public void OnCollisionEnter2D(Collision2D other) // Dice Pickup System
    {
        if(other.collider.tag == "Dice")
        {
            HasDice = true;
            Destroy(other.gameObject);
            d6gui.GetComponent<d6GUIController>().D6Reset();
        }
    }
}

I’ve done something similar by just turning the UI text on when my player collides with something. I have a timer that is set at the same time & countsdown. When it reaches 0 I turn that bit of the UI off.

From memory I have the one canvas with lots of different text & image elements around the screen. Some of these are always on, some are specifically turned on & off depending on actions, & some are common text boxes that are turned on & off with different text used depending on the player action.

Sorry, I don’t have access to the code atm

d6gui =GameObject.Find("d6GUI").GetComponent<d6GUIController>();

...

d6gui.GetComponent<d6GUIController>().<.....>

why are you gettting the d6GUIController component from the d6GUIController component? once you’ve got the reference “d6gui” intitialised it really should all just be

d6gui.<.....>

from there on.