internal static XRInteractionManager CreateInteractionManager() { GameObject managerGO = new GameObject(); XRInteractionManager manager = managerGO.AddComponent <XRInteractionManager>(); return(manager); }
XRInteractablesTreeView(XRInteractionManager manager, TreeViewState state, MultiColumnHeader header) : base(state, header) { m_InteractionManager = manager; showBorder = false; rowHeight = k_RowHeight; Reload(); }
// Start is called before the first frame update void Start() { startPos = this.transform.position; cam = Camera.main; ball = this.gameObject; mgr = GameObject.Find("XR Interaction Manager").GetComponent <XRInteractionManager>(); InvokeRepeating("PositionChecker", 5, 5); }
private void Awake() { leftHand = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/LeftHand"); rightHand = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/RightHand"); _interactionManager = this.FindComponent <XRInteractionManager>("XR Interaction Manager"); locomotionSystem = this.FindGameObject("Locomotion System"); _mainCamera = this.FindComponent <Camera>("XR Origin/Camera Offset/Main Camera"); leftXRRayInteractor = LeftController.GetComponent <XRRayInteractor>(); rightXRRayInteractor = RightController.GetComponent <XRRayInteractor>(); }
public static void Create() { xrInteractionManagerInstance = GameObject.FindObjectOfType <XRInteractionManager>(); if (xrInteractionManagerInstance == null) { xrInteractionManagerInstance = new GameObject("XRInteractionManager", typeof(XRInteractionManager)).GetComponent <XRInteractionManager>(); GameObject.DontDestroyOnLoad(xrInteractionManagerInstance.gameObject); } SceneManager.sceneLoaded += SceneManager_sceneLoaded; }
void AddManager(XRInteractionManager manager) { if (m_InteractionManagers.Contains(manager)) { return; } manager.interactableRegistered += OnInteractableRegistered; manager.interactableUnregistered += OnInteractableUnregistered; m_InteractionManagers.Add(manager); Reload(); }
void RemoveManager(XRInteractionManager manager) { if (!m_InteractionManagers.Contains(manager)) { return; } if (manager != null) { manager.interactableRegistered -= OnInteractableRegistered; manager.interactableUnregistered -= OnInteractableUnregistered; } m_InteractionManagers.Remove(manager); Reload(); }
public static XRInteractablesTreeView Create(XRInteractionManager interactionManager, ref TreeViewState treeState, ref MultiColumnHeaderState headerState) { if (treeState == null) { treeState = new TreeViewState(); } var newHeaderState = CreateHeaderState(); if (headerState != null) { MultiColumnHeaderState.OverwriteSerializedFields(headerState, newHeaderState); } headerState = newHeaderState; var header = new MultiColumnHeader(headerState); return(new XRInteractablesTreeView(interactionManager, treeState, header)); }
protected virtual void Awake() { Reset(); CheckPrefabs(); CheckEventSystem(); _vrManager = QuickSingletonManager.GetInstance <QuickVRManager>(); _xrInteractionManager = QuickSingletonManager.GetInstance <XRInteractionManager>(); _interactorHandLeft = transform.CreateChild("__InteractorHandLeft__").GetOrCreateComponent <QuickVRInteractor>(); _interactorHandLeft._xrNode = XRNode.LeftHand; _interactorHandRight = transform.CreateChild("__InteractorHandRight__").GetOrCreateComponent <QuickVRInteractor>(); _interactorHandRight._xrNode = XRNode.RightHand; //By default, disable all the locomotion providers foreach (DefaultLocomotionProvider lProvider in QuickUtils.GetEnumValues <DefaultLocomotionProvider>()) { EnableLocomotionSystem(lProvider, false); } BaseTeleportationInteractable[] teleportationInteractables = FindObjectsOfType <BaseTeleportationInteractable>(); foreach (BaseTeleportationInteractable t in teleportationInteractables) { t.teleportationProvider = _teleportProvider; } _grabInteractables = new List <XRGrabInteractable>(FindObjectsOfType <XRGrabInteractable>()); foreach (XRGrabInteractable g in _grabInteractables) { if (!g.attachTransform) { //Try to find the default attach transform g.attachTransform = g.transform.Find(GRAB_PIVOT_NAME); } } }
public ControllerWithRayInteractor( XRInteractionManager interactionManager, XRNode node, string gameObjectName, bool constructScene) : base(node: node, gameObjectName: gameObjectName, constructScene: constructScene) { if (constructScene) { LineRenderer = GameObject.AddComponent <LineRenderer>(); LineRenderer.numCornerVertices = 4; LineRenderer.numCapVertices = 4; string lineMaterialResourcePath = "GemPlay/Materials/XRRaycast"; var material = Resources.Load(lineMaterialResourcePath) as Material; if (material == null) { Debug.LogError("Found nothing at " + lineMaterialResourcePath); } LineRenderer.material = material; LineRenderer.sortingOrder = 5; XRRayInteractor = GameObject.AddComponent <XRRayInteractor>(); XRInteractorLineVisual = GameObject.AddComponent <XRInteractorLineVisual>(); XRInteractorLineVisual.lineWidth = 0.005f; XRInteractorLineVisual.lineLength = 2.0f; var invalidGradientColorKey = new GradientColorKey[2]; invalidGradientColorKey[0].color = Color.white; invalidGradientColorKey[1].color = Color.white; var alphaKey = new GradientAlphaKey[2]; alphaKey[0].alpha = 1.0f; alphaKey[0].time = 0.0f; alphaKey[1].alpha = 0.0f; alphaKey[1].time = 1.0f; XRInteractorLineVisual.invalidColorGradient.SetKeys(invalidGradientColorKey, alphaKey); var validGradientColorKey = new GradientColorKey[2]; validGradientColorKey[0].color = Color.green; validGradientColorKey[1].color = Color.green; var validGradient = new Gradient(); validGradient.SetKeys(validGradientColorKey, alphaKey); XRInteractorLineVisual.validColorGradient.SetKeys(validGradientColorKey, alphaKey); } else { LineRenderer = GameObject.GetComponent <LineRenderer>(); XRRayInteractor = GameObject.GetComponent <XRRayInteractor>(); XRInteractorLineVisual = GameObject.GetComponent <XRInteractorLineVisual>(); } XRRayInteractor.interactionManager = interactionManager; }
public Container( XRInteractionManager interactionManager, bool constructScene) { if (constructScene) { GameObject = new GameObject("AR"); var aRSessionGameObject = new GameObject("Session"); aRSessionGameObject.transform.SetParent(GameObject.transform); Session = aRSessionGameObject.AddComponent <ARSession>(); aRSessionGameObject.AddComponent <ARInputManager>(); var aRSessionOriginGameObject = new GameObject("Session Origin"); aRSessionOriginGameObject.transform.SetParent(GameObject.transform); SessionOrigin = aRSessionOriginGameObject.AddComponent <ARSessionOrigin>(); var aRCameraGameObject = new GameObject("Camera"); aRCameraGameObject.transform.SetParent(aRSessionOriginGameObject.transform); Camera = aRCameraGameObject.AddComponent <Camera>(); Camera.tag = "MainCamera"; Camera.clearFlags = CameraClearFlags.SolidColor; Camera.backgroundColor = Color.black; aRCameraGameObject.AddComponent <ARCameraManager>(); CameraBackground = aRCameraGameObject.AddComponent <ARCameraBackground>(); aRCameraGameObject.AddComponent <ARPoseDriver>(); GestureInteractor = aRCameraGameObject.AddComponent <ARGestureInteractor>(); GestureInteractor.interactionManager = interactionManager; aRCameraGameObject.AddComponent <AudioListener>(); aRCameraGameObject.AddComponent <UnityEngine.Rendering.Universal.UniversalAdditionalCameraData>(); SessionOrigin.camera = Camera; SessionOrigin.gameObject.AddComponent <ARRaycastManager>(); var planeManager = SessionOrigin.gameObject.AddComponent <ARPlaneManager>(); // @todo Create planePrefab in code instead of loading .prefab resource planeManager.planePrefab = Resources.Load("GemPlay/Prefabs/ARPlane") as GameObject; planeManager.detectionMode = UnityEngine.XR.ARSubsystems.PlaneDetectionMode.Horizontal; } else { GameObject = GameObject.Find("AR"); Session = GameObject.GetComponentInChildren <ARSession>(); SessionOrigin = GameObject.GetComponentInChildren <ARSessionOrigin>(); Camera = GameObject.GetComponentInChildren <Camera>(); CameraBackground = GameObject.GetComponentInChildren <ARCameraBackground>(); GestureInteractor = GameObject.GetComponentInChildren <ARGestureInteractor>(); } GestureLogger.RegisterGestureLoggingEvents(gestureInteractor: GestureInteractor); }
// Start is called before the first frame update void Start() { xrInteractionManager = GameObject.FindGameObjectWithTag("XRInteractionManager").GetComponent <XRInteractionManager>(); xrSimpleInteractable.interactionManager = xrInteractionManager; }
private void Awake() { interactor = GetComponent <XRBaseControllerInteractor>(); interactionManager = interactor.interactionManager; originalTriggerType = interactor.selectActionTrigger; }