private void DrawParameterCreator() { GUILayout.BeginVertical(); EditorGUILayout.LabelField("Create New Parameter", EditorStyles.boldLabel); _newName = EditorGUILayout.TextField("Name", _newName); _newDescription = EventsManagerUI.WordWrappedTextField(_parent.position.width - LIST_WIDTH, "Description", _newDescription); _newType = (ParameterType)EditorGUILayout.EnumPopup("Type", _newType); if (_newType == ParameterType.String) { _newFormat = EditorGUILayout.TextField("Format", _newFormat); } if (String.IsNullOrEmpty(_newName)) { EditorGUILayout.HelpBox("A name is required.", MessageType.Warning); } else if (_parameterCreator.NameIsInvalid(_newName)) { EditorGUILayout.HelpBox("Parameter names must begin with a lower-case English letter (a-z), and otherwise can only include upper-case or lower-case English letters (a-z, A-Z), digits (0-9) or underscores (_).", MessageType.Warning); } else { bool nameAlreadyInUse = false; foreach (DDNAEventManagerEventParameter parameter in _parameterProvider.Data) { if (_newName.Equals(parameter.name, StringComparison.InvariantCultureIgnoreCase)) { nameAlreadyInUse = true; break; } } if (nameAlreadyInUse) { EditorGUILayout.HelpBox($"A parameter with the name {_newName} already exists.", MessageType.Warning); } else if (String.IsNullOrEmpty(_newDescription)) { EditorGUILayout.HelpBox("A description is required.", MessageType.Warning); } else if (GUILayout.Button("Create Parameter")) { _mode = Mode.Creating; CreateParameter(); } } GUILayout.EndVertical(); }
private void DrawEventCreator() { GUILayout.BeginVertical(); EditorGUILayout.LabelField("Create New Event", EditorStyles.boldLabel); _newEventName = EditorGUILayout.TextField("Event Name", _newEventName); _newEventDescription = EventsManagerUI.WordWrappedTextField(_parent.position.width - LIST_WIDTH, "Description", _newEventDescription); if (String.IsNullOrEmpty(_newEventName)) { EditorGUILayout.HelpBox("A name is required.", MessageType.Warning); } else if (_eventEditor.NameIsInvalid(_newEventName)) { EditorGUILayout.HelpBox("Event names can only include upper-case or lower-case English letters (a-z, A-Z), digits (0-9) or underscores (_).", MessageType.Warning); } else { bool nameAlreadyInUse = false; foreach (DDNAEventManagerEvent apiEvent in _eventProvider.Data) { if (apiEvent.environment == _environmentProvider.CurrentEnvironmentId && _newEventName.Equals(apiEvent.name, StringComparison.InvariantCultureIgnoreCase)) { nameAlreadyInUse = true; break; } } if (nameAlreadyInUse) { EditorGUILayout.HelpBox($"An event with the name {_newEventName} already exists.", MessageType.Warning); } else if (String.IsNullOrEmpty(_newEventDescription)) { EditorGUILayout.HelpBox("A description is required.", MessageType.Warning); } else if (GUILayout.Button("Create Event")) { _mode = Mode.Creating; _eventEditor.CreateEvent(_newEventName, _newEventDescription, _environmentProvider.CurrentEnvironmentId, _authProvider.AuthToken); } } GUILayout.EndVertical(); }