public DebugUiButton AddItem(string name, Action action) { var button = new DebugUiButton(name, _itemWidth, _itemHeight); button.color = this.color; button.textColor = this.textColor; button.pointerDownColor = this.pointerDownColor; button.pointerDownTextColor = this.pointerDownTextColor; button.onClick = () => { // サブメニューを閉じる CloseSub(); if (action != null) { action(); } }; Add(button); Item item; item.button = button; item.menu = null; item.menuDirection = Direction.Unknown; _items.Add(item); Layout(); return(button); }
void OnClickDigit(DebugUiButton digit) { // 何桁目が押されたか識別 int index = -1; int scale = 1; for (int i = 0; i < _digits.Length; i++) { if (_digits[i] == digit) { index = i; } scale *= 10; } // 該当する桁を抜き出し for (int i = 0; i <= index; i++) { scale /= 10; } int v = value; v /= scale; int d = v % 10; if (d == 9) { value -= d * scale; } else { value += scale; } UpdateDigits(); }
public DebugUiNumberInput( int digitCount, int initialValue, float height = 50f) { this._value = initialValue; _digits = new DebugUiButton[digitCount]; for (int i = 0; i < digitCount; i++) { var digit = new DebugUiButton("0", height * 0.6f, height); AddAuto(digit); digit.onClick = () => { OnClickDigit(digit); }; _digits[i] = digit; } FitSize(); eventEnabled = true; draggable = true; UpdateDigits(); activeColor = new Color32(120, 120, 90, 128); defaultColor = backgroundColor; }
// 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(); }
public DebugUiMenu AddItem(string name, Action action) { var button = new DebugUiButton(name, _itemWidth, _itemHeight); button.onClick = () => { // サブメニューを閉じる CloseSubMenus(); if (action != null) { action(); } }; AddChild(button, _x, _y); Enlarge(); return(this); }
public DebugUiMenu AddMenu( string name, DebugUiMenu subMenu, Direction subMenuDirection = Direction.Down) { subMenu.enabled = false; var button = new DebugUiButton(name, _itemWidth, _itemHeight); button.onClick = () => { // サブメニューを閉じる bool opened = subMenu.enabled; CloseSubMenus(); if (!opened) { subMenu.enabled = true; } }; AddChild(button, _x, _y); float subX = _x; float subY = _y; float dw = (_itemWidth + borderWidth); float dh = (_itemHeight + borderWidth); switch (subMenuDirection) { case Direction.Left: subX -= dw; break; case Direction.Right: subX += dw; break; case Direction.Up: subY -= dh; break; case Direction.Down: subY += dh; break; } AddChild(subMenu, subX, subY); _subMenus.Add(subMenu); Enlarge(); return(this); }
public DebugUiButton AddSubMenu( DebugUiSubMenu subMenu, Direction subMenuDirection = Direction.Down) { subMenu._parent = this; subMenu.enabled = false; subMenu.color = this.color; subMenu.textColor = this.textColor; subMenu.pointerDownColor = this.pointerDownColor; subMenu.pointerDownTextColor = this.pointerDownTextColor; var button = new DebugUiButton(subMenu.name, _itemWidth, _itemHeight); button.color = this.color; button.textColor = this.textColor; button.pointerDownColor = this.pointerDownColor; button.pointerDownTextColor = this.pointerDownTextColor; button.onClick = () => { // サブメニューを閉じる bool opened = subMenu.enabled; CloseSub(); if (!opened) { subMenu.enabled = true; } }; Add(button); Add(subMenu); Item item; item.button = button; item.menu = subMenu; item.menuDirection = subMenuDirection; _items.Add(item); Layout(); return(button); }
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(); }