public static WindowLayoutElement AddLayoutElementComponent(string name, Transform root, int siblingIndex) { var go = new GameObject(name); go.transform.SetParent(root); go.transform.localScale = Vector3.one; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.AddComponent <RectTransform>(); go.transform.SetSiblingIndex(siblingIndex); var layoutElement = go.AddComponent <WindowLayoutElement>(); layoutElement.comment = "NEW LAYOUT ELEMENT"; var canvas = go.AddComponent <CanvasGroup>(); canvas.alpha = 1f; canvas.blocksRaycasts = true; canvas.interactable = true; canvas.ignoreParentGroups = false; layoutElement.canvas = canvas; //FlowSceneView.GetItem().SetLayoutDirty(); FlowDatabase.SaveLayout(layoutElement.transform.root.GetComponent <WindowLayout>()); return(layoutElement); }
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); }
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); }
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); }
public static void RemoveLayoutComponent(Transform element) { var root = element.root; GameObject.DestroyImmediate(element.gameObject); FlowDatabase.SaveLayout(root.GetComponent <WindowLayout>()); }