Mercurial > hg > Members > kazuma > JungleforUnity
view Assets/Application/Scripts/SaveData.cs @ 10:3fefb9f9025d
put Attribute class.
author | Kazuma Takeda |
---|---|
date | Fri, 20 Jan 2017 07:30:26 +0900 |
parents | 599bd8ddb72b |
children |
line wrap: on
line source
using UnityEngine; using System.Collections; using JungleDB; public class SaveData : MonoBehaviour { public static SaveData Instance; private Jungle mainScene ; private JungleTree mainTree; private JungleTreeEditor TreeEditor; private TreeNode node; // private NodePath root; // Use this for initialization void Awake () { if (Instance == null) { Instance = this; } } private void Start () { JungleStart (); // root = new DefaultNodePath (); // InterfaceTraverser t = new InterfaceTraverser (root, false); } private void JungleStart () { Debug.Log ("[Jungle] Start ..."); mainScene = new DefaultJungle(null, "Main", new DefaultTreeEditor(new DefaultTraverser())); } public void CreateTree (string name) { mainScene.createNewTree (name); mainTree = mainScene.getTreeByName (name); Debug.Log ("[Jungle] Create " + name + " Tree"); EditorMode (); } public void EditorMode () { TreeEditor = mainTree.getTreeEditor (); Debug.Log ("[Jungle] Editor Mode" + TreeEditor.ToString()); } public void createTree (int pos, NodePath path, string key, byte[] value) { Either<Error, JungleTreeEditor> either = TreeEditor.addNewChildAt(path, pos); if (either.isA ()) { Debug.LogError ("[Error]" + either.a ()); } else { TreeEditor = either.b (); Either<Error, JungleTreeEditor> eitherput = TreeEditor.putAttribute (path.add(pos), key, value); if (eitherput.isA ()) { Debug.LogError ("[Error]" + eitherput.a()); } else { Debug.Log ("[Success]"); TreeEditor = eitherput.b (); } } } // public void PutAttribute (NodePath path, string key, byte[] value) { // Either<Error, JungleTreeEditor> either = TreeEditor.putAttribute (path, key, value); // if (either.isA ()) { // Debug.LogError ("[Error]" + either.a()); // } else { // Debug.Log ("[Success]"); // either.b (); // } // } public void GetAttribute (NodePath path, string key) { Either<Error, TreeNode> either = mainTree.getNodeOfPath (path); if (either.isA ()) { Debug.LogError ("[Error]"); } else { node = either.b (); print (key); object target = node.getAttributes ().get (key); print (target); } } public void Push() { Either<Error, JungleTreeEditor> r = TreeEditor.commit(); if (r.isA ()) { Debug.LogError ("[Error]"); } else { Debug.Log ("[Success]"); TreeEditor = r.b (); } } }