public static WindowBase GenerateScreen(string filepath, string className, FlowLayoutWindowTypeTemplate template)
        {
            WindowBase instance = null;

            filepath = filepath.Replace("//", "/");

            var sourcepath = ADB.GetAssetPath(template);

            filepath = AssetDatabase.GenerateUniqueAssetPath(filepath);

            System.IO.File.Copy(sourcepath, filepath, true);
            ADB.Refresh();

            var source = ADB.LoadAssetAtPath(filepath, typeof(GameObject)) as GameObject;
            var prefab = source.GetComponent <WindowBase>();

            instance = UnityEditor.PrefabUtility.InstantiatePrefab(prefab) as WindowBase;

            var type = WindowUtilities.GetTypeFromAllAssemblies(className);

            instance = FlowDatabase.ReplaceComponents <FlowLayoutWindowTypeTemplate, WindowBase>(instance as FlowLayoutWindowTypeTemplate, type);

            FlowDatabase.SaveScreen(instance);

            GameObject.DestroyImmediate(instance.gameObject);
            instance = (ADB.LoadAssetAtPath(filepath, typeof(GameObject)) as GameObject).GetComponent <WindowBase>();

            return(instance);
        }
        public static WindowBase GenerateScreen(FlowWindow window, FlowLayoutWindowTypeTemplate template)
        {
            WindowBase instance = null;

            if (window.compiled == false)
            {
                return(instance);
            }

            var tplName = template.name;       //"Layout";
            var tplData = template;            //FlowSystem.LoadPrefabTemplate<WindowBase>(FlowSystem.SCREENS_FOLDER, tplName);

            if (tplData != null)
            {
                var filepath = window.compiledDirectory + "/" + FlowDatabase.SCREENS_FOLDER + "/" + tplName + "Screen.prefab";

                instance = FlowDatabase.GenerateScreen(filepath, window.compiledDerivedClassName, tplData);
            }
            else
            {
                Debug.LogError("Template Loading Error: " + tplName);
            }

            return(instance);
        }