Last active
March 22, 2023 22:21
-
-
Save maluoi/43a2b9a55791a09a64caf5a0364c987a to your computer and use it in GitHub Desktop.
StereoKit: using a grab bar below the window for movement.
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
Pose grabBarPose = new Pose(0, 0, -0.5f, Quat.LookDir(0, 0, 1)); | |
Vec2 windowSize = Vec2.Zero; // First frame will not be in the right spot unless we know window size in advance. | |
public void Update() | |
{ | |
// Use the size of the Window to position it directly above the grab | |
// bar. Note that we're using the Pose relative Up direction instead of | |
// just the Y axis. | |
Pose windowPose = grabBarPose; | |
windowPose.position -= grabBarPose.Up * windowSize.y; | |
// Begin the window, only show the body, and don't allow the user to | |
// grab it. That'd require a bit more work :) | |
UI.WindowBegin("Interface", ref windowPose, new Vec2(0.15f, 0), UIWin.Body, UIMove.None); | |
// Some UI to fill up space | |
UI.Text("Here's a window that can be moved via a bar below the window!", TextAlign.Center); | |
UI.HSeparator(); | |
UI.Button("Testing!"); | |
// Save the size of the window before ending it. MUST be on a new line. | |
windowSize = new Vec2(UI.LayoutRemaining.x, UI.LayoutAt.y - UI.Settings.margin); | |
UI.WindowEnd(); | |
// Show the window grab bar at its own location. | |
UI.Handle("GrabBar", ref grabBarPose, new Bounds(new Vec3(windowSize.x * 0.9f, 0.01f, 0.01f)), true, UIMove.FaceUser); | |
} |
Author
maluoi
commented
Mar 22, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment