using UnityEngine; using UnityEngine.UI; using UniRx; public class FirePumpAttributePanel : UIView { //类型 public Text TypeText; public InputField TypeInput; //型号 public Text ModeText; public InputField ModeInput; //功率 public Text PowerText; public InputField PowerInput; //扬程 public Text LiftText; public InputField LiftInput; //流量 public Text FlowText; public InputField FlowInput; //压力 public Text PressureText; public InputField PressureInput; //保存按钮 public Button SaveButton; public Button CancelButton; public Button EditorButton; public GameObject InfosPanel; public GameObject InputsPanel; public GameObject DefaultPanel; public GameObject EditorPanel; public override void Awake() { base.Awake(); #region DataSource Bind //类型 DataSource.Type.SubscribeToText(TypeText).AddTo(gameObject); DataSource.Type.SubscribeToText(TypeInput).AddTo(gameObject); TypeInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Type.Value = s); //型号 DataSource.Mode.SubscribeToText(ModeText).AddTo(gameObject); DataSource.Mode.SubscribeToText(ModeInput).AddTo(gameObject); ModeInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Mode.Value = s); //功率 DataSource.Power.SubscribeToText(PowerText).AddTo(gameObject); DataSource.Power.SubscribeToText(PowerInput).AddTo(gameObject); PowerInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Power.Value = s); //扬程 DataSource.Lift.SubscribeToText(LiftText).AddTo(gameObject); DataSource.Lift.SubscribeToText(LiftInput).AddTo(gameObject); LiftInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Lift.Value = s); //流量 DataSource.Flow.SubscribeToText(FlowText).AddTo(gameObject); DataSource.Flow.SubscribeToText(FlowInput).AddTo(gameObject); FlowInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Flow.Value = s); //压力 DataSource.Pressure.SubscribeToText(PressureText).AddTo(gameObject); DataSource.Pressure.SubscribeToText(PressureInput).AddTo(gameObject); PressureInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Pressure.Value = s); #endregion #region Button Click //编辑 EditorButton.onClick.AsObservable().Subscribe(onClick => { InfosPanel.SetActive(false); InputsPanel.SetActive(true); DefaultPanel.SetActive(false); EditorPanel.SetActive(true); }).AddTo(gameObject); //保存 SaveButton.onClick.AsObservable().Subscribe(onClick => { InfosPanel.SetActive(true); InputsPanel.SetActive(false); DefaultPanel.SetActive(true); EditorPanel.SetActive(false); SaveData(); }).AddTo(gameObject); //取消 CancelButton.onClick.AsObservable().Subscribe(onClick => { InfosPanel.SetActive(true); InputsPanel.SetActive(false); DefaultPanel.SetActive(true); EditorPanel.SetActive(false); }).AddTo(gameObject); transform.Find("TitleBar/CloseButton").GetComponent