Newby - best way store trigger link to another (gui) object

Hi … apologies for this newbie question… I appreciate that this answer will already be out there somewhere!

I am quickly trying to help my son create a walkthrough (using the great viking village) for a school assignment.

At a number of points in the village, I want to place a trigger object that will activate a matching information image on the canvas (with some exciting fact about viking like) , and which will then deactivate on click or trigger exit.

I’m not looking for exact code, but would appreciate some advice or pointers to tutorials as to the best way (without hard coding) to link the trigger object with the info image in order to activate it, deactivate it and log it as being seen.

I use this code to deactivate the infoScreens off at the start, and assumed that there would be some clever way to link the collider with the screen.

infoScreens = GameObject.FindGameObjectsWithTag("infoScreenTag");
		for(int i = 0; i < infoScreens.Length; i++)
		{
			Debug.Log("I found this infoscreen "+i+" named "+infoScreens*.name);*

_ infoScreens .SetActive (false);_
* }*

Thanks in advance all of you

Hey the_gumby,

I think what you have to do is creating one canvas with a text inside. Than you create a single code that are using the functions OnTriggerEnter() and OnTriggerExit().

there you set first the text to the specific one you want in this trigger. And then simply activate the canvas. After that you have to close it again, for example when walking out of the trigger:

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

public class TriggerWalking : MonoBehaviour {

    public Canvas UiCanvas; // This is you single Canvas you have; Set this in the inspector
    public Text Informationtext; // This is the Text in your canvas you want to show the information; Set this in the inspector
    public string information; // This is the Information you want to show when walking throw this trigger; Set this in the inspector

    // Open UI when exit the Trigger
    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Player")  //Make sure the ui opens only, when the player walks in the trigger
        {
            Informationtext.text = information; // here you set the information to the 1 canvas you have
            UiCanvas.gameObject.SetActive(true);
        }
    }

    // Close UI when exit the Trigger
    void OnTriggerExit(Collider col)
    {
        if (col.tag == "Player")  //Make sure the ui closes only, when the player walks in the trigger
        {
            Informationtext.text = information; // here you set the information to the 1 canvas you have
            UiCanvas.gameObject.SetActive(false);
        }
    }
}

Than you can simply clone your triggers and just change the information variable in the inspector to have another text.

I have done a small projekt for you, where you can see exactly that:

http://s000.tinyupload.com/?file_id=00286269081195273050

I hope I have interpreted your question right and i could help.

Julian