// Use this for initialization void Start() { Property p = new Property(50f); p.AddTrace("weapon1", 10f); p.AddTrace("weapon1", 0.3f, DeltaMode.Percentage); Debug.Log(FormatFunc.ObjectToJson(p)); Property p1 = FormatFunc.JsonToObject <Property>(FormatFunc.ObjectToJson(p)); Debug.Log(FormatFunc.ObjectToJson(p1)); Debug.Log(p1.value); }
void Update() { if (Input.GetKeyDown(KeyCode.S)) { //线程调用测试 HoxisProtocol proto = new HoxisProtocol { type = ProtocolType.Synchronization, receiver = new HoxisProtocolReceiver { type = ReceiverType.Cluster, uid = 0, }, sender = new HoxisProtocolSender { aid = new HoxisAgentID("soldier", 10), loopback = true, }, action = new HoxisProtocolAction { method = "shoot", args = new HoxisProtocolArgs { values = new Dictionary <string, string> { { "val", "15" }, { "src", "weapon" }, } }, }, desc = "thread test", }; string json = FormatFunc.ObjectToJson(proto); byte[] data = FormatFunc.StringToBytes(json); Thread t = new Thread(() => { //Thread.Sleep(1000); HoxisDirector.Ins.ProtocolEntry(data); }); t.Start(); } }