public static string GenerateReturnMethod(FlowSystemEditorWindow flowEditor, FlowWindow exitWindow) { var file = Resources.Load("UI.Windows/Functions/Templates/TemplateReturnMethod") as TextAsset; if (file == null) { Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateReturnMethod'"); return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } var result = string.Empty; var part = file.text; var functionContainer = exitWindow.GetFunctionContainer(); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetNamespace(exitWindow) + "." + Tpl.GetDerivedClassName(exitWindow); result += part.Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace); return(result); }
public FlowSceneItem(FlowSystemEditorWindow rootWindow, FD.FlowWindow window, AnimatedValues.AnimFloat progressValue) { this.isLocked = false; this.rootWindow = rootWindow; this.window = window; #if UNITY_5_2 this.currentScene = EditorApplication.currentScene; #else this.currentScene = EditorSceneManager.GetActiveScene(); #endif this.layouts = new List <WindowLayout>(); this.layoutPrefab = null; this.screens = new List <WindowBase>(); this.screenPrefab = null; #if UNITY_5_2 EditorApplication.NewEmptyScene(); #else EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.EmptyScene); #endif var popupOffset = 100f; var popupSize = new Vector2(rootWindow.position.width - popupOffset * 2f, rootWindow.position.height - popupOffset * 2f); var popupRect = new Rect(rootWindow.position.x + popupOffset, rootWindow.position.y + popupOffset, popupSize.x, popupSize.y); this.view = FlowSceneViewWindow.CreateInstance <FlowSceneViewWindow>(); FlowSceneView.recompileChecker = this.view; var title = "UI.Windows Flow Screen Editor ('{0}')"; title = string.Format(title, this.window.title); this.view.titleContent = new GUIContent(string.Format(title, this.window.title)); this.view.position = popupRect; this.view.rootWindow = rootWindow; this.Show(); this.view.Repaint(); this.view.Focus(); this.autoloadedScreen = false; this.ReloadScreens(); this.autoloadedLayout = false; this.ReloadLayouts(); this.defaultRects = false; progressValue.valueChanged.AddListener(() => { this.view.DrawProgress(progressValue.value); if (progressValue.value == progressValue.target) { this.view.Repaint(); this.view.Focus(); } }); }
public static void OnReset(FlowSystemEditorWindow flowEditor) { var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>(); foreach (var addon in flowAddons) { addon.flowEditor = flowEditor; addon.Reset(); } }
public static void OnFlowWindowTransition(FlowSystemEditorWindow flowEditor, int index, FD.FlowWindow fromWindow, FD.FlowWindow toWindow, bool doubleSided, Vector2 centerOffset) { var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>(); foreach (var addon in flowAddons) { addon.flowEditor = flowEditor; addon.OnFlowWindowTransition(index, fromWindow, toWindow, doubleSided, centerOffset); } }
public static void OnFlowWindowScreenMenuGUI(FlowSystemEditorWindow flowEditor, FD.FlowWindow window, GenericMenu menu) { var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>(); foreach (var addon in flowAddons) { addon.flowEditor = flowEditor; addon.OnFlowWindowScreenMenuGUI(window, menu); } }
public static void OnDrawToolsMenuGUI(FlowSystemEditorWindow flowEditor, string prefix, GenericMenu menu) { var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>(); foreach (var addon in flowAddons) { addon.flowEditor = flowEditor; addon.OnFlowToolsMenuGUI(prefix, menu); } }
public static void OnDrawWindowGUI(FlowSystemEditorWindow flowEditor, FlowWindow window) { var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>(); foreach (var addon in flowAddons) { addon.flowEditor = flowEditor; addon.OnFlowWindowGUI(window); } }
public static void OnDrawToolbarGUI(FlowSystemEditorWindow flowEditor, GUIStyle buttonStyle) { var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>(); foreach (var addon in flowAddons) { addon.flowEditor = flowEditor; addon.OnFlowToolbarGUI(buttonStyle); } }
public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FlowWindow windowFrom, FlowWindow windowTo) { var file = Resources.Load("UI.Windows/Functions/Templates/TemplateTransitionMethod") as TextAsset; if (file == null) { Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateTransitionMethod'"); return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } var result = string.Empty; var part = file.text; // Function link var functionId = windowTo.GetFunctionId(); // Find function container var functionContainer = data.GetWindow(functionId); if (functionContainer == null) { // Function not found return(string.Empty); } // Get function root window var root = data.GetWindow(functionContainer.functionRootId); //var exit = data.GetWindow(functionContainer.functionExitId); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetNamespace(root) + "." + Tpl.GetDerivedClassName(root); var transitionMethods = Tpl.GenerateTransitionMethods(windowTo); transitionMethods = transitionMethods.Replace("\r\n", "\r\n\t") .Replace("\n", "\n\t"); result += part.Replace("{TRANSITION_METHODS}", transitionMethods) .Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{FLOW_FROM_ID}", windowFrom.id.ToString()) .Replace("{FLOW_TO_ID}", windowTo.id.ToString()) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace); return(result); }
public void DrawCap(Vector3 pos, Vector3 startPos, Vector3 endPos, Quaternion rot, Color shadowColor, Color lineColor) { if (FlowSystem.GetZoom() < 1f) { return; } if (this.arrow == null) { this.arrow = Resources.Load <Texture2D>("UI.Windows/Flow/Arrow"); } var size = 12f; size /= FlowSystem.GetZoom(); //pos = this.editor.zoomDrawer.ConvertScreenCoordsToZoomCoords(pos, topLeft: true); var scrollPos = -FlowSystem.GetScrollPosition(); var offset = -8f; if (this.editor.scrollRect.Contains(new Vector3(pos.x - scrollPos.x + FlowSystemEditorWindow.GetSettingsWidth() + offset, pos.y - scrollPos.y + FlowSystemEditorWindow.TOOLBAR_HEIGHT + offset, 0f)) == false) { return; } var shadowOffset = Vector3.one * 1f; shadowOffset.z = 0f; var v1 = startPos - endPos; v1.x = -v1.x; var v2 = Vector3.left; var angle = Mathf.Atan2( Vector3.Dot(Vector3.back, Vector3.Cross(v1, v2)), Vector3.Dot(v1, v2)) * Mathf.Rad2Deg; var oldColor = GUI.color; GUI.color = shadowColor; GUIExt.DrawTextureRotated(new Rect(pos.x - size * 0.5f + shadowOffset.x, pos.y - size * 0.5f + shadowOffset.y, size, size), arrow, -angle + 180f); GUI.color = lineColor; GUIExt.DrawTextureRotated(new Rect(pos.x - size * 0.5f, pos.y - size * 0.5f, size, size), arrow, -angle + 180f); GUI.color = oldColor; /*Handles.color = shadowColor; * Handles.ConeCap(-1, pos + shadowOffset, rot, 15f); * Handles.color = lineColor; * Handles.ConeCap(-1, pos, rot, 15f);*/ }
public FlowSplash(FlowSystemEditorWindow editor) { this.editor = editor; if (this.skin == null) { this.skin = Resources.Load <GUISkin>("UI.Windows/Flow/Styles/" + (EditorGUIUtility.isProSkin == true ? "SkinDark" : "SkinLight")); } if (this.splash == null) { this.splash = Resources.Load <Texture>("UI.Windows/Flow/Splash"); } }
public FlowSplash(FlowSystemEditorWindow editor) { this.editor = editor; if (this.skin == null) { this.skin = UnityEngine.Resources.Load <GUISkin>(string.Format("UI.Windows/Flow/Styles/{0}", (EditorGUIUtility.isProSkin == true ? "SkinDark" : "SkinLight"))); } if (this.splash == null) { this.splash = UnityEngine.Resources.Load <Texture>(EditorGUIUtility.isProSkin == true ? "UI.Windows/Flow/Splash_Pro" : "UI.Windows/Flow/Splash"); } }
public static Vector2 OnDrawNodeCurveOffset(FlowSystemEditorWindow flowEditor, UnityEngine.UI.Windows.AttachItem attachItem, FD.FlowWindow fromWindow, FD.FlowWindow toWindow, bool doubleSide) { var offset = Vector2.zero; var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>(); foreach (var addon in flowAddons) { addon.flowEditor = flowEditor; offset += addon.OnFlowDrawNodeCurveOffset(attachItem, fromWindow, toWindow, doubleSide); } return(offset); }
public static void SetControl(FlowSystemEditorWindow rootWindow, FlowWindow window, System.Action <float> onProgress) { if (EditorApplication.SaveCurrentSceneIfUserWantsTo() == true) { FlowSceneView.editAnimation = new UnityEditor.AnimatedValues.AnimFloat(0f, () => { onProgress(FlowSceneView.editAnimation.value); }); FlowSceneView.editAnimation.value = 0f; FlowSceneView.editAnimation.speed = 2f; FlowSceneView.editAnimation.target = 1f; FlowSceneView.currentItem = new FlowSceneItem(rootWindow, window, FlowSceneView.editAnimation); FlowSceneView.isActive = true; } }
public static string GenerateReturnMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow exitWindow) { var file = UnityEngine.Resources.Load("UI.Windows/Functions/Templates/TemplateReturnMethod") as TextAsset; if (file == null) { if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) { UnityEngine.Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateReturnMethod'"); } return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } var result = string.Empty; var part = file.text; var functionContainer = exitWindow.GetFunctionContainer(); if (functionContainer == null) { // Function not found return(string.Empty); } var exit = data.GetWindow(functionContainer.functionExitId); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetClassNameWithNamespace(exit); result += part.Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace); return(result); }
public static void SetControl(FlowSystemEditorWindow rootWindow, FD.FlowWindow window, System.Action <float> onProgress) { #if UNITY_5_2 if (EditorApplication.SaveCurrentSceneIfUserWantsTo() == true) { #else if (UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() == true) { #endif FlowSceneView.editAnimation = new UnityEditor.AnimatedValues.AnimFloat(0f, () => { onProgress(FlowSceneView.editAnimation.value); }); FlowSceneView.editAnimation.value = 0f; FlowSceneView.editAnimation.speed = 2f; FlowSceneView.editAnimation.target = 1f; FlowSceneView.currentItem = new FlowSceneItem(rootWindow, window, FlowSceneView.editAnimation); FlowSceneView.isActive = true; } }
public static void OnDrawSettingsGUI(FlowSystemEditorWindow flowEditor) { var flowAddons = CoreUtilities.GetAddons <FlowAddon>((name, item) => item.name = name); if (flowAddons.Count == 0) { GUILayout.Label("No Modules Has Been Installed."); } else { foreach (var addon in flowAddons) { #if DEBUGBUILD Profiler.BeginSample("[ GUI ] Addon " + addon.name); #endif addon.flowEditor = flowEditor; Flow.DrawModuleSettingsGUI(addon, addon.GetName(), addon.GetSettingsMenu(null), () => { addon.OnFlowSettingsGUI(); }); #if DEBUGBUILD Profiler.EndSample(); #endif } } CustomGUI.Splitter(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayoutExt.LargeButton("Install Modules...", 40f, 200f) == true) { Application.OpenURL(VersionInfo.DOWNLOAD_LINK); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); }
public static void DrawModuleSettingsGUI(IWindowFlowAddon addon, string caption, GenericMenu settingsMenu, System.Action onGUI) { //CustomGUI.Splitter(new Color(0.7f, 0.7f, 0.7f, 0.2f)); var key = "UI.Windows.Addons." + caption + ":foldout"; var show = EditorPrefs.GetBool(key, true); GUILayout.BeginHorizontal(); { var style = ME.Utilities.CacheStyle("UI.Windows.Settings.AddonToggle", "Toggle", (name) => { return(FlowSystemEditorWindow.defaultSkin.FindStyle("SettingsAddonToggle")); }); var styleSelected = ME.Utilities.CacheStyle("UI.Windows.Settings.AddonToggle", "ToggleSelected", (name) => { return(FlowSystemEditorWindow.defaultSkin.FindStyle("SettingsAddonToggleSelected")); }); var newShow = GUILayout.Toggle(show, caption.ToSentenceCase().UppercaseWords(), show == true ? styleSelected : style); var rect = GUILayoutUtility.GetLastRect(); if (GUI.enabled == true) { EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link); } if (rect.Contains(Event.current.mousePosition) == true) { FlowSystemEditorWindow.GetWindow <FlowSystemEditorWindow>().Repaint(); } if (newShow != show) { show = newShow; EditorPrefs.SetBool(key, show); } if (settingsMenu != null) { var settingsStyle = new GUIStyle("PaneOptions"); if (GUILayout.Button(string.Empty, settingsStyle) == true) { settingsMenu.ShowAsContext(); } } } GUILayout.EndHorizontal(); //CustomGUI.Splitter(new Color(0.7f, 0.7f, 0.7f, 0.2f)); if (show == true) { GUILayout.BeginVertical(FlowSystemEditorWindow.defaultSkin.box); { if (addon != null && addon.InstallationNeeded() == true) { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayoutExt.LargeButton("Install", 40f, 200f) == true) { addon.Install(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } else { onGUI(); } } GUILayout.EndVertical(); } }
public FlowSceneItem(FlowSystemEditorWindow rootWindow, FlowWindow window, AnimatedValues.AnimFloat progressValue) { this.isLocked = false; this.rootWindow = rootWindow; this.window = window; this.currentScene = EditorApplication.currentScene; this.layouts = new List <WindowLayout>(); this.layoutPrefab = null; this.screens = new List <WindowBase>(); this.screenPrefab = null; #if UNITY_5_0 EditorApplication.NewEmptyScene(); #else EditorApplication.NewScene(); #endif var popupOffset = 100f; var popupSize = new Vector2(rootWindow.position.width - popupOffset * 2f, rootWindow.position.height - popupOffset * 2f); var popupRect = new Rect(rootWindow.position.x + popupOffset, rootWindow.position.y + popupOffset, popupSize.x, popupSize.y); this.view = FlowSceneViewWindow.CreateInstance <FlowSceneViewWindow>(); FlowSceneView.recompileChecker = this.view; this.view.title = "UI.Windows Flow Screen Editor ('" + this.window.title + "')"; this.view.position = popupRect; this.view.rootWindow = rootWindow; /*this.inspector = FlowInspectorWindow.CreateInstance<FlowInspectorWindow>(); * this.inspector.position = popupRect; * this.inspector.rootWindow = rootWindow; * this.inspector.Repaint(); * this.inspector.Focus(); * * this.hierarchy = FlowHierarchyWindow.CreateInstance<FlowHierarchyWindow>(); * this.hierarchy.position = popupRect; * this.hierarchy.rootWindow = rootWindow; * this.hierarchy.Repaint(); * this.hierarchy.Focus();*/ this.Show(); //this.inspector.Repaint(); //this.inspector.Focus(); //this.hierarchy.Repaint(); //this.hierarchy.Focus(); this.view.Repaint(); this.view.Focus(); this.autoloadedScreen = false; this.ReloadScreens(); this.autoloadedLayout = false; this.ReloadLayouts(); this.defaultRects = false; progressValue.valueChanged.AddListener(() => { this.view.DrawProgress(progressValue.value); //this.inspector.DrawProgress(progressValue.value); //this.hierarchy.DrawProgress(progressValue.value); if (progressValue.value == progressValue.target) { this.view.Repaint(); this.view.Focus(); } }); }
public GUIDrawer(FlowSystemEditorWindow editor) { this.editor = editor; }
public static FlowSystemEditorWindow ShowEditor(System.Action onClose) { return(FlowSystemEditorWindow.ShowEditor(onClose)); }
public static string GenerateTransitionTypedMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow windowFrom, FD.FlowWindow windowTo, System.Type[] parameters, string[] parameterNames) { var file = UnityEngine.Resources.Load("UI.Windows/Functions/Templates/TemplateTransitionTypedMethod") as TextAsset; if (file == null) { Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateTransitionTypedMethod'"); return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } var result = string.Empty; var part = file.text; // Function link var functionId = windowTo.GetFunctionId(); // Find function container var functionContainer = data.GetWindow(functionId); if (functionContainer == null) { // Function not found return(string.Empty); } // Get function root window var root = data.GetWindow(functionContainer.functionRootId); //var exit = data.GetWindow(functionContainer.functionExitId); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetNamespace(root) + "." + Tpl.GetDerivedClassName(root); var transitionMethods = Tpl.GenerateTransitionMethods(windowTo); transitionMethods = transitionMethods.Replace("\r\n", "\r\n\t") .Replace("\n", "\n\t"); var definition = parameters.Select((x, i) => ME.Utilities.FormatParameter(x) + " " + parameterNames[i]).ToArray(); var call = parameterNames; var description = parameters.Select((x, i) => "/// <param name=\"" + parameterNames[i] + "\">" + parameterNames[i] + " to OnParametersPass</param>").ToArray(); result += part.Replace("{TRANSITION_METHODS}", transitionMethods) .Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{FLOW_FROM_ID}", windowFrom.id.ToString()) .Replace("{FLOW_TO_ID}", windowTo.id.ToString()) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace) .Replace("{PARAMETERS_DEFINITION}", string.Join(", ", definition)) .Replace("{PARAMETERS_CALL}", string.Join(", ", call)) .Replace("{PARAMETERS_DESCRIPTION}", string.Join(System.Environment.NewLine, description)); return(result); }
public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow windowFrom, FD.FlowWindow windowTo) { var file = UnityEngine.Resources.Load("UI.Windows/ABTesting/Templates/TemplateTransitionMethod") as TextAsset; if (file == null) { if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) { UnityEngine.Debug.LogError("ABTesting Template Loading Error: Could not load template 'TemplateTransitionMethod'"); } return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } if (windowTo.IsABTest() == false) { return(string.Empty); } var result = string.Empty; var part = file.text; var methodPatternDefault = "(item, h, wh) => WindowSystemFlow.DoFlow<{0}>(this, item, h, wh, false, null)"; var methods = string.Empty; var methodList = new List <string>(); foreach (var item in windowTo.abTests.items) { var window = FlowSystem.GetWindow(item.attachItem.targetId); if (window.IsFunction() == true) { var winFunc = FlowSystem.GetWindow(window.functionId); if (winFunc != null) { window = FlowSystem.GetWindow(winFunc.functionRootId); } else { window = null; } } if (window == null) { methodList.Add("null"); } else { var classNameWithNamespace = Tpl.GetClassNameWithNamespace(window); methodList.Add(string.Format(methodPatternDefault, classNameWithNamespace)); } } methods = string.Join(", ", methodList.ToArray()); result += part.Replace("{METHOD_NAMES}", methods) .Replace("{FLOW_FROM_ID}", windowFrom.id.ToString()) .Replace("{FLOW_TO_ID}", windowTo.id.ToString()); return(result); }