Files
XRLib/Assets/Scripts/Simulator/PropertyWindow/ConveyorProperty.cs

64 lines
1.9 KiB
C#
Raw Normal View History

2025-12-24 17:36:01 +09:00
using Simulator.Data;
using System.Collections.Generic;
using UnityEngine;
using UVC.UI.Window.PropertyWindow;
using static Unity.VisualScripting.Member;
public class ConveyorProperty : MonoBehaviour
{
[SerializeField]
private PropertyWindow propertyWindow;
private void Awake()
{
//propertyWindow.PropertyValueChanged += OnPropertyValueChanged;
}
public void SetProertyWindow(ConveyorPath data)
{
Debug.Log(data);
InitConveyorProperty(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);
//UpdateValueStack.Save();
}
public void InitConveyorProperty(ConveyorPath conveyor)
{
List<IPropertyEntry> entries = new List<IPropertyEntry>
{
new StringProperty("name", "이름", conveyor.name)
{
IsReadOnly = true
},
new StringProperty("from_node", "시작 노드", conveyor.from_node)
{
IsReadOnly = true
},
new StringProperty("to_node", "도착 노드", conveyor.to_node)
{
IsReadOnly = true
},
new FloatProperty("speed", "컨베이어 속도", conveyor.speed)
{
IsReadOnly = false
}.Bind(
setter: v => {conveyor.speed = v;SaveChange(conveyor,v,"speed"); }
),
new IntProperty("capacity", "최대 수용 개체 수", conveyor.capacity)
{
IsReadOnly = false
}.Bind(
setter: v => {conveyor.capacity = v;SaveChange(conveyor,v,"capacity"); }
),
};
propertyWindow.LoadMixedProperties(entries);
}
}