public static string GenerateTransitionMethods(FD.FlowWindow window) { var flowData = FlowSystem.GetData(); var result = string.Empty; var transitions = new List <FlowWindow>(); if (window.IsContainer() == true) { foreach (var attachItem in window.attachItems) { var attachWindow = flowData.GetWindow(attachItem.targetId); if (attachWindow.IsContainer() == true) { continue; } var items = attachWindow.attachItems.Where(x => { var w = flowData.GetWindow(x.targetId); return(w.IsContainer() == false); }).Select(x => flowData.GetWindow(x.targetId)); foreach (var item in items) { if (transitions.Any(x => x.id == item.id) == false) { transitions.Add(item); } } } } else { transitions = flowData.windowAssets.Where(w => window.attachItems.Any((item) => item.targetId == w.id) && !w.IsContainer()).ToList(); } if (transitions == null) { return(result); } foreach (var each in transitions) { var className = each.directory; var classNameWithNamespace = Tpl.GetNamespace(each) + "." + Tpl.GetDerivedClassName(each); if (each.IsShowDefault() == true) { // Collect all default windows foreach (var defaultWindowId in FlowSystem.GetDefaultWindows()) { var defaultWindow = FlowSystem.GetWindow(defaultWindowId); className = defaultWindow.directory; classNameWithNamespace = Tpl.GetNamespace(defaultWindow) + "." + Tpl.GetDerivedClassName(defaultWindow); result += TemplateGenerator.GenerateWindowLayoutTransitionMethod(window, each, className, classNameWithNamespace); FlowEditorUtilities.CollectCallVariations(each.GetScreen().Load <WindowBase>(), (listTypes, listNames) => { result += TemplateGenerator.GenerateWindowLayoutTransitionTypedMethod(window, each, className, classNameWithNamespace, listTypes, listNames); }); } continue; } else { if (each.CanCompiled() == false) { continue; } } result += TemplateGenerator.GenerateWindowLayoutTransitionMethod(window, each, className, classNameWithNamespace); FlowEditorUtilities.CollectCallVariations(each.GetScreen().Load <WindowBase>(), (listTypes, listNames) => { result += TemplateGenerator.GenerateWindowLayoutTransitionTypedMethod(window, each, className, classNameWithNamespace, listTypes, listNames); }); } var c = 0; var everyPlatformHasUniqueName = false; foreach (var attachItem in window.attachItems) { var attachId = attachItem.targetId; var attachedWindow = FlowSystem.GetWindow(attachId); var tmp = UnityEditor.UI.Windows.Plugins.Flow.Flow.IsCompilerTransitionAttachedGeneration(window, attachedWindow); if (tmp == true) { ++c; } } everyPlatformHasUniqueName = c > 1; foreach (var attachItem in window.attachItems) { var attachId = attachItem.targetId; var attachedWindow = FlowSystem.GetWindow(attachId); if (attachedWindow.IsShowDefault() == true) { // Collect all default windows foreach (var defaultWindowId in FlowSystem.GetDefaultWindows()) { var defaultWindow = FlowSystem.GetWindow(defaultWindowId); result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionAttachedGeneration(window, defaultWindow, everyPlatformHasUniqueName); FlowEditorUtilities.CollectCallVariations(attachedWindow.GetScreen().Load <WindowBase>(), (listTypes, listNames) => { result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionTypedAttachedGeneration(window, defaultWindow, everyPlatformHasUniqueName, listTypes, listNames); }); } result += TemplateGenerator.GenerateWindowLayoutTransitionMethodDefault(); } /*if (withFunctionRoot == true) { * * var functionId = attachedWindow.GetFunctionId(); * var functionContainer = flowData.GetWindow(functionId); * if (functionContainer != null) { * * var root = flowData.GetWindow(functionContainer.functionRootId); * if (root != null) { * * attachedWindow = root; * * } * * } * * }*/ result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionAttachedGeneration(window, attachedWindow, everyPlatformHasUniqueName); FlowEditorUtilities.CollectCallVariations(attachedWindow.GetScreen().Load <WindowBase>(), (listTypes, listNames) => { result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionTypedAttachedGeneration(window, attachedWindow, everyPlatformHasUniqueName, listTypes, listNames); }); } // Run addons transition logic result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionGeneration(window); return(result); }
public static void DrawComponentChooser(Rect rect, GameObject gameObject, WindowComponent component, System.Action <WindowComponent> onSelect, GUIStyle style = null) { if (style == null) { style = GUILayoutExt.componentChooserStyle; style.fixedWidth = 0f; style.fixedHeight = 0f; } if (GUI.Button(rect, "+", style) == true) { var anySpecial = Event.current.shift || Event.current.command || Event.current.control || Event.current.alt; GenericMenu.MenuFunction2 onAction = (object comp) => { onSelect(comp as WindowComponent); }; var libraries = ME.EditorUtilities.GetAssetsOfType <WindowComponentLibraryLinker>(null, (p) => { return(!p.child); }); var screenRect = new Rect(rect.x, rect.y + rect.height, 150f, 250f); Vector2 vector = GUIUtility.GUIToScreenPoint(new Vector2(screenRect.x, screenRect.y)); screenRect.x = vector.x; screenRect.y = vector.y; Popup popup = null; GenericMenu menu = null; if (anySpecial == false) { popup = new Popup() { screenRect = screenRect }; } else { menu = new GenericMenu(); } var package = FlowEditorUtilities.GetPackage(gameObject); if (package != null) { var components = ME.EditorUtilities.GetPrefabsOfType <WindowComponent>(strongType: false, directory: AssetDatabase.GetAssetPath(package)); for (int i = 0; i < components.Length; ++i) { var comp = components[i]; var path = AssetDatabase.GetAssetPath(comp.gameObject); var packagePath = AssetDatabase.GetAssetPath(package); var _path = path.Replace(packagePath, string.Empty); _path = _path.Replace("/Components", string.Empty); _path = Path.GetDirectoryName(_path); _path = _path.TrimEnd('/'); _path = package.name + " Screen" + _path + "/" + comp.gameObject.name.ToSentenceCase(); if (anySpecial == false) { var index = i; popup.ItemByPath(_path, () => { onAction(components[index]); }); } else { menu.AddItem(new GUIContent(_path), on: (comp == component), func: onAction, userData: comp); } } if (anySpecial == true) { menu.AddSeparator(string.Empty); } } var k = 0; var z = 0; foreach (var library in libraries) { foreach (var item in library.items) { var path = library.name + "/" + item.localDirectory + "/" + item.title.ToSentenceCase(); if (anySpecial == true) { menu.AddItem(new GUIContent(path), on: (item.mainComponent == component), func: onAction, userData: item.mainComponent); } else { var index1 = z; var index2 = k; popup.ItemByPath(path, () => { onAction(libraries[index1].items[index2].mainComponent); }); } ++k; } ++z; k = 0; } if (anySpecial == false) { popup.Show(); } else { menu.DropDown(rect); } } }