Created
December 28, 2023 06:14
-
-
Save maluoi/d530747d50318efca7491f10df66d148 to your computer and use it in GitHub Desktop.
StereoKit previous theme
This file contains hidden or 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 function will restore the StereoKit theme used in versions prior to | |
// v0.3.9. | |
// This also requires the previous UI shaders, you will need to copy them and | |
// add them to your project's Assets. This file references them as: | |
// ui.hlsl - https://github.com/StereoKit/StereoKit/blob/646afeef576a2f04103b0b99e2ee932cffa814b4/StereoKitC/shaders_builtin/shader_builtin_ui.hlsl | |
// ui_quadrant.hlsl - https://github.com/StereoKit/StereoKit/blob/646afeef576a2f04103b0b99e2ee932cffa814b4/StereoKitC/shaders_builtin/shader_builtin_ui_quadrant.hlsl | |
static void ApplyTheme_SKPrevious() | |
{ | |
UI.Settings = new UISettings | |
{ | |
margin = 0.01f, | |
padding = 0.01f, | |
gutter = 0.01f, | |
depth = 0.01f, | |
rounding = 0.0075f | |
}; | |
UILathePt[] defaultLathe = | |
{ | |
new UILathePt{ pt = V.XY(0, -0.5f), normal = V.XY(0, 1), color = new Color32(255,255,255,255), connectNext = true }, | |
new UILathePt{ pt = V.XY(0.83f,-0.5f), normal = V.XY(0, 1), color = new Color32(255,255,255,255), connectNext = false}, | |
new UILathePt{ pt = V.XY(0.83f,-0.5f), normal = V.XY(1, 2), color = new Color32(255,255,255,0), connectNext = true }, | |
new UILathePt{ pt = V.XY(1, 0 ), normal = V.XY(1, 0), color = new Color32(255,255,255,0), connectNext = true }, | |
new UILathePt{ pt = V.XY(0.83f, 0.5f), normal = V.XY(1,-2), color = new Color32(255,255,255,0), connectNext = false}, | |
new UILathePt{ pt = V.XY(0.83f, 0.5f), normal = V.XY(0,-1), color = new Color32(255,255,255,255), connectNext = true }, | |
new UILathePt{ pt = V.XY(0, 0.5f), normal = V.XY(0,-1), color = new Color32(255,255,255,255), connectNext = true }, | |
}; | |
float round = UI.Settings.rounding; | |
float smallRound = Math.Min(UI.LineHeight / 3.0f, UI.Settings.rounding) / 2.0f; | |
float fullRound = UI.LineHeight/2.0f; | |
Vec2 boxMin = V.XY( round, round )*2; | |
Vec2 smallMin = V.XY( smallRound, smallRound )*2; | |
Vec2 fullMin = V.XY( fullRound, fullRound ) *2; | |
Mesh box = UI.GenQuadrantMesh(UICorner.All, round, 5, false, defaultLathe); | |
Mesh boxTop = UI.GenQuadrantMesh(UICorner.Top, round, 5, true, defaultLathe); | |
Mesh boxBot = UI.GenQuadrantMesh(UICorner.Bottom, round, 5, true, defaultLathe); | |
Mesh small = UI.GenQuadrantMesh(UICorner.All, smallRound, 5, false, defaultLathe); | |
Mesh smallLeft = UI.GenQuadrantMesh(UICorner.Left, smallRound, 5, true, defaultLathe); | |
Mesh smallRight = UI.GenQuadrantMesh(UICorner.Right, smallRound, 5, true, defaultLathe); | |
Mesh cylinder = UI.GenQuadrantMesh(UICorner.All, fullRound, 8, false, defaultLathe); | |
Material matQuad = new Material("ui_quadrant.hlsl"); | |
Material mat = new Material("ui.hlsl"); | |
mat["ui_tint"] = true; | |
UI.SetElementVisual(UIVisual.Default, box, matQuad, boxMin); | |
UI.SetElementVisual(UIVisual.Button, box, matQuad, boxMin); | |
UI.SetElementVisual(UIVisual.Toggle, box, matQuad, boxMin); | |
UI.SetElementVisual(UIVisual.Input, box, matQuad, boxMin); | |
UI.SetElementVisual(UIVisual.Panel, box, matQuad, boxMin); | |
UI.SetElementVisual(UIVisual.WindowHead, boxTop, matQuad, boxMin); | |
UI.SetElementVisual(UIVisual.WindowBody, boxBot, matQuad, boxMin); | |
UI.SetElementVisual(UIVisual.ButtonRound, cylinder, matQuad, fullMin); | |
UI.SetElementVisual(UIVisual.SliderLine, small, matQuad, smallMin); | |
UI.SetElementVisual(UIVisual.SliderLineActive, smallLeft, matQuad, smallMin); | |
UI.SetElementVisual(UIVisual.SliderLineInactive, smallRight, matQuad, smallMin); | |
UI.SetElementVisual(UIVisual.SliderPinch, small, matQuad, smallMin); | |
UI.SetElementVisual(UIVisual.SliderPush, small, matQuad, smallMin); | |
UI.SetElementVisual(UIVisual.Separator, Mesh.Cube, mat); | |
UI.SetElementVisual(UIVisual.Carat, Mesh.Cube, mat); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment