63 lines
1.9 KiB
C#
63 lines
1.9 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)
|
|
{
|
|
|
|
var rotation = gameObject.transform.rotation.eulerAngles.y;
|
|
print($"The rotation: {rotation}");
|
|
print($"rotation / 45: {rotation / 45}");
|
|
var letter = gameObject.name[(int)(rotation / 45)].ToString();
|
|
print($"The letter: {letter}");
|
|
|
|
|
|
if (letter == "1")
|
|
{
|
|
textQuad.text = textQuad.text.Remove(textQuad.text.Length - 1);
|
|
}
|
|
else if (letter == "0")
|
|
{
|
|
textQuad.text += " ";
|
|
} else if (letter == "9")
|
|
{
|
|
textQuad.text += "<3";
|
|
}
|
|
else
|
|
{
|
|
textQuad.text += letter;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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()
|
|
{
|
|
var rotation = gameObject.transform.rotation.eulerAngles.y;
|
|
print($"The rotation: {rotation}");
|
|
print($"rotation / 45: {rotation / 45}");
|
|
}
|
|
}
|