diff --git a/Assets/Engine/Interactions/InteractionHandler.cs b/Assets/Engine/Interactions/InteractionHandler.cs index 53e3dcc244..77f2e70f0e 100644 --- a/Assets/Engine/Interactions/InteractionHandler.cs +++ b/Assets/Engine/Interactions/InteractionHandler.cs @@ -56,23 +56,37 @@ public void Update() Destroy(activeMenu.gameObject); } - var ray = Camera.main.ScreenPointToRay(Input.mousePosition); - var viableInteractions = GetViableInteractions(ray, out InteractionEvent interactionEvent); - if (viableInteractions.Select(x => x.Interaction).ToList().Count > 0) + if (Input.GetButton("Alternate")) { - //Debug.LogError(viableInteractions.Count); - // Create a menu that will run the given action when clicked - var obj = Instantiate(menuPrefab, transform.root.transform); - activeMenu = obj.GetComponentInChildren(); - - activeMenu.Position = Input.mousePosition; - activeMenu.Event = interactionEvent; - activeMenu.Interactions = viableInteractions.Select(x => x.Interaction).ToList(); - activeMenu.onSelect = interaction => + Hands hands = GetComponent(); + if (hands != null ) { - CmdRunInteraction(ray, viableInteractions.FindIndex(x => x.Interaction == interaction), + Item item = hands.Container.GetItem(hands.HeldSlot); + if (item != null) + { + InteractInHand(item.gameObject, gameObject, true); + } + } + } + else + { + var ray = Camera.main.ScreenPointToRay(Input.mousePosition); + var viableInteractions = GetViableInteractions(ray, out InteractionEvent interactionEvent); + if (viableInteractions.Select(x => x.Interaction).ToList().Count > 0) + { + // Create a menu that will run the given action when clicked + var obj = Instantiate(menuPrefab, transform.root.transform); + activeMenu = obj.GetComponentInChildren(); + + activeMenu.Position = Input.mousePosition; + activeMenu.Event = interactionEvent; + activeMenu.Interactions = viableInteractions.Select(x => x.Interaction).ToList(); + activeMenu.onSelect = interaction => + { + CmdRunInteraction(ray, viableInteractions.FindIndex(x => x.Interaction == interaction), interaction.GetName(interactionEvent)); - }; + }; + } } } @@ -116,11 +130,12 @@ public void InteractInHand(GameObject target, GameObject sourceObject, bool show interactionEvent.Target = entries[0].Target; if (showMenu && entries.Select(x => x.Interaction).ToList().Count > 0) { - //Debug.LogError(entries[0]); var obj = Instantiate(menuPrefab, transform.root.transform); activeMenu = obj.GetComponentInChildren(); - activeMenu.Position = Input.mousePosition; + Vector3 mousePosition = Input.mousePosition; + mousePosition.y = Mathf.Max(obj.transform.GetChild(0).GetComponent().rect.height, mousePosition.y); + activeMenu.Position = mousePosition; activeMenu.Event = interactionEvent; activeMenu.Interactions = entries.Select(x => x.Interaction).ToList(); activeMenu.onSelect = interaction => diff --git a/Assets/Engine/Interactions/UI/RadialMenuInteraction/PetalsManager.cs b/Assets/Engine/Interactions/UI/RadialMenuInteraction/PetalsManager.cs index b967c9cd7b..4ae00b30b6 100644 --- a/Assets/Engine/Interactions/UI/RadialMenuInteraction/PetalsManager.cs +++ b/Assets/Engine/Interactions/UI/RadialMenuInteraction/PetalsManager.cs @@ -111,7 +111,7 @@ public Petal AddPetalToFolder(Sprite icon, string name) Petal newPetal = Instantiate(petalPrefab, petalParent.transform).GetComponent(); newPetal.iconImage.texture = icon.texture; newPetal.name = name; - newPetal.transform.parent = petalParent.transform; + newPetal.transform.SetParent(petalParent.transform, false); folder.AddPetal(newPetal); folder.isDirty = true; return (newPetal); diff --git a/Assets/Engine/Inventory/UI/UIGroupedContainers.cs b/Assets/Engine/Inventory/UI/UIGroupedContainers.cs index 5784ad1bf9..e1891f623f 100644 --- a/Assets/Engine/Inventory/UI/UIGroupedContainers.cs +++ b/Assets/Engine/Inventory/UI/UIGroupedContainers.cs @@ -96,7 +96,7 @@ public override void OnPress(UIItemSlot slot, PointerEventData.InputButton butto if (handler != null && hands != null && hands.GetActiveTool() != null && item != null && (slotType == Container.SlotType.LeftHand || slotType == Container.SlotType.RightHand)) { - handler.InteractInHand(item, playerObject); + handler.InteractInHand(item, playerObject, button == PointerEventData.InputButton.Right); return; } diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 242a506c4e..012c24b7a1 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -490,7 +490,7 @@ InputManager: descriptiveName: Activate Item descriptiveNegativeName: negativeButton: - positiveButton: left alt + positiveButton: altNegativeButton: altPositiveButton: z gravity: 1000 @@ -501,3 +501,19 @@ InputManager: type: 0 axis: 5 joyNum: 0 + - serializedVersion: 3 + m_Name: Alternate + descriptiveName: Alternate action + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 5 + joyNum: 0