Skip to content
Snippets Groups Projects
Select Git revision
  • bf784d4ae87d6eba98ab1ac1d2f6062e16ad44f0
  • main default protected
  • alazar_issues
  • atsaverage_extra
  • spectrometer/alazar_driver
  • v2025.7.1 protected
  • v2025.3.1 protected
  • v2024.11.1 protected
  • v2024.9.19-rc1 protected
  • v2024.7.1 protected
  • v2023.7.1 protected
  • v2023.6.1 protected
12 results

simulator.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    LHMTurnAroundMenuController.cs 1.57 KiB
    using UnityEngine;
    using System.Collections;
    
    public class LHMTurnAroundMenuController : MonoBehaviour {
    
        public float sensitivity = 100f;
        private float distance = -0.03f;
    
        private SteamVR_TrackedController trackedObjeckt;
        private SteamVR_Controller.Device device;
        private Transform pos;
        private Vector3 posoffset;
        private Vector2 actPadPos;
        private Vector2 lastPadPos;
        private float dif;
        private bool istouched;
    
        void Start()
        {
            trackedObjeckt = GetComponentInParent<SteamVR_TrackedController>();
            trackedObjeckt.PadTouched += Controller_PadTouched;
            trackedObjeckt.PadUntouched += Controller_PadUntouched;
            device = SteamVR_Controller.Input((int)trackedObjeckt.controllerIndex);
            pos = gameObject.transform.parent.FindChild("Model").transform;
            posoffset.Set(0f, distance, 0f);
            gameObject.transform.localPosition = posoffset;
        }
    
        void LateUpdate()
        {
    
            if (istouched)
            {
                actPadPos = device.GetAxis();
                dif = lastPadPos.x - actPadPos.x;
                gameObject.transform.RotateAround(pos.position + posoffset, pos.forward, dif * sensitivity);
                gameObject.transform.localPosition = posoffset;
                lastPadPos = actPadPos;
            }
        }
    
        private void Controller_PadUntouched(object sender, ClickedEventArgs e)
        {
            istouched = false;
        }
    
        private void Controller_PadTouched(object sender, ClickedEventArgs e)
        {
            lastPadPos = device.GetAxis();
            actPadPos = device.GetAxis();
            istouched = true;
        }
    }