Пример #1
0
        public void Update()
        {
            ViveBridge.Position = transform.position;
            ViveBridge.Forward  = transform.forward;
            ViveBridge.Touchpad = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
            ViveBridge.CheckHits();
            viveManipulator.PrevPosition    = viveManipulator.CurrentPosition;
            viveManipulator.CurrentPosition = transform.position;

            viveManipulator.CheckHits(ViveBridge.InteractionMode, true);

            switch (ViveBridge.InteractionMode)
            {
            case InteractionMode.ScalePrefabs:
                if (viveManipulator.IsScaling)
                {
                    viveManipulator.ScaleObject();
                    DisplayBox(viveManipulator.ManipulatedObject.name, true);
                }
                else if (!string.IsNullOrEmpty(ViveBridge.CollidedName) && !string.Equals(ViveBridge.CollidedName, lastCollided))
                {
                    var collided = GameObject.Find(ViveBridge.CollidedName);

                    if (collided.CompareTag(ViveManipulable.Manipulable))
                    {
                        DisplayBox(ViveBridge.CollidedName, true);
                        lastCollided = ViveBridge.CollidedName;
                    }
                }
                break;

            case InteractionMode.SpawnObjects:
                int index = radialMenu.FindIndex(ViveBridge.Touchpad);
                radialMenu.Highlight(index);
                break;

            case InteractionMode.Manipulation:
                if (!string.IsNullOrEmpty(ViveBridge.CollidedName) && !string.Equals(ViveBridge.CollidedName, lastCollided))
                {
                    var collided = GameObject.Find(ViveBridge.CollidedName);

                    if (collided.CompareTag(ViveManipulable.Manipulable))
                    {
                        DisplayBox(ViveBridge.CollidedName, true);
                        lastCollided = ViveBridge.CollidedName;
                    }
                }
                break;
            }

            if (!viveManipulator.IsScaling && !string.IsNullOrEmpty(lastCollided) && !string.Equals(ViveBridge.CollidedName, lastCollided))
            {
                DisplayBox(lastCollided, false);
                lastCollided = ViveBridge.CollidedName;
            }
        }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        viveManipulator.PrevPosition    = viveManipulator.CurrentPosition;
        viveManipulator.CurrentPosition = transform.position;

        if (isServer)
        {
            transform.position = ViveBridge.Position;
            transform.rotation = ViveBridge.Rotation;
        }
        else
        {
            transform.position = Vector3.Lerp(transform.position, ViveBridge.Position, Time.deltaTime * ViveManipulator.SmoothStep);
            transform.rotation = Quaternion.Lerp(transform.rotation, ViveBridge.Rotation, Time.deltaTime * ViveManipulator.SmoothStep);
        }
        rayMesh.transform.rotation = transform.rotation;

        CheckHits();

        switch (ViveBridge.InteractionMode)
        {
        case InteractionMode.ScalePrefabs:
            if (viveManipulator.IsScaling)
            {
                viveManipulator.ScaleObject();
                DisplayBox(viveManipulator.ManipulatedObject.name, true);
            }
            else if (!string.IsNullOrEmpty(ViveBridge.CollidedName) && !string.Equals(ViveBridge.CollidedName, lastCollided))
            {
                var collided = GameObject.Find(ViveBridge.CollidedName);

                if (collided.CompareTag(ViveManipulable.Manipulable))
                {
                    DisplayBox(ViveBridge.CollidedName, true);
                    lastCollided = ViveBridge.CollidedName;
                }
            }
            break;

        case InteractionMode.SpawnObjects:
            int index = radialMenu.FindIndex(ViveBridge.Touchpad);
            radialMenu.Highlight(index);
            break;

        case InteractionMode.Manipulation:
            if (!string.IsNullOrEmpty(ViveBridge.CollidedName) && !string.Equals(ViveBridge.CollidedName, lastCollided))
            {
                var collided = GameObject.Find(ViveBridge.CollidedName);

                if (collided.CompareTag(ViveManipulable.Manipulable))
                {
                    DisplayBox(ViveBridge.CollidedName, true);
                    lastCollided = ViveBridge.CollidedName;
                }
            }
            break;
        }

        if (!viveManipulator.IsScaling && !string.IsNullOrEmpty(lastCollided) && !string.Equals(ViveBridge.CollidedName, lastCollided))
        {
            DisplayBox(lastCollided, false);
            lastCollided = ViveBridge.CollidedName;
        }
    }