Ejemplo n.º 1
0
 public TechTree(UpgradeEditor editor, VisualElement root, UpgradeEditorData data)
 {
     this.editor = editor;
     this.data   = data;
     AddToRoot(root, "TechTree");
     SetupUI();
 }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 private void OnDisable()
 {
     UpgradeEditorData.Save(data);
     Undo.undoRedoPerformed -= DataFilesUpdated;
 }