Files
XRLib/Assets/Scripts/Simulator/UpdateValueStack.cs

56 lines
1.3 KiB
C#
Raw Permalink Normal View History

2026-02-25 16:30:12 +09:00
using Cysharp.Threading.Tasks;
2025-12-17 11:42:57 +09:00
using Newtonsoft.Json;
2025-12-24 17:36:01 +09:00
using Simulator.Config;
using Simulator.Data;
2025-12-17 11:42:57 +09:00
using System;
using System.Collections.Generic;
using UnityEngine;
2025-12-24 17:36:01 +09:00
using UVC.Network;
2025-12-17 11:42:57 +09:00
2026-02-25 16:30:12 +09:00
namespace Simulator.Data
{
2025-12-17 11:42:57 +09:00
[Serializable]
public class Patches
{
public List<Patch> patches=new List<Patch>();
}
[Serializable]
public class Patch
{
public string path;
public object value;
}
public class UpdateValueStack : MonoBehaviour
{
static Dictionary<string,object> patches=new Dictionary<string,object>();
public static void AddPatch(string path, object value)
{
if (patches.ContainsKey(path))
{
patches[path] = value;
}
else
{
patches.Add(path, value);
}
}
2026-02-25 16:30:12 +09:00
public static async UniTask Save()
2025-12-17 11:42:57 +09:00
{
Patches change = new Patches();
foreach (var patch in patches)
{
Patch pa = new Patch();
pa.path = patch.Key;
pa.value = patch.Value;
change.patches.Add(pa);
}
var data=JsonConvert.SerializeObject(change);
Debug.Log(data);
2025-12-24 17:36:01 +09:00
var request = await HttpRequester.Request_<Totaljson>($"{Constants.HTTP_DOMAIN}/simulation/logics/{SimulationConfig.logicId}/data", data, methodString:"patch", null,true);
Debug.Log(request.code);
2025-12-17 11:42:57 +09:00
patches.Clear();
}
}
2026-02-25 16:30:12 +09:00
}