public void Layout(IGUIState guiState) { Debug.Assert(guiState.eventType == EventType.Layout); for (var i = 0; i < GetCount(); ++i) { if (guiState.hotControl == actionID && hotLayoutData.index == i) { continue; } var layoutData = new LayoutData() { index = i, position = GetPosition(guiState, i), distance = GetDistance(guiState, i), forward = GetForward(guiState, i), up = GetUp(guiState, i), right = GetRight(guiState, i), userData = GetUserData(guiState, i) }; m_LayoutData = LayoutData.Nearest(m_LayoutData, layoutData); } }
public void OnGUI() { var nearestLayoutData = LayoutData.zero; foreach (var control in m_Controls) { control.GetControl(m_GUIState); } if (m_GUIState.eventType == EventType.Layout) { foreach (var control in m_Controls) { control.BeginLayout(m_GUIState); } foreach (var control in m_Controls) { control.Layout(m_GUIState); nearestLayoutData = LayoutData.Nearest(nearestLayoutData, control.layoutData); } foreach (var control in m_Controls) { m_GUIState.AddControl(control.ID, control.layoutData.distance); } foreach (var control in m_Controls) { control.EndLayout(m_GUIState); } if (m_PrevNearestControl == m_GUIState.nearestControl) { if (nearestLayoutData.index != m_PrevNearestLayoutData.index) { m_GUIState.Repaint(); } } else { m_PrevNearestControl = m_GUIState.nearestControl; m_GUIState.Repaint(); } m_PrevNearestLayoutData = nearestLayoutData; } if (m_GUIState.eventType == EventType.Repaint) { foreach (var action in m_Actions) { if (action.IsRepaintEnabled(m_GUIState)) { action.PreRepaint(m_GUIState); } } foreach (var control in m_Controls) { control.Repaint(m_GUIState); } } var repaintOnMouseMove = false; foreach (var action in m_Actions) { if (IsMouseMoveEvent()) { repaintOnMouseMove |= action.IsRepaintOnMouseMoveEnabled(m_GUIState); } action.OnGUI(m_GUIState); } if (repaintOnMouseMove) { m_GUIState.UseCurrentEvent(); } }