Newer
Older
using System.Collections;
using UnityEngine;
Stefan Richter
committed
//using UnityEngine.EventSystems;
Stefan Richter
committed
using static UIconfig;
public class AlignText : MonoBehaviour
{
// Start is called before the first frame update
private Camera Cam;
public Camera Cam1;
public Camera Cam2;
Stefan Richter
committed
public Camera BackUPCam;
Stefan Richter
committed
StartCoroutine(CheckForNewMainCamRoutine());
Stefan Richter
committed
}
// Update is called once per frame
void Update()
{
//print("Cam" + Cam);
//CheckForNewMainCamRoutine();
transform.forward = Cam.transform.forward;
John Schihada
committed
//Not yet the perfect solution
//Problem is the relative rotation of the TextMesh to the Line-Parent
//transform.rotation = Quaternion.Lerp(transform.parent.transform.rotation, Cam.transform.rotation, 0);
//if (Moving_GObj) { }
Stefan Richter
committed
//Überprüfen ob Textfeld einen Collider hat, und wenn ja dieser aktiv sein soll
if (gameObject.GetComponent<BoxCollider>() != null)
{
if (UIconfig.controlMode == ControlMode.Keyboard) { gameObject.GetComponent<BoxCollider>().enabled = false; }
if (UIconfig.controlMode == ControlMode.Mobile) { gameObject.GetComponent<BoxCollider>().enabled = true; }
}
Stefan Richter
committed
Camera toCamMain()
{
if (Camera.main != null)
{
return Camera.main;
}
//return BackUPCam;
return Camera.main;
Stefan Richter
committed
}
IEnumerator CheckForNewMainCamRoutine()
{
yield return new WaitForSeconds(0);//Verzögerung für Bug aufhebung hinzugefügt, Bug selbst aktuell vergessen
switch (UIconfig.MainCameraID)
Stefan Richter
committed
Cam = toCamMain();
break;
case 1:
Cam = Cam1;
break;
case 2:
Cam = Cam2;
break;
default:
Stefan Richter
committed
Cam = toCamMain();
break;
}
//StopCoroutine(CheckForNewMainCamRoutine());
//print("Stopped:CheckForNewMainCamRoutine()");
//Cam = Camera.main;
}