public override string ToString() { var info = new StringBuilder(); MismatchInfo.ForEach(kvp => info.AppendLine($"[{kvp.Key}]: {kvp.Value}")); info.AppendLine($"Commenatry: {Commentary}"); return(info.ToString()); }
private static void DrawMismatchUI(Rect rect, float repairButtonX, float repairButtonWidth, MismatchInfo mismatch, SerializedProperty property) { rect = EditorUtils.DrawHelpButton(rect, () => new SimpleHelp(mismatch.HelpText, 400)); Rect repairRect = new Rect(repairButtonX, rect.y, repairButtonWidth, GetBaseHeight()); if (GUI.Button(repairRect, new GUIContent(RepairIcon, mismatch.RepairTooltip), buttonStyle)) { mismatch.RepairAction(property); } Rect labelRect = rect; labelRect.xMax = repairRect.xMin; GUI.Label(labelRect, new GUIContent(mismatch.Message, WarningIcon)); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (buttonStyle == null) { buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.padding.top = 1; buttonStyle.padding.bottom = 1; } Texture browseIcon = EditorUtils.LoadImage("SearchIconBlack.png"); Texture openIcon = EditorUtils.LoadImage("BrowserIcon.png"); Texture addIcon = EditorUtils.LoadImage("AddIcon.png"); Texture copyIcon = EditorUtils.LoadImage("CopyIcon.png"); using (new EditorGUI.PropertyScope(position, label, property)) { HandleDragEvents(position, property); EventReference eventReference = property.GetEventReference(); EditorEventRef editorEventRef = GetEditorEventRef(eventReference); float baseHeight = GetBaseHeight(); Rect headerRect = position; headerRect.width = EditorGUIUtility.labelWidth; headerRect.height = baseHeight; if (editorEventRef != null) { property.isExpanded = EditorGUI.Foldout(headerRect, property.isExpanded, label, true); } else { EditorGUI.LabelField(headerRect, label); } Rect addRect = new Rect(position.xMax - addIcon.width - 7, position.y, addIcon.width + 7, baseHeight); Rect openRect = new Rect(addRect.x - openIcon.width - 7, position.y, openIcon.width + 6, baseHeight); Rect searchRect = new Rect(openRect.x - browseIcon.width - 9, position.y, browseIcon.width + 8, baseHeight); Rect pathRect = position; pathRect.xMin = headerRect.xMax; pathRect.xMax = searchRect.x - 3; pathRect.height = baseHeight; SerializedProperty pathProperty = GetPathProperty(property); using (var scope = new EditorGUI.ChangeCheckScope()) { EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none); if (scope.changed) { SetEvent(property, pathProperty.stringValue); } } if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle)) { var eventBrowser = ScriptableObject.CreateInstance <EventBrowser>(); eventBrowser.ChooseEvent(property); var windowRect = position; windowRect.xMin = pathRect.xMin; windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); windowRect.height = openRect.height + 1; eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400)); } if (GUI.Button(addRect, new GUIContent(addIcon, "Create New Event in Studio"), buttonStyle)) { var addDropdown = EditorWindow.CreateInstance <CreateEventPopup>(); addDropdown.SelectEvent(property); var windowRect = position; windowRect.xMin = pathRect.xMin; windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position); windowRect.height = openRect.height + 1; addDropdown.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 500)); } if (GUI.Button(openRect, new GUIContent(openIcon, "Open In Browser"), buttonStyle) && !string.IsNullOrEmpty(pathProperty.stringValue) && EventManager.EventFromPath(pathProperty.stringValue) != null ) { EventBrowser.ShowWindow(); EventBrowser eventBrowser = EditorWindow.GetWindow <EventBrowser>(); eventBrowser.FrameEvent(pathProperty.stringValue); } if (editorEventRef != null) { float labelY = headerRect.y + baseHeight; MismatchInfo mismatch = GetMismatch(eventReference, editorEventRef); if (mismatch != null) { Rect warningRect = pathRect; warningRect.xMax = position.xMax; warningRect.y = labelY; warningRect.height = WarningSize().y; DrawMismatchUI(warningRect, openRect.x, openRect.width, mismatch, property); labelY = warningRect.yMax; } if (property.isExpanded) { using (new EditorGUI.IndentLevelScope()) { Rect labelRect = EditorGUI.IndentedRect(headerRect); labelRect.y = labelY; Rect valueRect = labelRect; valueRect.xMin = labelRect.xMax; valueRect.xMax = position.xMax - copyIcon.width - 7; GUI.Label(labelRect, new GUIContent("GUID")); GUI.Label(valueRect, eventReference.Guid.ToString()); Rect copyRect = valueRect; copyRect.xMin = valueRect.xMax; copyRect.xMax = position.xMax; if (GUI.Button(copyRect, new GUIContent(copyIcon, "Copy To Clipboard"))) { EditorGUIUtility.systemCopyBuffer = eventReference.Guid.ToString(); } valueRect.xMax = position.xMax; labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("Banks")); GUI.Label(valueRect, string.Join(", ", editorEventRef.Banks.Select(x => x.Name).ToArray())); labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("Panning")); GUI.Label(valueRect, editorEventRef.Is3D ? "3D" : "2D"); labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("Stream")); GUI.Label(valueRect, editorEventRef.IsStream.ToString()); labelRect.y += baseHeight; valueRect.y += baseHeight; GUI.Label(labelRect, new GUIContent("Oneshot")); GUI.Label(valueRect, editorEventRef.IsOneShot.ToString()); labelRect.y += baseHeight; valueRect.y += baseHeight; } } } else { EditorEventRef renamedEvent = GetRenamedEventRef(eventReference); if (renamedEvent != null) { MismatchInfo mismatch = new MismatchInfo() { Message = string.Format("Moved to {0}", renamedEvent.Path), HelpText = string.Format( "This event has been moved in FMOD Studio.\n" + "You can click the repair button to update the path to the new location, or run " + "the <b>{0}</b> command to scan your project for similar issues and fix them all.", EventReferenceUpdater.MenuPath), RepairTooltip = string.Format("Repair: set path to {0}", renamedEvent.Path), RepairAction = (p) => { p.FindPropertyRelative("Path").stringValue = renamedEvent.Path; }, }; using (new EditorGUI.IndentLevelScope()) { Rect mismatchRect = pathRect; mismatchRect.xMin = position.xMin; mismatchRect.xMax = position.xMax; mismatchRect.y += baseHeight; mismatchRect.height = baseHeight; mismatchRect = EditorGUI.IndentedRect(mismatchRect); DrawMismatchUI(mismatchRect, openRect.x, openRect.width, mismatch, property); } } else { Rect labelRect = pathRect; labelRect.xMax = position.xMax; labelRect.y += baseHeight; labelRect.height = WarningSize().y; GUI.Label(labelRect, NotFoundWarning); } } } }