// TODO: とある事情によりmanagerが必要 public DebugUiWindow( DebugUiManager manager, string title, float headerHeight = DefaultHeaderSize) : base(string.IsNullOrEmpty(title) ? "Window" : title) { _headerPanel = new DebugUiPanel( float.MaxValue, float.MaxValue, true, true, true); _headerPanel.backgroundColor = new Color32(0, 0, 128, 128); _headerPanel.draggable = true; _headerPanel.onDragStart = () => { _prevPointerX = pointerX; _prevPointerY = pointerY; }; // このヘッダをタップしたら、windowを手前に持ってくる _headerPanel.onEventConsume = () => { SetAsLastSibling(); }; var closeButton = new DebugUiButton( "X", DefaultHeaderSize, DefaultHeaderSize); closeButton.onClick = () => { enabled = false; }; _headerPanel.AddChildAuto(closeButton); var minimizeButton = new DebugUiButton( "_", DefaultHeaderSize, DefaultHeaderSize); minimizeButton.onClick = () => { ToggleMinimize(); }; _headerPanel.AddChildAuto(minimizeButton); var titleText = new DebugUiText(manager, title, DefaultHeaderSize * 0.75f); _headerPanel.AddChildAuto(titleText); _headerPanel.AdjustSize(); base.AddChild(_headerPanel); _contentPanel = new DebugUiPanel(0f, 0f, false, false); base.AddChild(_contentPanel); backgroundEnabled = true; borderEnabled = true; // とりあえず空でレイアウト Layout(); }
// 自動測定にはmanagerが必要。TODO: どうにかしたい public DebugUiText( DebugUiManager manager, string text, float fontSize, float lineHeight = DefaultLineHeight, bool rotateToVertical = false, bool backgroundEnabled = false) : base(string.IsNullOrEmpty(text) ? "Text" : text) { this.text = text; this.lineHeight = lineHeight; _fontSize = fontSize; _rotateToVertical = rotateToVertical; borderEnabled = false; this.backgroundEnabled = backgroundEnabled; color = new Color32(255, 255, 255, 255); var size = manager.primitiveRenderer.MeasureText(text, fontSize, lineHeight); // ギリギリだと自動改行が不規則に走り得るので少し余裕をもたせる TODO: ちゃんと計算しろ size.x += fontSize * 0.2f; size.y += fontSize * 0.1f; if (_rotateToVertical) { SetSize(size.y, size.x); } else { SetSize(size.x, size.y); } }
// 自動測定にはmanagerが必要。TODO: どうにかしたい public DebugUiText( DebugUiManager manager, string text, float fontSize, bool backgroundEnabled = false) : base(string.IsNullOrEmpty(text) ? "Text" : text) { this.text = text; _fontSize = fontSize; var size = manager.primitiveRenderer.MeasureText(text, fontSize, lineSpacing); // ギリギリだと自動改行が不規則に走り得るので少し余裕をもたせる TODO: ちゃんと計算しろ size.x += fontSize * 0.2f; size.y += fontSize * 0.1f; SetSize(size.x, size.y); }
public SampleWindow(DebugUiManager manager) : base(manager, "SampleWindow") { _frameTimeWatcher = new FrameTimeWatcher(); var button = new DebugUiButton("ボタン", 100f); button.onClick = () => { _log.Add("ボタンが押された!"); }; AddAuto(button); var toggleGroup = new DebugUiToggleGroup(); var toggles = new DebugUiToggle[2]; toggles[0] = new DebugUiToggle("トグルA", 100f, 50f, toggleGroup); toggles[0].onChangeToOn = () => { _log.Add("Aが有効になった"); }; AddAuto(toggles[0]); toggles[1] = new DebugUiToggle("トグルB", 100f, 50f, toggleGroup); toggles[1].onChangeToOn = () => { _log.Add("Bが有効になった"); }; AddAuto(toggles[1]); var text = new DebugUiText("テキスト", fontSize: 20f, width: 80f, height: 25f); AddAuto(text); BreakLine(); _log = new DebugUiLogWindow( fontSize: 20f, width: 600f, height: 220f, borderEnabled: true, captureUnityLog: true); // Unityのログも出しちゃうよ AddAuto(_log); _graph = new DebugUiGraph(5, 200f, 220f); _graph.AddSeries(new Color32(255, 64, 64, 255)); AddAuto(_graph); BreakLine(); var frameTimeGauge = new FrameTimeGauge(200f, 30f, _frameTimeWatcher); AddAuto(frameTimeGauge); var slider = new DebugUiSlider("スライダー", -100f, 100f, 400f); slider.onDragEnd = () => { _log.Add("スライダーが" + slider.value + "に変更された"); }; AddAuto(slider); BreakLine(); var table = new DebugUiTable( 16f, new List <float>() { 80f, 80f, 120f }, 3, 20f); table.cells[0, 0] = "列A"; table.cells[0, 1] = "列B"; table.cells[0, 2] = "列C"; table.cells[1, 0] = "データ10"; table.cells[1, 1] = "データ11"; table.cells[1, 2] = "データ12"; table.cells[2, 0] = "データ20"; table.cells[2, 1] = "データ21"; table.cells[2, 2] = "データ23"; AddAuto(table); FitSize(); }
public SampleWindow(DebugUiManager manager) : base(manager, "SampleWindow") { var button = new DebugUiButton("ボタン", 100f); button.onClick = () => { _log.Add("ボタンが押された!"); }; AddChildAuto(button); var toggleGroup = new DebugUiToggleGroup(); var toggles = new DebugUiToggle[2]; toggles[0] = new DebugUiToggle("トグルA", 100f, 50f, toggleGroup); toggles[0].onChangeToOn = () => { _log.Add("Aが有効になった"); }; AddChildAuto(toggles[0]); toggles[1] = new DebugUiToggle("トグルB", 100f, 50f, toggleGroup); toggles[1].onChangeToOn = () => { _log.Add("Bが有効になった"); }; AddChildAuto(toggles[1]); var text = new DebugUiText("テキスト", fontSize: 20f, width: 80f, height: 20f); AddChildAuto(text); BreakLine(); _log = new DebugUiLogWindow(fontSize: 20f, lineHeight: 22f, lineCount: 10, width: 800f); AddChildAuto(_log); BreakLine(); var frameTimeGauge = new FrameTimeGauge(200f, 30f, null); AddChildAuto(frameTimeGauge); var slider = new DebugUiSlider("スライダー", -100f, 100f, 400f); slider.onDragEnd = () => { _log.Add("スライダーが" + slider.value + "に変更された"); }; AddChildAuto(slider); BreakLine(); var table = new DebugUiTable( 16f, new List <float>() { 80f, 80f, 120f }, 3, 20f); table.cells[0, 0] = "列A"; table.cells[0, 1] = "列B"; table.cells[0, 2] = "列C"; table.cells[1, 0] = "データ10"; table.cells[1, 1] = "データ11"; table.cells[1, 2] = "データ12"; table.cells[2, 0] = "データ20"; table.cells[2, 1] = "データ21"; table.cells[2, 2] = "データ23"; AddChildAuto(table); AdjustSize(); }