64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
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);
|
|
}
|
|
}
|