FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.

Share

descriptionOnCollision I wish text to be displayed.

more_horiz
Basicially, when a collision occurs I wish for my UI text to be displayed. Here is the method I am using to accomplish this, the script is attached to my UI Text GameObject:

Code:

using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
public class text : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
          
        GetComponent<Text>().enabled = false;
 
     }
    
    
        
 
        
    void OnCollisionEnter2D(Collision2D Man)
         {
            if (Man.gameObject.tag == "house")
                 GetComponent<Text>().enabled = true;
            
         }
 
  }
 
 


Within Void Start I can successfully enable and disable the UI Text, however within the OnCollisionEnter2D, the GetComponent<Text>().enabled = true; just doesn't get recognised when a collision is made and so the text doesn't become true (doesn't show). I can confirm that a collision is detected, so that's not the problem.. I suspect it's something to do with the .enabled method? Could somebody help me with this.

descriptionRe: OnCollision I wish text to be displayed.

more_horiz
why don't you try using event trigger for UI.Text
Permissions in this forum:
You cannot reply to topics in this forum