-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(input): add interaction to recipe picker (#92)
- Loading branch information
Showing
10 changed files
with
114 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using TechtonicaVR.Util; | ||
using UnityEngine; | ||
using System.Linq; | ||
|
||
namespace TechtonicaVR.Input.Ui.Machine; | ||
|
||
public class RecipePickerInteractableUi : InteractableUi | ||
{ | ||
private static PluginLogger Logger = PluginLogger.GetLogger<RecipePickerInteractableUi>(); | ||
|
||
public RecipePickerInteractableUi(GameObject gameObject) : base(gameObject) | ||
{ | ||
zIndex = -0.001f; | ||
interactable = gameObject.GetComponentsInChildren<ResourceSlotUI>().Select(getInteractable).ToList(); | ||
} | ||
|
||
private Interactable getInteractable(ResourceSlotUI slot, int index) | ||
{ | ||
Logger.LogDebug($"Slot: {slot} {slot.gameObject.name} {slot.gameObject.transform.localPosition}"); | ||
var rectTransform = slot.GetComponent<RectTransform>(); | ||
var rect = getRect(rectTransform); | ||
Logger.LogDebug($"Slot rect: {slot} {rect} {rectTransform.localPosition}"); | ||
|
||
return new InteractableBuilder(this, rect, rectTransform.gameObject) | ||
.withRecalculate(() => getRect(rectTransform)) | ||
.withClick((ui) => onClick(slot)) | ||
.withHoverEnter((ui) => onHoverEnter(slot)) | ||
.withHoverExit((ui) => onHoverExit(slot)) | ||
.build(); | ||
} | ||
|
||
private void onClick(ResourceSlotUI slot) | ||
{ | ||
slot.mouseLeftClickCallback.Invoke(); | ||
} | ||
|
||
private void onHoverEnter(ResourceSlotUI slot) | ||
{ | ||
slot.mouseEnterCallback.Invoke(); | ||
} | ||
|
||
private void onHoverExit(ResourceSlotUI slot) | ||
{ | ||
slot.mouseExitCallback.Invoke(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace TechtonicaVR.UI; | ||
|
||
public class RecipePickerMenuWrapper : Menu | ||
{ | ||
|
||
private RecipePickerUI menu; | ||
|
||
public RecipePickerMenuWrapper(RecipePickerUI menu) | ||
{ | ||
this.menu = menu; | ||
} | ||
|
||
public bool isOpen() | ||
{ | ||
return menu.myCanvas.enabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters