- Home /
GUI trigger help (C#)
Hi Guys, I have had this problem for a while. Basiclly i am making 2d platform game and i am trying to make it so when the player hits the finish flag the gui show up. i already have a script for this but it never works i dont know why. FYI i have just started learning c#
Thank You
Script
using UnityEngine;
using System.Collections;
public class Level_Finish : MonoBehaviour {
public GUITexture finishFlag;
void Start () {
finishFlag.enabled = false;
}
void OnTriggerEnter(Collider col){
if (col.tag == "Player") {
finishFlag.enabled = true;
}
}
}
Comment
Answer by Maui-M · Feb 25, 2014 at 05:11 PM
You need to put your GUI code in OnGui to render it. GUI Basics
using UnityEngine;
using System.Collections;
public class Level_Finish : MonoBehaviour {
public Texture finishTexture;
private bool bFinish = false;
void Start () {
bFinish = false;
}
void OnTriggerEnter(Collider col){
if (col.tag == "Player") {
bFinish = true;
}
}
void OnGui() {
GUI.Box(new Rect(10,10,100,90), finishTexture);
}
}
Your answer
Follow this Question
Related Questions
Store/Stack Items 0 Answers
Distribute terrain in zones 3 Answers
Equivelant of GUI.DrawSprite() ? 0 Answers
Problem with playmaker gui and "Get mouse button down" action. 1 Answer
UIText not updating on Android build 0 Answers