arskrald/AR-3/Assets/make_text.cs

47 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class make_text : MonoBehaviour, ITrackableEventHandler
{
private TrackableBehaviour mTrackableBehaviour;
private TextMesh textQuad;
public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
{
if (newStatus == ImageTargetBehaviour.Status.TRACKED ||
newStatus == ImageTargetBehaviour.Status.DETECTED ||
newStatus == ImageTargetBehaviour.Status.EXTENDED_TRACKED)
{
if (gameObject.name == "del")
{
textQuad.text = textQuad.text.Remove(textQuad.text.Length - 1);
}
else
{
textQuad.text += gameObject.name;
}
}
}
// Start is called before the first frame update
void Start()
{
textQuad = GameObject.Find("TextQuad").GetComponent<TextMesh>();
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour)
{
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
}
// Update is called once per frame
void Update()
{
}
}