Пример #1
0
        public void Init()
        {
            Transform origins = transform.Find("PointerOrigins");

            if (origins != null)
            {
                if (XRDevice.model.Contains("Oculus"))
                {
                    _pointerOrigin = origins.Find("Oculus");
                }
                else
                {
                    _pointerOrigin = origins.Find("Generic");
                }

                if (_pointerOrigin == null)
                {
                    _pointerOrigin = transform;
                }
            }
            else
            {
                _pointerOrigin = transform;
            }

            _arc = GetComponent <Arc>();
            _arc.ControllerHand = InputAdapter.Instance.PlayerController.Nodes.GetControllerHand(gameObject);
            //Ignore raycast and Zones
            _arc.TraceLayerMask = ~((1 << 2) | (1 << 13));
            _events             = InputAdapter.Instance.ControllerInput.ControllerEventFactory.GetFrom(gameObject);
        }
Пример #2
0
        public void Init()
        {
            Transform origins = transform.Find("PointerOrigins");

            if (origins != null)
            {
                if (XRDevice.model.Contains("Oculus"))
                {
                    _pointerOrigin = origins.Find("Oculus");
                }
                else
                {
                    _pointerOrigin = origins.Find("Generic");
                }

                if (_pointerOrigin == null)
                {
                    _pointerOrigin = transform;
                }
            }
            else
            {
                _pointerOrigin = transform;
            }

            Holder = new GameObject();
            Holder.transform.parent        = _pointerOrigin;
            Holder.transform.localPosition = Vector3.zero;
            Holder.transform.localRotation = Quaternion.identity;

            Pointer = GameObject.CreatePrimitive(PrimitiveType.Cube);
            Pointer.transform.parent        = Holder.transform;
            Pointer.transform.localScale    = new Vector3(Thickness, Thickness, 100f);
            Pointer.transform.localPosition = new Vector3(0f, 0f, 50f);
            Pointer.transform.localRotation = Quaternion.identity;

            BoxCollider boxCollider = Pointer.GetComponent <BoxCollider>();

            if (AddRigidBody)
            {
                if (boxCollider)
                {
                    boxCollider.isTrigger = true;
                }

                Rigidbody rigidBody = Pointer.AddComponent <Rigidbody>();
                rigidBody.isKinematic = true;
            }
            else
            {
                if (boxCollider)
                {
                    Destroy(boxCollider);
                }
            }

            Material newMaterial = new Material(Shader.Find("Unlit/TransparentColor"));

            newMaterial.SetColor(ColorShader, _currentColor);
            newMaterial.renderQueue = 3000;
            Pointer.GetComponent <MeshRenderer>().material = newMaterial;
            Pointer.SetActive(false);

            _events = InputAdapter.Instance.ControllerInput.ControllerEventFactory.GetFrom(gameObject);
        }