protected void DrawButtons(GUIDialogResult _delegate, float _widthFactor = 0.5f) { if (ButtonList == null) { return; } GUILayoutOption _width = GUILayout.Width(Screen.width * _widthFactor); if (ButtonList.Length <= 2) { GUILayout.BeginHorizontal(_width); { foreach (string each in ButtonList) { if (GUILayout.Button(each)) { //Send the callback and destroy if (_delegate != null) { _delegate(each); } //Close by destroying this object Close(); } } } GUILayout.EndHorizontal(); } else { GUILayout.BeginVertical(_width); { foreach (string each in ButtonList) { if (GUILayout.Button(each)) { //Send the callback and destroy if (_delegate != null) { _delegate(each); } //Close by destroying this object Close(); } } } GUILayout.EndHorizontal(); } }
protected void DrawButtons(GUIDialogResult _delegate, float _widthFactor = 0.5f) { if (ButtonList == null) return; GUILayoutOption _width = GUILayout.Width(Screen.width * _widthFactor); if (ButtonList.Length <= 2) { GUILayout.BeginHorizontal(_width); { foreach(string each in ButtonList) { if (GUILayout.Button(each)) { //Send the callback and destroy if (_delegate != null) { _delegate(each); } //Close by destroying this object Close(); } } } GUILayout.EndHorizontal(); } else { GUILayout.BeginVertical(_width); { foreach(string each in ButtonList) { if (GUILayout.Button(each)) { //Send the callback and destroy if (_delegate != null) { _delegate(each); } //Close by destroying this object Close(); } } } GUILayout.EndHorizontal(); } }
protected void DrawButtons(GUIDialogResult _delegate, float _widthFactor = 0.5f) { if (ButtonList == null) return; GUILayoutOption _width = GUILayout.Width(Screen.width * _widthFactor); bool _buttonPressed = false; if (ButtonList.Length <= 2) { GUILayout.BeginHorizontal(_width); { foreach (string each in ButtonList) { if (GUILayout.Button(each)) { // Update flag _buttonPressed = true; // Send the callback and destroy if (_delegate != null) _delegate(each); // Close by destroying this object Close(); } } } GUILayout.EndHorizontal(); } else { GUILayout.BeginVertical(_width); { foreach (string each in ButtonList) { if (GUILayout.Button(each)) { // Update flag _buttonPressed = true; // Send the callback and destroy if (_delegate != null) _delegate(each); // Close by destroying this object Close(); } } } GUILayout.EndVertical(); } // Check if enter was pressed if (!_buttonPressed && m_returnPressed) { // Send the callback and destroy if (_delegate != null) _delegate(ButtonList[0]); // Close by destroying this object Close(); } m_returnPressed = false; }
protected void DrawButtons(GUIDialogResult _delegate, float _widthFactor = 0.5f) { if (ButtonList == null) { return; } GUILayoutOption _width = GUILayout.Width(Screen.width * _widthFactor); bool _buttonPressed = false; if (ButtonList.Length <= 2) { GUILayout.BeginHorizontal(_width); { foreach (string each in ButtonList) { if (GUILayout.Button(each)) { // Update flag _buttonPressed = true; // Send the callback and destroy if (_delegate != null) { _delegate(each); } // Close by destroying this object Close(); } } } GUILayout.EndHorizontal(); } else { GUILayout.BeginVertical(_width); { foreach (string each in ButtonList) { if (GUILayout.Button(each)) { // Update flag _buttonPressed = true; // Send the callback and destroy if (_delegate != null) { _delegate(each); } // Close by destroying this object Close(); } } } GUILayout.EndVertical(); } // Check if enter was pressed if (!_buttonPressed && m_returnPressed) { // Send the callback and destroy if (_delegate != null) { _delegate(ButtonList[0]); } // Close by destroying this object Close(); } m_returnPressed = false; }