fix: little work around on saving data

main
taoria 3 years ago
parent c7e68748f6
commit 675589de2b
  1. 84
      Scenes/SampleScene.unity
  2. 3
      TNodeCore/Components.meta
  3. 46
      TNodeCore/Components/RuntimeDataSaver.cs
  4. 3
      TNodeCore/Components/RuntimeDataSaver.cs.meta
  5. 12
      TNodeCore/Components/RuntimeGraph.cs
  6. 0
      TNodeCore/Components/RuntimeGraph.cs.meta
  7. 1
      TNodeCore/Editor/NodeGraphView/IBaseDataGraphView.cs
  8. 1
      TNodeGraphViewImpl/Editor/NodeGraphView/DataGraphView.cs

@ -625,90 +625,6 @@ Transform:
m_Father: {fileID: 507038910}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1648230696
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1648230698}
- component: {fileID: 1648230697}
m_Layer: 0
m_Name: Square
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &1648230697
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1648230696}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1648230698
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1648230696}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1701140682
GameObject:
m_ObjectHideFlags: 0

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 732046b8ee564bd5be9be4ce908a011b
timeCreated: 1658710679

@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace TNodeCore.Components{
public class RuntimeDataSaver:MonoBehaviour{
public string saveName;
public string saveExtension = "tng";
public Dictionary<string, object> savedData = new();
public void Load(){
string path = Application.persistentDataPath + "/"+ saveName + "." + saveExtension;
if(!File.Exists(path)){
Debug.LogWarning("File not found: " + path);
return;
}
string json = File.ReadAllText(path);
savedData = JsonUtility.FromJson<Dictionary<string, object>>(json);
}
public void Save(){
string path = Application.persistentDataPath + "/" + saveName + "." + saveExtension;
string json = JsonUtility.ToJson(savedData);
File.WriteAllText(path, json);
}
public void Write(string id,object o){
if (savedData.ContainsKey(id)){
savedData[id] = o;
}
else{
savedData.Add(id,o);
}
}
public object Read(string id){
return savedData.ContainsKey(id) ? savedData[id] : null;
}
public bool Has(string id){
return savedData.ContainsKey(id);
}
public void Remove(string id){
if (savedData.ContainsKey(id)){
savedData.Remove(id);
}
}
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c4a377b7b5444bf08d3cf68b5a54daf5
timeCreated: 1658710701

@ -2,14 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using TNodeCore.Models;
using TNodeCore.Runtime;
using UnityEngine;
namespace TNodeCore.Runtime{
namespace TNodeCore.Components{
public class RuntimeGraph:MonoBehaviour{
public GraphData graphData;
public List<SceneNodeData> sceneNodes;
public readonly Dictionary<string, RuntimeNode> RuntimeNodes = new Dictionary<string, RuntimeNode>();
private GraphTool _graphTool;
private class GraphTool{
@ -182,6 +183,13 @@ namespace TNodeCore.Runtime{
RuntimeNodes.Clear();
_build = false;
}
public void Start(){
Build();
}
public virtual void RuntimeExecute(){
_graphTool.DirectlyTraversal();
}
}

@ -1,4 +1,5 @@
using System;
using TNodeCore.Components;
using TNodeCore.Models;
using TNodeCore.Runtime;
using UnityEngine;

@ -4,6 +4,7 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using TNode.Editor.Inspector;
using TNodeCore.Components;
using TNodeCore.Editor.Blackboard;
using TNodeCore.Editor.EditorPersistence;
using TNodeCore.Editor.NodeGraphView;

Loading…
Cancel
Save