using UnityEngine; using UnityEngine.UI; using UniRx; using AX.ImageViewer; public class OutdoorHydranrAttributePanel : UIView { //位置 public Text LocationText; public InputField LocationInput; //编号 public Text NumberText; public InputField NumberInput; //管径 public Text DiameterText; public InputField DiameterInput; //牙口 public Text MouthText; public InputField MouthInput; //状态 public Text StateText; public InputField StateInput; //图片类型 public OriginalImageType ImageType; //图片面板 public Image ImagePanel; //全景开关 public Toggle ImageTypeToggle; //查看原图 public Button ViewButton; public OpenImage OpenImageFile; //保存按钮 public Button SaveButton; public override void Awake() { base.Awake(); #region DataSource Bind //位置 DataSource.Location.SubscribeToText(LocationText).AddTo(gameObject); DataSource.Location.SubscribeToText(LocationInput).AddTo(gameObject); //编号 DataSource.Number.SubscribeToText(NumberText).AddTo(gameObject); DataSource.Number.SubscribeToText(NumberInput).AddTo(gameObject); //管径 DataSource.Diameter.SubscribeToText(DiameterText).AddTo(gameObject); DataSource.Diameter.SubscribeToText(DiameterInput).AddTo(gameObject); //牙口 DataSource.Mouth.SubscribeToText(MouthText).AddTo(gameObject); DataSource.Mouth.SubscribeToText(MouthInput).AddTo(gameObject); //状态 DataSource.State.SubscribeToText(StateText).AddTo(gameObject); DataSource.State.SubscribeToText(StateInput).AddTo(gameObject); //图片类型 DataSource.ImageType.Subscribe(data => { switch (data) { case OriginalImageType.Normal: ImageTypeToggle.isOn = false; break; case OriginalImageType.Panorama: ImageTypeToggle.isOn = true; break; } }).AddTo(gameObject); //图片地址 DataSource.ImageUrl.Subscribe(url => { GetImage(); }).AddTo(gameObject); LocationInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Location.Value = s); NumberInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Number.Value = s); DiameterInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Diameter.Value = s); MouthInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Mouth.Value = s); StateInput.OnValueChangedAsObservable().Subscribe(s => DataSource.State.Value = s); #endregion #region Button Click //保存 SaveButton.onClick.AsObservable().Subscribe(onClick => { SaveData(); }).AddTo(gameObject); //查看原图 ViewButton.onClick.AsObservable().Subscribe(onClick => { ViewImage(); }); //关闭 transform.Find("TitleBar/CloseButton").GetComponent