コード例 #1
0
        public static WindowLayout GenerateLayout(string filepath, FlowWindowLayoutTemplate layout)
        {
            filepath = filepath.Replace("//", "/");

            WindowLayout instance = null;

            var sourcepath = ADB.GetAssetPath(layout);

            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 <WindowLayout>();

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

            instance = FlowDatabase.ReplaceComponents <FlowWindowLayoutTemplate, WindowLayout>(instance as FlowWindowLayoutTemplate, typeof(WindowLayout));

            FlowDatabase.SaveLayout(instance);

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

            return(instance);
        }
コード例 #2
0
        public static WindowLayout GenerateLayout(FlowWindow window, FlowWindowLayoutTemplate layout)
        {
            WindowLayout instance = null;

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

            var tplName = layout.name;       //"3Buttons";
            var tplData = layout;            //FlowSystem.LoadPrefabTemplate<WindowLayout>(FlowSystem.LAYOUT_FOLDER, tplName);

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

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

            return(instance);
        }