Files
XRLib/Assets/Scripts/Simulator/PropertyWindow/NodeProperty.cs
2026-01-16 11:36:54 +09:00

55 lines
1.6 KiB
C#

using Simulator.Data;
using System.Collections.Generic;
using UnityEngine;
using UVC.UI.Window.PropertyWindow;
public class NodeProperty : MonoBehaviour
{
[SerializeField]
private PropertyWindow propertyWindow;
public void SetProertyWindow(ConveyorNode data)
{
Debug.Log(data);
InitNodeProperty(data);
}
void SaveChange(object source, object value, string name)
{
var path = PathIndexer.GetNodePath(source);
Patch updateData = new Patch();
updateData.value = value;
UpdateValueStack.AddPatch($"{path}.{name}", value);
}
public void InitNodeProperty(ConveyorNode node)
{
List<IPropertyEntry> entries = new List<IPropertyEntry>
{
new StringProperty("name", "이름", node.name)
{
IsReadOnly=true
},
new StringProperty("label", "라벨", node.label)
{
IsReadOnly=false
}.Bind(
setter: v => {node.label = v;SaveChange(node,v,"label"); }
),
new ListProperty("type","타입",new List<string> { "start","junction","endpoint"},node.node_type)
{
IsReadOnly=false
}.Bind(
setter: v => {node.node_type=v; SaveChange(node,v,"node_type"); }
),
new IntProperty("capacity", "용량", node.capacity)
{
IsReadOnly=false
}.Bind(
setter: v => {node.capacity = v;SaveChange(node,v,"capacity"); }
),
};
propertyWindow.LoadMixedProperties(entries);
}
}