n/a

:stuck_out_tongue:

If you want the cube to be destroyed when the UI with the question appears, then you have to create a new game object (it can be an empty object, so it is not drawn on the screen) and attach your GUIScreen script to that object. Make an “Ebola” variable public in the GUIScreen script. Then create a reference to the GUIScreen in the “Trigger” script and finally in the OnTriggerEnter function set the “Ebola” variable of the GUIScreen class to true (before destroying the cube object).

Alternatively you could move the GUI code to the “Trigger” script and when the trigger is activated (in the OnTriggerEnter function) you would disable the renderer and collider components of the cube and then when the user will click on one of the answer buttons, you could destroy the cube object.

And finally if you are planning to do a UI heavy game, I would strongly recommend to use our new UI instead of the legacy GUI. You can learn about it here: Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn

So your scripts will look something like this.

using UnityEngine;
using System.Collections;

public class Trigger : MonoBehaviour
{
    public GameObject guiObject;

    private GUIScreen guiScript;

    void Awake ()
    {
        guiScript = guiObject.GetComponent<GUIScreen> ();
    }

    void OnTriggerEnter (Collider other)
    {
        guiScript.Ebola = true;
        Destroy (this.gameObject);
    }
}

and

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

public class GUIScreen : MonoBehaviour
{
    public bool Ebola;

    // your other code to show questions
}

Then at the end of your “HandleAnswer” function set the Ebola variable to false.
Select your cube in Unity editor and in the “Inspector” panel you will see a “guiObject” value. From the “Hierarchy” panel drag the ui object (which has “GUIScreen” script attached to it) to that “guiObject” value.
This should work.

Also you could tag your ui object (e.g. “Questions”) and then instead of

guiScript = guiObject.GetComponent<GUIScreen> ();

you could use

guiScript = GameObject.FindWithTag("Questions").GetComponent<GUIScreen> ();

This way you would not need a “public GameObject guiObject;” variable and would not need to drag the ui object in the editor. You can read about tags here Unity - Manual: Tags