Question by
nickilak · Jul 09, 2016 at 09:34 PM ·
ontriggerenter
OnTriggerEnter Message Panel trouble!
I'm having trouble having a small message window pop on screen inside of a canvas when my character walks onto a small button. This is the coding that I have on my canvas:
and Second:
Comment
Edit: wow that was messed up, first script:
public class $$anonymous$$essenger : $$anonymous$$onoBehaviour
{
public GameObject messagePanel;
public Text msgFrom;
public Text msgBody;
private bool show$$anonymous$$sg = false;
private float showTime = 0;
private Inventory backpack;
void Update()
{
if (messagePanel.activeSelf != show$$anonymous$$sg)
messagePanel.SetActive(show$$anonymous$$sg);
if (showTime > 0)
{
showTime -= Time.deltaTime;
}
else
{
show$$anonymous$$sg = false;
}
}
public void New$$anonymous$$essage(string from, string body, float displayTime)
{
showTime = displayTime;
msgFrom.text = from;
msgBody.text = body;
show$$anonymous$$sg = true;
}
}
Second:
public class NameShow : $$anonymous$$onoBehaviour {
public $$anonymous$$essenger messagePanel;
// Use this for initialization
void Start () {
}
void OnTriggerEnter(Collider entity)
{
messagePanel.New$$anonymous$$essage("Name:","Nicholas Levanti", 5);
}
// Update is called once per frame
void Update () {
}
}
Your answer
Follow this Question
Related Questions
Destroy object on hover? 1 Answer
Moving an Object Using a Trigger 0 Answers
Collider dosent detect trigger 0 Answers
OnTriggerEnter and OnTriggerExit called twice despite checking it 1 Answer