Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Vuforia;
- public class MyTrackableEventHandler : MonoBehaviour, ITrackableEventHandler
- {
- private bool mShowLabel = false;
- public Vector3 pos;
- // Start is called before the first frame update
- void Start()
- {
- GetComponent<TrackableBehaviour>().RegisterTrackableEventHandler(this);
- }
- public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus,
- TrackableBehaviour.Status newStatus)
- {
- if ( newStatus == TrackableBehaviour.Status.DETECTED ||
- newStatus == TrackableBehaviour.Status.TRACKED ||
- newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED )
- {
- mShowLabel = true;
- }
- else
- {
- mShowLabel = false;
- }
- }
- void OnGUI()
- {
- if(mShowLabel)
- {
- GUI.color = Color.red;
- GUI.Label(new Rect(50, 50, 500, 500), "Imagem rastreada");
- }
- }
- Transform houseTransform;
- void GetHouseTransform()
- {
- GameObject go = GameObject.Find("ImageOat");
- if (go != null)
- {
- houseTransform = go.transform
- }
- else
- {
- Debug.Log("House not found");
- }
- }
- // Update is called once per frame
- void Update()
- {
- GetHouseTransform();
- distance = Vector3.distance(transform.position, houseTransform);
- if (distance < 5)
- {
- Debug.Log("THEY ARE CLOSE");
- }
- else
- {
- Debug.Log("THEY ARENT CLOSE");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment