// 自動測定にはmanagerが必要。TODO: どうにかしたい public Text( DebugUiManager manager, string text, float fontSize, bool backgroundEnabled = false) : base(string.IsNullOrEmpty(text) ? "Text" : text) { Value = text; this.fontSize = fontSize; var size = manager.Renderer.MeasureText(text, fontSize, LineSpacing); // ギリギリだと自動改行が不規則に走り得るので少し余裕をもたせる TODO: ちゃんと計算しろ size.x += fontSize * 0.2f; size.y += fontSize * 0.1f; SetSize(size.x, size.y); Initialize(backgroundEnabled); }
// TODO: とある事情によりmanagerが必要 public Window( DebugUiManager manager, string title, float headerHeight = DefaultHeaderSize) : base(string.IsNullOrEmpty(title) ? "Window" : title) { this.manager = manager; headerPanel = new Panel( float.MaxValue, float.MaxValue, true, true, true) { BackgroundColor = new Color32(0, 0, 128, 128), Draggable = true, OnDragStart = () => { prevPointerX = PointerX; prevPointerY = PointerY; }, // このヘッダをタップしたら、windowを手前に持ってくる OnEventConsume = () => { this.manager.MoveToTop(this); } }; var closeButton = new Button( "X", DefaultHeaderSize, DefaultHeaderSize) { OnClick = () => { Enabled = false; } }; headerPanel.AddAuto(closeButton); var minimizeButton = new Button( "_", DefaultHeaderSize, DefaultHeaderSize) { OnClick = ToggleMinimize }; headerPanel.AddAuto(minimizeButton); var titleText = new Text(manager, title, headerHeight * 0.75f); headerPanel.AddAuto(titleText); headerPanel.FitSize(); AddChildAsTail(headerPanel); contentPanel = new Panel(0f, 0f, false, false); AddChildAsTail(contentPanel); BackgroundEnabled = true; BorderEnabled = true; // とりあえず空でレイアウト Layout(); }