private void OnEnable() { EditorGrid.BackgroundColor = new Color(0f, 0, 0, 0.5f); EditorGrid.BackGroundGridLineColor = new Color(0, 0, 0, 0.3f); EditorGrid.Initialize(this); EditorGrid.SetViewPort(new ViewPort(0.1f, 0.1f, 0.8f, 0.8f));; EditorGrid.IsOutlineActive = true; EditorGrid.GridOutlineColor = Color.blue; //--Some Performance Testing--// /* * for (int i = 0; i < 100 ; ++i) * { * var bigTexture = new GridTexture(new Cell(-10, -10), 40, 20, Texture2D.whiteTexture) {IsInteractable = true, CanDrag = true}; * * //texture.Transform.Parent = bigTexture.Transform; * * var label = new GridLabel(new Cell(1, 0)); * * label.SetFontSize(3); * * label.Content = "I'm a Label!"; * * label.Transform.Parent = bigTexture.Transform; * } */ }
public static void ProcessInput() { if (e == null) { return; } switch (e.type) { case EventType.Ignore: case EventType.Repaint: case EventType.Layout: case EventType.Used: return; case EventType.MouseMove: UpdateMousePosition(); break; } //If the mouse button was held last frame and the used is dragging the mouse we initialize the drag if (_prepareToDrag && e.type == EventType.MouseDrag) { _isDragging = true; _prepareToDrag = false; _eventTrigger.Invoke(TriggerEvent.StartedDrag); } else if (_prepareToDrag) { _prepareToDrag = false; } if (_isDragging) { ProcessDrag(); } var triggerUnderCursor = !_isDragging?GetCurrentTriggerUnderCursor() : _eventTrigger; if (_eventTrigger != triggerUnderCursor) { OnTriggerUnderCursorChanged(triggerUnderCursor); } if (!EditorGrid.IsInViewportEditorSpace(_mousePosition.TopLeft.GetPosition(), _mousePosition.BottomRight.GetPosition())) { return; } if (_eventTrigger == null || e.type == EventType.ScrollWheel) { ProcessGridInput(); return; } switch (e.type) { case EventType.DragPerform: _eventTrigger.Invoke(TriggerEvent.Drag); e.Use(); break; case EventType.DragExited: _eventTrigger.Invoke(TriggerEvent.DragFinished); e.Use(); break; case EventType.MouseDown: _prepareToDrag = true; _eventTrigger.Invoke(TriggerEvent.OnMouseDown); e.Use(); break; case EventType.MouseUp: _eventTrigger.Invoke(TriggerEvent.OnMouseUp); e.Use(); break; } }
protected void OnGUI() { EditorGrid.Update(); }