Skip to content
Snippets Groups Projects
Select Git revision
  • d1267ba2f812e518d1bcbbf7dc74097bc2baef98
  • master default protected
  • no_scala_DSL
3 results

QueryDB.scala

Blame
  • AlignText.cs 2.14 KiB
    using System.Collections;
    using UnityEngine;
    //using UnityEngine.EventSystems;
    using static UIconfig;
    
    public class AlignText : MonoBehaviour
    {
        // Start is called before the first frame update
    
        private Camera Cam;
        public Camera Cam1;
        public Camera Cam2;
        public Camera BackUPCam;
        // public GameObject Moving_GObj;
    
    
        void Start()
        {
    
            StartCoroutine(CheckForNewMainCamRoutine());
    
        }
    
        // Update is called once per frame
        void Update()
        {
            //print("Cam" + Cam);
            //CheckForNewMainCamRoutine();
            if (Cam == null) { return; }
    
            transform.forward = Cam.transform.forward;
    
            //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) {  }
    
            //Ü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; }    
            }
        }
    
        Camera toCamMain()
        {
            if (Camera.main != null)
            {
                return Camera.main;
            }
            //return BackUPCam;
            return Camera.main;
        }
    
    
    
        IEnumerator CheckForNewMainCamRoutine()
        {
    
            yield return new WaitForSeconds(0);//Verzögerung für Bug aufhebung hinzugefügt, Bug selbst aktuell vergessen
            switch (UIconfig.MainCameraID)
            {
                case 0:
                    Cam = toCamMain();
                    break;
                case 1:
                    Cam = Cam1;
                    break;
                case 2:
                    Cam = Cam2;
                    break;
                default:
                    Cam = toCamMain();
                    break;
            }
            //StopCoroutine(CheckForNewMainCamRoutine());
            //print("Stopped:CheckForNewMainCamRoutine()");
            //Cam = Camera.main;
        }
    
    }