예제 #1
0
 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));
     }
 }
예제 #2
0
        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);
        }