protected override void OnGUI() { if (NodeUtils.FloatTextField(new Rect(3, 0, 50, 20), ref _numberString)) { _number = NodeUtils.Parse(_numberString); TriggerChangeEvent(); } }
private void DrawDirectNumberInput() { float width = CalcDirectInputOffset(); BoxRect.x -= width; GUI.Box(BoxRect, ">"); _directInputRect.Set(BoxRect.x + BoxRect.width, BoxRect.y, width, BoxRect.height); if (NodeUtils.FloatTextField(_directInputRect, ref _directInputString)) { _directInputNumber = float.Parse(_directInputString); Parent.TriggerChangeEvent(); } BoxRect.x += width; }
private void DrawUI() { float topOffset = _panelHeight + _panelMarginTop + 20; if (Event.current.type == EventType.MouseUp) { TriggerChangeEvent(); } if (_selectedPointIndex >= _points.Count) { _selectedPointIndex = -1; } if (_selectedPointIndex > -1) { Vector2 v = _points[_selectedPointIndex]; _pointXInput = v.x + ""; _pointYInput = v.y + ""; _tmpRect.Set(10, topOffset, 20, 18); GUI.Label(_tmpRect, "x"); _tmpRect.Set(20, _panelHeight + _panelMarginTop + 20, 40, 18); if (NodeUtils.FloatTextField(_tmpRect, ref _pointXInput)) { v.x = Mathf.Max(Mathf.Min(NodeUtils.Parse(_pointXInput), 1), -1); _points[_selectedPointIndex] = v; UpdatePoints(); TriggerChangeEvent(); } _tmpRect.Set(60, topOffset, 20, 18); GUI.Label(_tmpRect, "y"); _tmpRect.Set(70, _panelHeight + _panelMarginTop + 20, 40, 18); if (NodeUtils.FloatTextField(_tmpRect, ref _pointYInput)) { v.y = Mathf.Max(Mathf.Min(NodeUtils.Parse(_pointYInput), 1), -1); _points[_selectedPointIndex] = v; UpdatePoints(); TriggerChangeEvent(); } if (_points.Count > 2) { _tmpRect.Set(115, topOffset, 35, 18); if (GUI.Button(_tmpRect, "del")) { _points.RemoveAt(_selectedPointIndex); _spline = new BSpline(_points); UpdatePoints(); TriggerChangeEvent(); } } } _tmpRect.Set(150, topOffset, 35, 18); if (GUI.Button(_tmpRect, "add")) { Vector2 addPoint = new Vector2(); if (!ContainsEqualPoint(addPoint)) { _points.Add(new Vector2()); _spline = new BSpline(_points); UpdatePoints(); TriggerChangeEvent(); } } _tmpRect.Set(190, topOffset, 20, 18); if (GUI.Button(_tmpRect, "+")) { _panelWidth += 50; _panelHeight += 50; } _tmpRect.Set(210, topOffset, 20, 18); if (_panelWidth > 200 && GUI.Button(_tmpRect, "-")) { _panelWidth -= 50; _panelHeight -= 50; } topOffset += 25; _tmpRect.Set(15, topOffset, 60, 20); var currentClamp = GUI.Toggle(_tmpRect, _clamp, "clamp"); if (currentClamp != _clamp) { _clamp = currentClamp; TriggerChangeEvent(); } if (_spline.LowestX > -1 || _spline.HighestX < 1) { _tmpRect.Set(80, topOffset - 2, 50, 20); GUI.Label(_tmpRect, "bounds:"); _tmpRect.Set(130, topOffset, 100, 20); int newMode = GUI.SelectionGrid(_tmpRect, _selectedLimitOption, _limitOptions, 2, "toggle"); if (newMode != _selectedLimitOption) { _selectedLimitOption = newMode; TriggerChangeEvent(); } } }