public TechTree(UpgradeEditor editor, VisualElement root, UpgradeEditorData data) { this.editor = editor; this.data = data; AddToRoot(root, "TechTree"); SetupUI(); }
public Toolbar(VisualElement editorRoot, UpgradeEditorData data) { current = this; this.data = data; var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>($"{UpgradeEditor.DirectoryRoot}/Templates/Toolbar.uxml"); var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>($"{UpgradeEditor.DirectoryRoot}/Templates/Toolbar.uss"); visualTree.CloneTree(editorRoot); var toolbarRoot = editorRoot.Q("Toolbar"); toolbarRoot.styleSheets.Add(styleSheet); items = toolbarRoot.Q("ItemContainer"); modifyIndicator = toolbarRoot.Q("ModifyIndicator"); }
public static void Save(UpgradeEditorData data) { data ??= new UpgradeEditorData(); var json = JsonUtility.ToJson(data, true); try { File.WriteAllText(FilePath, json); } catch (Exception e) { Debug.LogError($"Failed to write to {FilePath}: {e.Message}"); } AssetDatabase.Refresh(); }
private void OnEnable() { root = rootVisualElement; var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>($"{DirectoryRoot}/UpgradeEditorWindow.uxml"); var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>($"{DirectoryRoot}/UpgradeEditorWindow.uss"); visualTree.CloneTree(root); root.styleSheets.Add(styleSheet); data ??= UpgradeEditorData.Load(); toolbar = new Toolbar(root, data); AddPage(new UpgradeTester(this, root)); AddPage(new TechTree(this, root, data)); toolbar.Init(); Undo.undoRedoPerformed += DataFilesUpdated; this.SetAntiAliasing(4); }
private void OnDisable() { UpgradeEditorData.Save(data); Undo.undoRedoPerformed -= DataFilesUpdated; }