コード例 #1
0
        /*
         * public void OnEnable() {
         *
         *      var dataPath = AssetDatabase.GetAssetPath(this.target);
         *      var directory = System.IO.Path.GetDirectoryName(dataPath);
         *
         * }*/

        public override void OnInspectorGUI()
        {
            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);
                }
            }

            foreach (var function in this.functions)
            {
                GUILayout.Button(function.title);
            }
        }
コード例 #2
0
        public static void Send(LayoutTag tag, WindowBase window, WindowComponent component, Vector2 localNormalizedPoint)
        {
            var flowWindow = Flow.FlowSystem.GetWindow(window);

            if (flowWindow == null)
            {
                Debug.LogWarningFormat("[ Heatmap ] FlowWindow not found. Source {0} used ({1}).", window, tag);
                return;
            }

            // Offline
                        #if UNITY_EDITOR
            var modulesPath = FlowSystem.GetData().GetModulesPath();
            var settings    = ME.EditorUtilities.GetAssetsOfType <HeatmapSettings>(modulesPath, useCache: false).FirstOrDefault();
                        #else
            HeatmapSettings settings = null;
                        #endif
            if (settings == null)
            {
                return;
            }

            var data = settings.data.Get(flowWindow);
            data.AddPoint(localNormalizedPoint, new Vector2Int(Screen.width, Screen.height), flowWindow.id, tag, component);
        }
コード例 #3
0
        public void OnFlowSettingsGUI()
        {
            #region NAMESPACE

            GUILayout.Label("Flow Compiler", EditorStyles.boldLabel);

            EditorGUIUtility.labelWidth = 70f;

            var namespaceName = EditorGUILayout.TextField("Namespace: ", FlowSystem.GetData().namespaceName);
            if (namespaceName != FlowSystem.GetData().namespaceName)
            {
                FlowSystem.GetData().namespaceName = namespaceName;
                FlowSystem.SetDirty();
            }

            EditorGUIUtility.LookLikeControls();

            var forceRecompile = GUILayout.Toggle(FlowSystem.GetData().forceRecompile, "Force Recompile");
            if (forceRecompile != FlowSystem.GetData().forceRecompile)
            {
                FlowSystem.GetData().forceRecompile = forceRecompile;
                FlowSystem.SetDirty();
            }

            #endregion
        }
コード例 #4
0
        public override void OnFlowSettingsGUI()
        {
            GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel);

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                #region NAMESPACE
                EditorGUIUtility.labelWidth = 70f;

                var namespaceName = EditorGUILayout.TextField("Namespace: ", FlowSystem.GetData().namespaceName);
                if (namespaceName != FlowSystem.GetData().namespaceName)
                {
                    FlowSystem.GetData().namespaceName = namespaceName;
                    FlowSystem.SetDirty();
                }

                EditorGUIUtility.LookLikeControls();

                var forceRecompile = GUILayout.Toggle(FlowSystem.GetData().forceRecompile, "Force Recompile");
                if (forceRecompile != FlowSystem.GetData().forceRecompile)
                {
                    FlowSystem.GetData().forceRecompile = forceRecompile;
                    FlowSystem.SetDirty();
                }

                #endregion
            }
            EditorGUILayout.EndVertical();
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public void DrawInspectorGUI(ScriptableObject settings, ServiceItem item, System.Action onReset, GUISkin skin)
        {
            if (FlowSystem.GetData() == null)
            {
                GUILayout.Label("No Data");
                return;
            }

            ++UnityEditor.EditorGUI.indentLevel;
            try {
                if (this.GetAuthPermissions() != AuthKeyPermissions.None && FlowSystem.GetData().IsValidAuthKey() == false)
                {
                    UnityEditor.EditorGUILayout.HelpBox("Authorization Key is not valid.", UnityEditor.MessageType.Error);
                    FlowSystem.DrawEditorGetKeyButton(skin);
                }
                else if (FlowSystem.GetData().IsValidAuthKey(this.GetAuthPermissions()) == false)
                {
                    UnityEditor.EditorGUILayout.HelpBox("You have no permission to use this service.", UnityEditor.MessageType.Warning);
                    FlowSystem.DrawEditorGetKeyButton(skin);
                }
                else
                {
                    this.DoInspectorGUI(settings, item, onReset, skin);
                }
            } catch (UnityException e) {
                Debug.LogException(e);
            }
            --UnityEditor.EditorGUI.indentLevel;
        }
コード例 #7
0
        public override Vector2 OnFlowDrawNodeCurveOffset(UnityEngine.UI.Windows.AttachItem attachItem, FD.FlowWindow window, FD.FlowWindow toWindow, bool doubleSide)
        {
            var offset = Vector2.zero;

            var data = FlowSystem.GetData();

            if (data == null)
            {
                return(offset);
            }

            Vector2 dotOffset = new Vector2(5f, 0f);

            var flag = window.IsABTest();

            if (flag == true)
            {
                this.Validate(window);

                for (int i = 0; i < window.abTests.Count(); ++i)
                {
                    var abTest = window.abTests.items[i];
                    if (abTest.attachItem.targetId == attachItem.targetId && abTest.attachItem.index == attachItem.index)
                    {
                        var editorRect = abTest.editorRect;
                        var delta      = editorRect.center - window.rect.size * 0.5f + dotOffset;

                        offset = delta;
                    }
                }
            }

            return(offset);
        }
コード例 #8
0
        public static CompilerWizard ShowEditor(System.Action onClose, System.Action onComplete)
        {
            var rootX      = 0f;
            var rootY      = 0f;
            var rootWidth  = 1000f;
            var rootHeight = 1000f;

            var rootWindow = EditorWindow.focusedWindow;

            if (rootWindow != null)
            {
                rootX      = rootWindow.position.x;
                rootY      = rootWindow.position.y;
                rootWidth  = rootWindow.position.width;
                rootHeight = rootWindow.position.height;
            }

            var width  = 600f;
            var height = 389f;

            CompilerWizard editor = null;

            CompilerWizard.FocusWindowIfItsOpen <CompilerWizard>();
            editor = EditorWindow.focusedWindow as CompilerWizard;

            if (editor == null)
            {
                editor = CompilerWizard.CreateInstance <CompilerWizard>();
                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.minimalScriptsSize = FlowSystem.GetData().minimalScriptsSize;
            editor.partIndex          = 0;

            editor.image = Resources.Load("UI.Windows/FlowCompiler/WizardImage") as Texture;

            editor.maxSize = new Vector2(width, height);
            editor.minSize = editor.maxSize;

            editor.onClose    = onClose;
            editor.onComplete = onComplete;

            CompilerWizard.compilationSync = new object();

            editor.defaultSkin = FlowSystemEditorWindow.defaultSkin;

            return(editor);
        }
コード例 #9
0
        public IEnumerator Init(System.Action onComplete = null)
        {
            if (this.logEnabled == true)
            {
                WindowSystemLogger.Log(this, "Initializing...");
            }

            if (FlowSystem.GetData().IsValidAuthKey(this.GetAuthPermission()) == false)
            {
                if (this.logEnabled == true)
                {
                    WindowSystemLogger.Warning(this, "Permission denied");
                }
                yield break;
            }

            var settings = this.settings;

            if (settings == null)
            {
                yield break;
            }

            this.OnInitialized();

            if (this.services != null)
            {
                var items = settings.GetItems();

                foreach (var service in this.services)
                {
                    for (int i = 0; i < items.Count; ++i)
                    {
                        var item = items [i];
                        if (item.serviceName == service.GetServiceName())
                        {
                            service.isActive = item.enabled;
                            if (service.isActive == true)
                            {
                                yield return(this.StartCoroutine(service.Auth(service.GetAuthKey(item))));

                                yield return(this.StartCoroutine(this.OnAfterAuth(service)));
                            }
                        }
                    }
                }
            }

            if (this.logEnabled == true)
            {
                WindowSystemLogger.Log(this, "Initialized");
            }

            if (onComplete != null)
            {
                onComplete.Invoke();
            }
        }
コード例 #10
0
        public bool InstallModule <T>(string name, string settingsName) where T : UnityEngine.UI.Windows.Plugins.Services.ServiceSettings
        {
            var moduleName = name;
            var settings   = new[] {
                new { type = typeof(T), name = settingsName, directory = "" }
            };

            var data = FlowSystem.GetData();

            if (data == null)
            {
                return(false);
            }

            // Check directories
            var dataPath    = AssetDatabase.GetAssetPath(data);
            var directory   = Path.GetDirectoryName(dataPath);
            var projectName = data.name;

            var modulesPath = Path.Combine(directory, projectName + ".Modules");
            var modulePath  = Path.Combine(modulesPath, moduleName);

            if (Directory.Exists(modulesPath) == false)
            {
                Directory.CreateDirectory(modulesPath);
            }
            if (Directory.Exists(modulePath) == false)
            {
                Directory.CreateDirectory(modulePath);
            }

            foreach (var file in settings)
            {
                var path = Path.Combine(modulePath, file.directory);
                if (Directory.Exists(path) == false)
                {
                    Directory.CreateDirectory(path);
                }

                if (File.Exists(path + "/" + file.name + ".asset") == false)
                {
                    var instance = ME.EditorUtilities.CreateAsset(file.type, path, file.name) as T;

                    if (instance != null)
                    {
                        EditorUtility.SetDirty(instance);
                    }
                }
            }

            ME.EditorUtilities.ResetCache <T>(modulesPath);

            AssetDatabase.Refresh();

            return(true);
        }
コード例 #11
0
        public void Validate(FD.FlowWindow window)
        {
                        #if UNITY_EDITOR
            if (this.items == null)
            {
                this.items = new List <ABTestingItem>();
                EditorUtility.SetDirty(window);
                FlowSystem.SetDirty();
                FlowSystem.Save();
            }

            if (this.Count() < 2)
            {
                for (int i = this.Count(); i < 2; ++i)
                {
                    this.AddNew();
                }
                EditorUtility.SetDirty(window);
                FlowSystem.SetDirty();
                FlowSystem.Save();
            }

            var data = FlowSystem.GetData();
            if (data != null)
            {
                var attaches = window.attachItems.ToArray();
                for (int i = 0; i < attaches.Count(); ++i)
                {
                    var toId    = attaches[i].targetId;
                    var toIndex = attaches[i].index;

                    if (this.items.FirstOrDefault(x => x.attachItem.targetId == toId && x.attachItem.index == toIndex) == null)
                    {
                        var fromId = window.id;
                        if (FlowSystem.GetWindow(toId).IsContainer() == false)
                        {
                            EditorApplication.delayCall += () => {
                                data.Detach(fromId, toIndex, toId, oneWay: false);
                            };
                        }
                    }
                }

                for (int i = 0; i < this.Count(); ++i)
                {
                    var item = this.items[i];

                    if (data.AlreadyAttached(window.id, item.attachItem.index, item.attachItem.targetId) == false)
                    {
                        // no attachment - remove it
                        item.Detach();
                    }
                }
            }
                        #endif
        }
コード例 #12
0
        private bool Install_INTERNAL()
        {
            var moduleName = "Ads";
            var settings   = new[] {
                new { type = typeof(AdsSettings), name = "AdsSettings", directory = "" }
            };

            var data = FlowSystem.GetData();

            if (data == null)
            {
                return(false);
            }

            // Check directories
            var dataPath    = AssetDatabase.GetAssetPath(data);
            var directory   = Path.GetDirectoryName(dataPath);
            var projectName = data.name;

            var modulesPath = Path.Combine(directory, projectName + ".Modules");
            var modulePath  = Path.Combine(modulesPath, moduleName);

            if (Directory.Exists(modulesPath) == false)
            {
                Directory.CreateDirectory(modulesPath);
            }
            if (Directory.Exists(modulePath) == false)
            {
                Directory.CreateDirectory(modulePath);
            }

            foreach (var file in settings)
            {
                var path = Path.Combine(modulePath, file.directory);
                if (Directory.Exists(path) == false)
                {
                    Directory.CreateDirectory(path);
                }

                if (File.Exists(path + "/" + file.name + ".asset") == false)
                {
                    var instance = ME.EditorUtilities.CreateAsset(file.type, path, file.name) as AdsSettings;

                    if (instance != null)
                    {
                        EditorUtility.SetDirty(instance);
                    }
                }
            }

            ME.EditorUtilities.ResetCache <AdsSettings>(modulesPath);

            AssetDatabase.Refresh();

            return(false);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        public static void Run(FlowData data)
        {
            UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", data.version, VersionInfo.BUNDLE_VERSION), 0f);
            var type = data.GetType();

            while (data.version < VersionInfo.BUNDLE_VERSION)
            {
                var nextVersion = data.version + 1;

                try {
                    // Try to find upgrade method
                    var methodName = "UpgradeTo" + nextVersion.ToSmallWithoutTypeString();
                    var methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public);
                    if (methodInfo != null)
                    {
                        var result = (bool)methodInfo.Invoke(data, null);
                        if (result == true)
                        {
                            // Need to recompile
                            var prevData = FlowSystem.GetData();
                            FlowSystem.SetData(data);
                            UnityEngine.UI.Windows.Plugins.FlowCompiler.CompilerSystem.currentNamespace = data.namespaceName;
                            var path = UnityEditor.AssetDatabase.GetAssetPath(data);
                            UnityEngine.UI.Windows.Plugins.FlowCompiler.CompilerSystem.Generate(path, recompile: true);
                            FlowSystem.SetData(prevData);
                        }

                        if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                        {
                            UnityEngine.Debug.Log("[UPGRADE] Invoked: `" + methodName + "`, version " + nextVersion);
                        }
                    }
                    else
                    {
                        if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                        {
                            UnityEngine.Debug.Log("[UPGRADE] Method `" + methodName + "` was not found: version " + nextVersion + " skipped");
                        }
                    }

                    UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", data.version, nextVersion), 0.5f);
                } catch (UnityException) {
                } finally {
                    UnityEditor.EditorUtility.ClearProgressBar();
                }

                data.version = nextVersion;
                UnityEditor.EditorUtility.SetDirty(data);
            }

            UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", data.version, VersionInfo.BUNDLE_VERSION), 1f);
            UnityEditor.EditorUtility.ClearProgressBar();
        }
コード例 #15
0
        public static string GenerateTransitionMethods(FlowWindow window)
        {
            var flowData = FlowSystem.GetData();

            var transitions = flowData.windows.Where(w => window.attachItems.Any((item) => item.targetId == w.id) && w.CanCompiled() && !w.IsContainer());

            var result = string.Empty;

            foreach (var each in transitions)
            {
                var className = each.directory;
                var classNameWithNamespace = Tpl.GetNamespace(each) + "." + Tpl.GetDerivedClassName(each);

                result += FlowTemplateGenerator.GenerateWindowLayoutTransitionMethod(window, each, className, classNameWithNamespace);
            }

            // Make FlowDefault() method if exists
            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)
                {
                    result += FlowTemplateGenerator.GenerateWindowLayoutTransitionMethodDefault();
                }

                result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionAttachedGeneration(window, attachedWindow, everyPlatformHasUniqueName);
            }

            // Run addons transition logic
            result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionGeneration(window);

            return(result);
        }
コード例 #16
0
        protected override void OnInspectorGUI(GameDataSettings settings, GameDataServiceItem item, System.Action onReset, GUISkin skin)
        {
            if (settings == null)
            {
                return;
            }

            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();
        }
コード例 #17
0
 public virtual string GetAuthKey(ServiceItem item)
 {
                 #if UNITY_EDITOR
     if (Application.isPlaying == false)
     {
         return(FlowSystem.GetData().GetAuthKeyEditor());
     }
     else
     {
         return(FlowSystem.GetData().GetAuthKeyBuild());
     }
                 #else
     return(FlowSystem.GetData().GetAuthKeyBuild());
                 #endif
 }
コード例 #18
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
        }
コード例 #19
0
		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();

		}
コード例 #20
0
        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);
        }
コード例 #21
0
        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();
                }
            }
        }
コード例 #22
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);
        }
コード例 #23
0
        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;
            }
        }
コード例 #24
0
        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;
            }
        }
コード例 #25
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();
        }
コード例 #26
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);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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>();
                editor.title = "Flow Compiler Wizard";
                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);
        }
コード例 #29
0
        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);
                    }
                }
            }
        }
コード例 #30
0
        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;
                }
            }
        }