void WindowFunc(int windowID) { const int border = 15; const int width = 200; const int height = 30; const int spacing = 10; Rect msgRect = new Rect( border, border + spacing, m_windowRect.width - border * 2, m_windowRect.height - border * 2 - height - spacing); GUI.Label(msgRect, msg); float allButtonsHeight = (height + border) * actions.Length; float allButtonsStartY = (m_windowRect.height - allButtonsHeight) / 2; float currentY = allButtonsStartY; for (int i = 0, len = actions.Length; i < len; ++i) { currentY += border + height; Rect actionRect = new Rect( (m_windowRect.width - width) / 2, currentY, width, height); UIMessageBoxAction action = actions[i]; if (GUI.Button(actionRect, action.text)) { ExecuteAction(action); } } }
void ExecuteAction(UIMessageBoxAction action) { open = !action.close; action.action?.Invoke(); action.actions?.Invoke(); }