public override IEnumerator OnEvent(int screenId, string group1, string group2, string group3, int weight) { if (screenId >= 0) { var eventName = string.Format("{0}({1})", FlowSystem.GetWindow(screenId).title, screenId); UnityEngine.Analytics.Analytics.CustomEvent(eventName, new Dictionary <string, object>() { { "Group1", group1 }, { "Group2", group2 }, { "Group3", group3 }, { "Weight", weight } }); } yield return(false); }
public List <FlowWindow> GetAttachedWindows() { List <FlowWindow> output = new List <FlowWindow>(); foreach (var attachItem in this.attachItems) { var window = FlowSystem.GetWindow(attachItem.targetId); if (window.IsContainer() == true) { continue; } output.Add(window); } return(output); }
public override void OnFlowSettingsGUI() { if (this.skin == null) this.skin = FlowSystemEditorWindow.defaultSkin; GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel); EditorGUILayout.BeginVertical(EditorStyles.helpBox); { #region NAMESPACE GUILayout.Label("Namespace:"); GUILayout.BeginVertical(GUILayout.Height(30f)); { var namespaceName = EditorGUILayout.TextField(FlowSystem.GetData().namespaceName, this.skin.textField); if (namespaceName != FlowSystem.GetData().namespaceName) { FlowSystem.GetData().namespaceName = namespaceName; FlowSystem.SetDirty(); } } GUILayout.EndHorizontal(); var forceRecompile = EditorGUILayout.ToggleLeft("Force Recompile", FlowSystem.GetData().forceRecompile); if (forceRecompile != FlowSystem.GetData().forceRecompile) { FlowSystem.GetData().forceRecompile = forceRecompile; FlowSystem.SetDirty(); } var minimalScriptsSize = EditorGUILayout.ToggleLeft("Minimal Scripts Size", FlowSystem.GetData().minimalScriptsSize); if (minimalScriptsSize != FlowSystem.GetData().minimalScriptsSize) { FlowSystem.GetData().minimalScriptsSize = minimalScriptsSize; FlowSystem.SetDirty(); } #endregion } EditorGUILayout.EndVertical(); }
public FlowWindow GetFunctionContainer() { // If current window attached to function var attaches = this.attachItems; foreach (var attachItem in attaches) { var win = FlowSystem.GetWindow(attachItem.targetId); if (win.IsContainer() == true && win.IsFunction() == true) { // We are inside a function return(win); } } return(null); }
public static FlowCompilerWizard ShowEditor(System.Action onClose) { var rootWindow = EditorWindow.focusedWindow; var rootX = rootWindow.position.x; var rootY = rootWindow.position.y; var rootWidth = rootWindow.position.width; var rootHeight = rootWindow.position.height; var width = 600f; var height = 389f; FlowCompilerWizard editor = null; FlowCompilerWizard.FocusWindowIfItsOpen <FlowCompilerWizard>(); editor = EditorWindow.focusedWindow as FlowCompilerWizard; if (editor == null) { editor = FlowCompilerWizard.CreateInstance <FlowCompilerWizard>(); var title = "UI.Windows: Flow Compiler Wizard"; #if !UNITY_4 editor.titleContent = new GUIContent(title); #else editor.title = title; #endif editor.ShowUtility(); } editor.position = new Rect(rootX + rootWidth * 0.5f - width * 0.5f, rootY + rootHeight * 0.5f - height * 0.5f, width, height); editor.compileNamespace = FlowSystem.GetData().namespaceName; editor.forceRecompile = FlowSystem.GetData().forceRecompile; editor.partIndex = 0; editor.image = Resources.Load("UI.Windows/FlowCompiler/WizardImage") as Texture; editor.maxSize = new Vector2(width, height); editor.minSize = editor.maxSize; FlowCompilerWizard.compilationSync = new object(); editor.defaultSkin = FlowSystemEditorWindow.defaultSkin; return(editor); }
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 void DrawComponentCurve(FlowWindow from, ref UnityEngine.UI.Windows.Plugins.Flow.FlowWindow.ComponentLink link, FlowWindow to) { if (from.IsEnabled() == false || to.IsEnabled() == false) { return; } var component = from.GetLayoutComponent(link.sourceComponentTag); if (component != null) { var rect = component.tempEditorRect; var start = new Rect(from.rect.x + rect.x, from.rect.y + rect.y, rect.width, rect.height); var end = to.rect; var zOffset = -4f; var offset = Vector2.zero; var startPos = new Vector3(start.center.x + offset.x, start.center.y + offset.y, zOffset); var endPos = new Vector3(end.center.x + offset.x, end.center.y + offset.y, zOffset); var scale = FlowSystem.GetData().flowWindowWithLayoutScaleFactor; var side1 = from.rect.size.x * 0.5f; var side2 = from.rect.size.y * 0.5f; var stopDistance = Mathf.Sqrt(side1 * side1 + side2 * side2); var color = Color.white; if (from.GetContainer() != to.GetContainer()) { color = Color.gray; if (to.GetContainer() != null) { color = to.GetContainer().randomColor; } } var comment = this.DrawComponentCurve(startPos, endPos, color, stopDistance + 50f * scale, link.comment); if (link.comment != comment) { link.comment = comment; FlowSystem.SetDirty(); } } }
public override System.Collections.Generic.IEnumerator <byte> OnScreenTransition(int index, int screenId, int toScreenId, bool popup) { #if UNITY_ANALYTICS_API if (screenId >= 0 && toScreenId >= 0) { UnityEngine.Analytics.Analytics.CustomEvent("Screen Transition", new Dictionary <string, object>() { { "From", string.Format("{0} (ID: {1})", FlowSystem.GetWindow(screenId).title, screenId) }, { "To", string.Format("{0} (ID: {1})", FlowSystem.GetWindow(toScreenId).title, toScreenId) }, { "Path", string.Format("Path Index: {0}", index) }, { "Popup", string.Format("Popup: {0}", popup) }, { "CustomParameter", User.instance.customParameter }, }); } #endif yield return(0); }
public override System.Collections.Generic.IEnumerator <byte> OnEvent(int screenId, string group1, string group2, string group3, int weight) { #if AMPLITUDE_ANALYTICS_API if (screenId >= 0) { var amplitude = Amplitude.Instance; amplitude.logEvent(string.Format("Screen: {0} (ID: {1}) - {2}", FlowSystem.GetWindow(screenId).title, screenId, group1), new Dictionary <string, object>() { { "Group1", group1 }, { "Group2", group2 }, { "Group3", group3 }, { "Weight", weight.ToString() }, { "CustomParameter", User.instance.customParameter }, }); } #endif yield return(0); }
public static string GenerateTransitionMethods(FlowWindow window) { var flowData = FlowSystem.GetData(); var transitions = flowData.windows.Where(w => window.attaches.Contains(w.id) && !w.isDefaultLink && !w.isContainer); var result = string.Empty; foreach (var each in transitions) { var className = each.directory; var classNameWithNamespace = Tpl.GetNamespace(each) + "." + Tpl.GetDerivedClassName(each); //GetBaseClassName( each ); result = result + FlowTemplateGenerator.GenerateWindowLayoutTransitionMethod(className, classNameWithNamespace); } return(result); }
public override void OnFlowToolbarGUI(GUIStyle buttonStyle) { base.OnFlowToolbarGUI(buttonStyle); if (FlowSystem.IsCompileDirty() == true) { var color = GUI.color; GUI.color = Color.red; if (GUILayout.Button("Recompile", buttonStyle) == true) { CompilerSystem.currentNamespace = FlowSystem.GetData().namespaceName; CompilerSystem.Generate(AssetDatabase.GetAssetPath(FlowSystem.GetData()), recompile: true, minimalScriptsSize: false); } GUI.color = color; } }
protected override void OnInspectorGUI(GameDataSettings settings, GameDataServiceItem item, System.Action onReset, GUISkin skin) { var data = FlowSystem.GetData(); if (data == null) { return; } GUILayout.Label("URL:"); var newKey = GUILayout.TextArea(settings.url); if (newKey != settings.url) { settings.url = newKey; UnityEditor.EditorUtility.SetDirty(settings); } UnityEditor.EditorGUI.BeginDisabledGroup(item.processing); if (GUILayout.Button(item.processing == true ? "Loading..." : "Load", skin.button) == true) { if (item.processing == false) { item.processing = true; // Connecting this.OnEditorAuth(item.authKey, (result) => { //UnityEditor.EditorApplication.delayCall += () => { this.StartCoroutine(this.GetData(settings.url, (res) => { if (res.hasError == false) { GameDataSystem.TryToSaveCSV(res.data); } item.processing = false; })); //}; }); } } UnityEditor.EditorGUI.EndDisabledGroup(); }
private void Validate(FD.FlowWindow window) { if (window.abTests == null) { window.abTests = new UnityEngine.UI.Windows.Plugins.ABTesting.ABTestingItems(); EditorUtility.SetDirty(window); FlowSystem.SetDirty(); FlowSystem.Save(); } window.abTests.Validate(window); var sourceWin = FlowSystem.GetData().windowAssets.FirstOrDefault(x => x.AlreadyAttached(window.id)); if (sourceWin != null) { window.abTests.sourceWindowId = sourceWin.id; } }
public override System.Collections.Generic.IEnumerator <byte> OnEvent(int screenId, string group1, string group2, string group3, int weight) { #if DELTADNA_ANALYTICS_API if (screenId >= 0) { var eventName = string.Format("{0}({1})", FlowSystem.GetWindow(screenId).title, screenId); var gameEvent = new GameEvent(eventName) .AddParam("Group1", group1) .AddParam("Group2", group2) .AddParam("Group3", group3) .AddParam("Weight", weight) .AddParam("CustomParameter", User.instance.customParameter); DDNA.Instance.RecordEvent(gameEvent); } #endif yield return(0); }
public static WindowLayout GetLayout(int windowId, out LayoutWindowType screen) { screen = null; var window = FlowSystem.GetWindow(windowId); if (window == null) { return(null); } screen = window.GetScreen() as LayoutWindowType; if (screen == null || screen.layout.layout == null) { return(null); } return(screen.layout.layout); }
public override void OnFlowToolbarGUI(GUIStyle buttonStyle) { base.OnFlowToolbarGUI(buttonStyle); if (FlowSystem.IsCompileDirty() == true) { var color = GUI.color; GUI.color = Color.red; if (GUILayout.Button("Recompile needed", buttonStyle) == true) { Compiler.ShowEditor(null, () => { FlowSystem.SetCompileDirty(state: false); }); } GUI.color = color; } }
public override System.Collections.Generic.IEnumerator <byte> OnScreenTransition(int index, int screenId, int toScreenId, bool popup) { #if DELTADNA_ANALYTICS_API if (screenId >= 0 && toScreenId >= 0) { var eventName = "Screen Transition"; var gameEvent = new GameEvent(eventName) .AddParam("From", string.Format("{0} (ID: {1})", FlowSystem.GetWindow(screenId).title, screenId)) .AddParam("To", string.Format("{0} (ID: {1})", FlowSystem.GetWindow(toScreenId).title, toScreenId)) .AddParam("Path", string.Format("Path Index: {0}", index)) .AddParam("Popup", string.Format("Popup: {0}", popup)) .AddParam("CustomParameter", User.instance.customParameter); DDNA.Instance.RecordEvent(gameEvent); } #endif yield return(0); }
protected override void OnInspectorGUI(ABTestingSettings settings, ABTestingServiceItem item, System.Action onReset, GUISkin skin) { var data = FlowSystem.GetData(); if (data == null) { return; } UnityEditor.EditorGUI.BeginDisabledGroup(item.processing); if (GUILayout.Button(item.processing == true ? "Saving..." : "Save All", skin.button) == true) { if (item.processing == false) { item.processing = true; // Connecting this.OnEditorAuth(item.authKey, (result) => { UnityEditor.EditorApplication.delayCall += () => { Dictionary <int, ABTestingItemsTO> testMap = new Dictionary <int, ABTestingItemsTO>(); foreach (var testWindow in data.GetWindows()) { if (testWindow.IsABTest() == true) { testMap.Add(testWindow.id, testWindow.abTests.GetTO()); // this.Save(testWindow.id, testWindow.abTests.GetTO(), (saveResult) => {}); } } if (testMap.Count != 0) { this.SaveAll(testMap, (saveResult) => {}); } item.processing = false; }; }); } } UnityEditor.EditorGUI.EndDisabledGroup(); }
public override System.Collections.Generic.IEnumerator <byte> OnEvent(int screenId, string group1, string group2, string group3, int weight) { #if UNITY_ANALYTICS_API if (screenId >= 0) { var eventName = string.Format("{0}({1})", FlowSystem.GetWindow(screenId).title, screenId); UnityEngine.Analytics.Analytics.CustomEvent(eventName, new Dictionary <string, object>() { { "Group1", group1 }, { "Group2", group2 }, { "Group3", group3 }, { "Weight", weight }, { "CustomParameter", User.instance.customParameter }, }); } #endif yield return(0); }
public static ABTestingSettings GetSettingsFile() { var data = FlowSystem.GetData(); if (data == null) { return(null); } var modulesPath = data.GetModulesPath(); var settings = ME.EditorUtilities.GetAssetsOfType <ABTestingSettings>(modulesPath, useCache: true); if (settings != null && settings.Length > 0) { return(settings[0]); } return(null); }
public override System.Collections.IEnumerator OnAfterAuth(IService serviceBase) { var service = serviceBase as ABTestingService; yield return(this.StartCoroutine(service.GetDataAll((result) => { if (result.hasError == false) { foreach (var abTest in result.data) { var window = FlowSystem.GetData().GetWindow(abTest.Key); if (window != null) { window.abTests = new ABTestingItems(abTest.Value); } } } }))); yield return(0); }
private static void Generate(string pathToData, bool recompile, bool minimalScriptsSize, System.Func <FD.FlowWindow, bool> predicate) { var filename = Path.GetFileName(pathToData); if (string.IsNullOrEmpty(pathToData) == true) { throw new Exception("`pathToData` is wrong: " + pathToData + ". Filename: " + filename); } var directory = pathToData.Replace(filename, string.Empty); CompilerSystem.currentProject = Path.GetFileNameWithoutExtension(pathToData); CompilerSystem.currentProjectDirectory = directory; var basePath = directory + CompilerSystem.currentProject; IO.CreateDirectory(basePath, string.Empty); IO.CreateDirectory(basePath, FlowDatabase.OTHER_NAME); predicate = predicate ?? delegate { return(true); }; AssetDatabase.StartAssetEditing(); { try { var windows = FlowSystem.GetWindows().Where(w => w.CanCompiled() && predicate(w)); foreach (var each in windows) { var relativePath = IO.GetRelativePath(each, "/"); CompilerSystem.GenerateWindow(basePath + relativePath + "/", each, recompile, minimalScriptsSize); } } catch (Exception e) { Debug.LogException(e); } } AssetDatabase.StopAssetEditing(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); FlowSystem.SetDirty(); FlowSystem.Save(); }
public bool Attach(int id, int index = 0, bool oneWay = false, WindowLayoutElement component = null) { if (this.id == id) { return(false); } var result = false; if (component != null) { if (this.attachedComponents.Any((c) => c.targetWindowId == id && c.sourceComponentTag == component.tag) == false) { this.attachedComponents.Add(new ComponentLink(id, component.tag, component.comment)); // If we attaching component - try to attach window if not oneWay = true; result = true; } else { return(false); } } if (this.AlreadyAttached(id, index) == false) { this.attachItems.Add(new AttachItem(id, index)); if (oneWay == false) { var window = FlowSystem.GetWindow(id); window.Attach(this.id, oneWay: true); } return(true); } return(result); }
public override void OnFlowCreateMenuGUI(string prefix, GenericMenu menu) { if (this.InstallationNeeded() == false) { menu.AddSeparator(prefix); menu.AddItem(new GUIContent(prefix + "AB Testing/Condition"), on: false, func: () => { this.flowEditor.CreateNewItem(() => { var window = FlowSystem.CreateWindow(flags: FD.FlowWindow.Flags.IsSmall | FD.FlowWindow.Flags.CantCompiled | FD.FlowWindow.Flags.IsABTest); window.smallStyleDefault = "flow node 5"; window.smallStyleSelected = "flow node 5 on"; window.title = "A/B Test Condition"; window.rect.width = 150f; window.rect.height = 100f; return(window); }); }); } }
public override System.Collections.Generic.IEnumerator <byte> OnScreenTransition(int index, int screenId, int toScreenId, bool popup) { #if AMPLITUDE_ANALYTICS_API if (screenId >= 0 && toScreenId >= 0) { var amplitude = Amplitude.Instance; amplitude.logEvent( "ScreenTransition", new Dictionary <string, object>() { { "From", FlowSystem.GetWindow(screenId).title }, { "FromID", screenId }, { "To", FlowSystem.GetWindow(toScreenId).title }, { "ToID", toScreenId }, { "CustomParameter", User.instance.customParameter }, } ); } #endif yield return(0); }
public override System.Collections.Generic.IEnumerator <byte> OnTransaction(int screenId, string productId, decimal price, string currency, string receipt, string signature) { #if FACEBOOK_ANALYTICS_API if (FB.IsInitialized == false) { yield break; } if (screenId >= 0) { FB.LogPurchase((float)price, currency, new Dictionary <string, object>() { { "Window", string.Format("{0} (ID: {1}), product: {2}", FlowSystem.GetWindow(screenId).title, screenId, productId) }, { "Receipt", receipt }, { "CustomParameter", User.instance.customParameter }, }); } #endif yield return(0); }
public override void OnFlowToolsMenuGUI(string prefix, GenericMenu menu) { menu.AddSeparator(prefix); #if WEBPLAYER menu.AddDisabledItem(new GUIContent("Compile UI...")); #else menu.AddItem(new GUIContent(prefix + "Compile UI Wizard..."), on: false, func: () => { Compiler.ShowEditor(null, null); }); menu.AddItem(new GUIContent(prefix + "Compile UI"), on: false, func: () => { CompilerSystem.currentNamespace = FlowSystem.GetData().namespaceName; CompilerSystem.Generate(AssetDatabase.GetAssetPath(FlowSystem.GetData()), recompile: true, minimalScriptsSize: false); }); #endif }
public bool Detach(int id, int index = 0, bool oneWay = false, WindowLayoutElement component = null) { if (this.id == id) { return(false); } var result = false; if (component != null) { if (this.attachedComponents.Any((c) => c.targetWindowId == id && c.sourceComponentTag == component.tag) == true) { this.attachedComponents.RemoveAll((c) => c.targetWindowId == id && c.sourceComponentTag == component.tag); result = true; } } else { if (this.AlreadyAttached(id, index) == true) { this.attachItems.RemoveAll((c) => c.targetId == id && c.index == index); this.attachedComponents.RemoveAll((c) => c.targetWindowId == id); result = true; } if (oneWay == false) { var window = FlowSystem.GetWindow(id); if (window != null) { result = window.Detach(this.id, oneWay: true); } } } return(result); }
public override void OnGUI() { if (ABTesting.styles == null) { ABTesting.styles = new Styles(); } if (this.opened == true) { var data = FlowSystem.GetData(); if (data == null) { return; } const float closeSize = 50f; var screenRect = new Rect(0f, 0f, Screen.width, Screen.height); var settingsSize = new Vector2(350f, 500f); var settingsRect = new Rect(screenRect.width * 0.5f - settingsSize.x * 0.5f, screenRect.height * 0.5f - settingsSize.y * 0.5f, settingsSize.x, settingsSize.y).PixelPerfect(); var settingsBackRect = new Rect(settingsRect.x - MARGIN, settingsRect.y - MARGIN, settingsRect.width + MARGIN * 2f, settingsRect.height + MARGIN * 2f).PixelPerfect(); var rectCloseButton = new Rect(settingsRect.x + settingsRect.width, settingsRect.y - closeSize * 0.5f, closeSize, closeSize).PixelPerfect(); GUI.Box(screenRect, string.Empty, ABTesting.styles.backLock); GUI.Box(settingsBackRect, string.Empty, ABTesting.styles.dropShadow); GUI.Box(settingsBackRect, string.Empty, ABTesting.styles.contentScreen); GUI.Box(settingsRect, string.Empty, ABTesting.styles.layoutBack); GUILayout.BeginArea(settingsRect.PixelPerfect()); this.tabs.selectedItem = this.selectedItem; this.tabs.OnGUI(); GUILayout.EndArea(); if (GUI.Button(rectCloseButton, string.Empty, ABTesting.styles.closeButton) == true) { this.flowEditor.SetEnabled(); this.opened = false; } } }
public override void OnFlowSettingsGUI() { GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel); GUILayout.Label("Functions", EditorStyles.boldLabel); var data = FlowSystem.GetData(); if (data == null) { return; } this.functions.Clear(); foreach (var window in data.windows) { if (window.IsFunction() == true && window.IsContainer() == true) { this.functions.Add(window); } } if (this.functions.Count == 0) { var style = new GUIStyle(GUI.skin.label); style.wordWrap = true; GUILayout.Label("No functions ware found in the current project. Add new one by clicking on `Create->Functions` menu.", style); } else { foreach (var function in this.functions) { if (GUILayoutExt.LargeButton(function.title, 20f, FlowSystemEditorWindow.SETTINGS_WIDTH) == true) { this.flowEditor.SetCenterTo(function); } } } }