上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

79 lines
2.6 KiB

using UnityEngine;
using UnityEngine.UI;
using UniRx;
using AX.ImageViewer;
public class FireElevatorAttributePanel : UIView<FireElevator,FireElevatorReactive>
{
//编号
public Text NumberText;
public InputField NumberInput;
//载重
public Text LoadText;
public InputField LoadInput;
//通往层数
public Text LayerText;
public InputField LayerInput;
//保存按钮
public Button SaveButton;
public override void Awake()
{
base.Awake();
#region DataSource Bind
//编号
DataSource.Number.SubscribeToText(NumberText).AddTo(gameObject);
DataSource.Number.SubscribeToText(NumberInput).AddTo(gameObject);
NumberInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Number.Value = s);
//载重
DataSource.Load.SubscribeToText(LoadText).AddTo(gameObject);
DataSource.Load.SubscribeToText(LoadInput).AddTo(gameObject);
LoadInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Load.Value = s);
//通往层数
DataSource.Layer.SubscribeToText(LayerText).AddTo(gameObject);
DataSource.Layer.SubscribeToText(LayerInput).AddTo(gameObject);
LayerInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Layer.Value = s);
#endregion
#region Button Click
//保存
SaveButton.onClick.AsObservable().Subscribe(onClick =>
{
SaveData();
}).AddTo(gameObject);
transform.Find("TitleBar/CloseButton").GetComponent<Button>().OnClickAsObservable()
.Subscribe(_ => Hide());
Observable.EveryLateUpdate()
.Where(_ => Input.GetMouseButtonDown(1))
.Subscribe(_ => Hide());
#endregion
}
public override void Show()
{
base.Show();
Vector2 pos = MainMenu.Instance.GetMousePosition(gameObject);
gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(pos.x, pos.y);
LoadData();
GetComponent<AttributePanelControl>().ResetPanel();
}
/// <summary>
/// 加载数据
/// <summary>
private void LoadData()
{
string url = string.Format(HttpManager.Instance.GetFireLiftsById,DataSource.Id);
HttpManager.Instance.Get<FireElevator>(url, d =>
{
DataSource.SetData(d);
});
}
/// <summary>
/// 保存数据
/// <summary>
private void SaveData()
{
string url = string.Format(HttpManager.Instance.PostFireLiftsById, DataSource.Id);
HttpManager.Instance.Post(url, DataSource.GetData());
}
}