Ejemplo n.º 1
0
        private static void Generate(string pathToData, bool recompile, System.Func <FlowWindow, bool> predicate)
        {
            var filename  = Path.GetFileName(pathToData);
            var directory = pathToData.Replace(filename, string.Empty);

            FlowCompilerSystem.currentProject          = Path.GetFileNameWithoutExtension(pathToData);
            FlowCompilerSystem.currentProjectDirectory = directory;

            var basePath = directory + FlowCompilerSystem.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.isDefaultLink && predicate(w));

                    foreach (var each in windows)
                    {
                        var relativePath = IO.GetRelativePath(each, "/");
                        FlowCompilerSystem.GenerateWindow(basePath + relativePath + "/", each, recompile);
                    }
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            }
            AssetDatabase.StopAssetEditing();
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            FlowSystem.SetDirty();
            FlowSystem.Save();
        }
Ejemplo n.º 2
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
        }
Ejemplo n.º 3
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(string.Format("`pathToData` is wrong: {0}. Filename: {1}", pathToData, 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.GetContainersAndWindows().Where(w => w.CanCompiled() && predicate(w));
                    //var windows = FlowSystem.GetContainers().Where(w => w.CanCompiled() && predicate(w));
                    foreach (var each in windows)
                    {
                        var relativePath = IO.GetRelativePath(each, "/");
                        CompilerSystem.GenerateWindow(string.Format("{0}{1}/", basePath, relativePath), each, recompile, minimalScriptsSize);
                    }

                    // Generate Base Files
                    var newInfo              = new Tpl.Info(CompilerSystem.currentNamespace, "Container", "ContainerBase", "LayoutWindowType", basePath);
                    var baseClassTemplate    = TemplateGenerator.GenerateWindowLayoutContainerBaseClass(newInfo.baseClassname, newInfo.baseNamespace, newInfo.containerClassName);
                    var derivedClassTemplate = TemplateGenerator.GenerateWindowLayoutDerivedClass(newInfo.classname, newInfo.baseClassname, newInfo.baseNamespace);

                    IO.CreateFile(basePath, newInfo.baseClassnameFile, baseClassTemplate, rewrite: true);
                    IO.CreateFile(basePath, newInfo.classnameFile, derivedClassTemplate, rewrite: false);
                } catch (Exception e) {
                    if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                    {
                        UnityEngine.Debug.LogException(e);
                    }
                }
            }
            AssetDatabase.StopAssetEditing();
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            FlowSystem.SetDirty();
            FlowSystem.Save();
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
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();
        }