Пример #1
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();
        }
Пример #2
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();
        }