public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float baseHeight = GetBaseHeight(); EventReference eventReference = property.GetEventReference(); EditorEventRef editorEventRef = GetEditorEventRef(eventReference); if (editorEventRef == null) { return(baseHeight + WarningSize().y); } else { float height; if (property.isExpanded) { height = baseHeight * 6; // 5 lines of info } else { height = baseHeight; } if (GetMismatch(eventReference, editorEventRef) != null) { height += WarningSize().y; } return(height); } }
public EventNotFoundException(EventReference eventReference) : base("[FMOD] Event not found: " + eventReference.ToString()) { Guid = eventReference.Guid; #if UNITY_EDITOR Path = eventReference.Path; #endif }
private static EditorEventRef GetEditorEventRef(EventReference eventReference) { if (EventManager.GetEventLinkage(eventReference) == EventLinkage.Path) { return(EventManager.EventFromPath(eventReference.Path)); } else // Assume EventLinkage.GUID { return(EventManager.EventFromGUID(eventReference.Guid)); } }
private static EditorEventRef GetRenamedEventRef(EventReference eventReference) { if (Settings.Instance.EventLinkage == EventLinkage.Path && !eventReference.Guid.IsNull) { EditorEventRef editorEventRef = EventManager.EventFromGUID(eventReference.Guid); if (editorEventRef != null && editorEventRef.Path != eventReference.Path) { return(editorEventRef); } } return(null); }
private static MismatchInfo GetMismatch(EventReference eventReference, EditorEventRef editorEventRef) { if (EventManager.GetEventLinkage(eventReference) == EventLinkage.Path) { if (eventReference.Guid != editorEventRef.Guid) { return(new MismatchInfo() { Message = "GUID doesn't match path", HelpText = string.Format( "The GUID on this EventReference doesn't match the path.\n" + "You can click the repair button to update the GUID to match the path, 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 GUID to {0}", editorEventRef.Guid), RepairAction = (property) => { property.FindPropertyRelative("Guid").SetGuid(editorEventRef.Guid); }, }); } } else // EventLinkage.GUID { if (eventReference.Path != editorEventRef.Path) { return(new MismatchInfo() { Message = "Path doesn't match GUID", HelpText = string.Format( "The path on this EventReference doesn't match the GUID.\n" + "You can click the repair button to update the path to match the GUID, 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}'", editorEventRef.Path), RepairAction = (property) => { property.FindPropertyRelative("Path").stringValue = editorEventRef.Path; }, }); } } return(null); }
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); } } } }