Skip to content

Commit

Permalink
feat(ui): move crafting queue to left hand (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenira committed Dec 16, 2023
1 parent e4c472a commit 8c4fb9b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugin/src/main_game_patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void Start()
new CursorCanvasPatch(),
new CompassPatch(),
new MapPatch(),
new CraftingQueuePatch(),
]).ToArray();

Plugin.Logger.LogDebug("Hello World!");
Expand Down
33 changes: 33 additions & 0 deletions plugin/src/patch/main_game/ui/crafting_queue_patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Plugin.Input;
using TechtonicaVR.UI;
using UnityEngine;

namespace TechtonicaVR.Patches.MainGame.UI;

class CraftingQueuePatch : GameComponentPatch<CraftingQueueGrid>

{
protected override bool Apply(CraftingQueueGrid component)
{
var tlc = component.gameObject.transform.parent;
if (tlc == null)
{
return false;
}

var trackedCanvas = tlc.gameObject.AddComponent<HandTrackedCanvas>();
trackedCanvas.hand = SteamVRInputMapper.leftHandObject.transform;
trackedCanvas.showDirection = -Vector3.right;
trackedCanvas.offset = new Vector3(-0.08f, 0.06f, -0.1f);
trackedCanvas.showDistance = 0.3f;
trackedCanvas.noTransform = true;
tlc.localPosition = new Vector3(-17.7141f, 17.7794f, 0f);
tlc.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
for (int i = 0; i < tlc.childCount; i++)
{
tlc.GetChild(i).localPosition = Vector3.zero;
}

return true;
}
}

0 comments on commit 8c4fb9b

Please sign in to comment.