| 36 | public void Shutdown() { } |
| 37 | |
| 38 | public void Step() |
| 39 | { |
| 40 | |
| 41 | UI.WindowBegin("Alignment", ref alignWindow); |
| 42 | Vec2 size = new Vec2(8 * U.cm, UI.LineHeight); |
| 43 | if (UI.Radio("Left" , alignX == TextAlign.XLeft , size)) alignX = TextAlign.XLeft; UI.SameLine(); |
| 44 | if (UI.Radio("CenterX", alignX == TextAlign.XCenter, size)) alignX = TextAlign.XCenter; UI.SameLine(); |
| 45 | if (UI.Radio("Right" , alignX == TextAlign.XRight , size)) alignX = TextAlign.XRight; |
| 46 | if (UI.Radio("Top" , alignY == TextAlign.YTop , size)) alignY = TextAlign.YTop; UI.SameLine(); |
| 47 | if (UI.Radio("CenterY", alignY == TextAlign.YCenter, size)) alignY = TextAlign.YCenter; UI.SameLine(); |
| 48 | if (UI.Radio("Bottom" , alignY == TextAlign.YBottom, size)) alignY = TextAlign.YBottom; |
| 49 | UI.WindowEnd(); |
| 50 | |
| 51 | Hierarchy.Push(Matrix.R(0, 180, 0) * Demo.contentPose); |
| 52 | Hierarchy.Push(Matrix.T(0.1f,0,0)); |
| 53 | Text.Add("X Center", Matrix.TR(new Vec3(0,.1f, 0), Quat.LookDir(0,0,1)), TextAlign.Center, alignX | alignY); |
| 54 | Text.Add("X Left", Matrix.TR(new Vec3(0,.15f,0), Quat.LookDir(0,0,1)), TextAlign.CenterLeft, alignX | alignY); |
| 55 | Text.Add("X Right", Matrix.TR(new Vec3(0,.2f, 0), Quat.LookDir(0,0,1)), TextAlign.CenterRight, alignX | alignY); |
| 56 | Lines.Add(new Vec3(0,.05f,0), new Vec3(0,.25f,0), Color32.White, 0.001f); |
| 57 | Hierarchy.Pop(); |
| 58 | |
| 59 | Hierarchy.Push(Matrix.T(-0.1f,0,0)); |
| 60 | Text.Add("Y Center", Matrix.TR(new Vec3(0,.1f, 0), Quat.LookDir(0,0,1)), TextAlign.YCenter|TextAlign.XCenter, alignX | alignY); |
| 61 | Lines.Add(new Vec3(-0.05f, .1f, 0), new Vec3(.05f, .1f, 0), Color32.White, 0.001f); |
| 62 | |
| 63 | Text.Add("Y Top", Matrix.TR(new Vec3(0,.15f,0), Quat.LookDir(0,0,1)), TextAlign.YTop|TextAlign.XCenter, alignX | alignY); |
| 64 | Lines.Add(new Vec3(-0.05f, .15f, 0), new Vec3(.05f, .15f, 0), Color32.White, 0.001f); |
| 65 | |
| 66 | Text.Add("Y Bottom", Matrix.TR(new Vec3(0,.2f, 0), Quat.LookDir(0,0,1)), TextAlign.YBottom|TextAlign.XCenter, alignX | alignY); |
| 67 | Lines.Add(new Vec3(-0.05f,.2f, 0), new Vec3(.05f,.2f, 0), Color32.White, 0.001f); |
| 68 | Hierarchy.Pop(); |
| 69 | |
| 70 | Hierarchy.Push(Matrix.T(0, -0.1f, 0)); |
| 71 | Tests.Screenshot("BasicText.jpg", 600, 300, Hierarchy.ToWorld(new Vec3(0, 0, 0.09f)), Hierarchy.ToWorld(Vec3.Zero)); |
| 72 | |
| 73 | /// :CodeSample: Text.MakeStyle Font.FromFile Text.Add |
| 74 | /// Then it's pretty trivial to just draw some text on the screen! Just call |
| 75 | /// Text.Add on update. If you don't have a TextStyle available, calling it |
| 76 | /// without one will just fall back on the default style. |
| 77 | // Text with an explicit text style |
| 78 | Text.Add( |
| 79 | "Here's\nSome\nMulti-line\nText!!", |
| 80 | Matrix.TR(new Vec3(0.1f, 0, 0), Quat.LookDir(0, 0, 1)), |
| 81 | style); |
| 82 | // Text using the default text style |
| 83 | Text.Add( |
| 84 | "Here's\nSome\nMulti-line\nText!!", |
| 85 | Matrix.TR(new Vec3(-0.1f, 0, 0), Quat.LookDir(0, 0, 1))); |
| 86 | /// :End: |
| 87 | |
| 88 | Hierarchy.Push(Matrix.T(0, -0.2f, 0)); |
| 89 | Text.Add( |
| 90 | "Here's Some Multi-line Text!!", |
| 91 | Matrix.TR(new Vec3(0, 0.0f, 0), Quat.LookDir(0, 0, 1)), |
| 92 | new Vec2(SKMath.Cos(Time.Totalf)*10+11, 20) * U.cm, |
| 93 | TextFit.Clip, |
| 94 | style, TextAlign.Center, alignX | alignY); |
| 95 | Hierarchy.Pop(); |