Esempio n. 1
0
        void Update()
        {
            //RotateCamera();

            var leftClick     = Input.GetMouseButtonDown(0);
            var middleClick   = Input.GetMouseButtonDown(2);
            var mousePosition = Input.mousePosition;

            if (middleClick)
            {
                if (Equipping)
                {
                    equipment.InvokeEvent(WasmEventType.Unequip);
                    equipment = null;
                }
                else
                {
                    Equip(mousePosition);
                }
            }

            UpdateEquipmentTransform();

            if (leftClick)
            {
                if (Equipping)
                {
                    equipment.InvokeEvent(WasmEventType.Use);
                }
                else
                {
                    Select(mousePosition);
                }
            }
        }
Esempio n. 2
0
        private void Equip(Vector3 mousePosition)
        {
            if (!TryGetSelectedObject(mousePosition, out var wasm))
            {
                return;
            }
            var pomlElement = wasm.GetComponent <PomlElementComponent>();

            if (pomlElement.Equipable)
            {
                equipment = wasm;
                equipment.InvokeEvent(WasmEventType.Equip);
            }
        }
Esempio n. 3
0
        private bool TryGetSelectedObject(Vector3 screenPos, out WasmBehaviour wasm)
        {
            var ray = mainCamera.ScreenPointToRay(screenPos);

            if (!Physics.Raycast(ray, out var hit))
            {
                wasm = null;
                return(false);
            }

            var hitObject = hit.collider.gameObject;

            wasm = hitObject.GetComponentInParent <WasmBehaviour>();
            return(wasm != null);
        }
Esempio n. 4
0
    public void Initialize(
        WasmBehaviour wasm,
        MixedRealityInputAction grabAction,
        MixedRealityInputAction useAction)
    {
        this.wasm = wasm;

        grabHandler = gameObject.AddComponent<CustomActionHandler>();
        grabHandler.InputAction = grabAction;
        grabHandler.SetFocusRequired(true);
        grabHandler.OnInputActionStarted += GrabHandler_OnInputActionStarted;

        useHandler = gameObject.AddComponent<CustomActionHandler>();
        useHandler.InputAction = useAction;
        // useHandler.SetFocusRequired(false);
        useHandler.OnInputActionStarted += UseHandler_OnInputActionStarted;
    }