11eimilia11

HELP

Nov 11th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Vuforia;
  5.  
  6. public class MyTrackableEventHandler : MonoBehaviour, ITrackableEventHandler
  7. {
  8.     private bool mShowLabel = false;
  9.     public Vector3 pos;
  10.  
  11.  
  12.  
  13.  
  14.     // Start is called before the first frame update
  15.     void Start()
  16.     {
  17.         GetComponent<TrackableBehaviour>().RegisterTrackableEventHandler(this);
  18.  
  19.        
  20.        
  21.     }
  22.  
  23.     public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus,
  24.         TrackableBehaviour.Status newStatus)
  25.     {
  26.         if ( newStatus == TrackableBehaviour.Status.DETECTED ||
  27.         newStatus == TrackableBehaviour.Status.TRACKED ||
  28.         newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED )
  29.         {
  30.             mShowLabel = true;
  31.         }
  32.         else
  33.         {
  34.             mShowLabel = false;
  35.         }
  36.     }
  37.  
  38.     void OnGUI()
  39.     {
  40.         if(mShowLabel)
  41.         {
  42.             GUI.color = Color.red;
  43.             GUI.Label(new Rect(50, 50, 500, 500), "Imagem rastreada");
  44.         }
  45.  
  46.     }
  47.  
  48. Transform houseTransform;
  49.  
  50. void GetHouseTransform()
  51. {
  52.     GameObject go = GameObject.Find("ImageOat");
  53.  
  54.     if (go != null)
  55.     {
  56.         houseTransform = go.transform
  57.     }
  58.  
  59.     else
  60.     {
  61.         Debug.Log("House not found");
  62.     }
  63.  
  64. }
  65.     // Update is called once per frame
  66.    void Update()
  67.     {
  68.         GetHouseTransform();
  69.        
  70.         distance = Vector3.distance(transform.position, houseTransform);
  71.  
  72.         if (distance < 5)
  73.         {
  74.             Debug.Log("THEY ARE CLOSE");
  75.         }
  76.  
  77.         else
  78.         {
  79.  
  80.             Debug.Log("THEY ARENT CLOSE");
  81.         }
  82.  
  83.  
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment