using UnityEngine; using UnityEngine.UI; using UniRx; using AX.ImageViewer; public class SmokeFanPanel : UIView { //标题 public Text TitleText; //排烟量 public Text VolumeText; public InputField VolumeInput; //启动方式 public Text ModeText; public InputField ModeInput; //开关位置 public Text LocationText; public InputField LocationInput; //图片类型 public OriginalImageType ImageType; //图片面板 public Image ImagePanel; //全景开关 public Toggle ImageTypeToggle; //查看原图 public Button ViewButton; public OpenImage OpenImageFile; //保存按钮 public Button SaveButton; //url private string url; public override void Awake() { base.Awake(); #region DataSource Bind DataSource.Name.SubscribeToText(VolumeText).AddTo(gameObject); DataSource.Name.SubscribeToText(VolumeInput).AddTo(gameObject); DataSource.Discription.SubscribeToText(ModeText).AddTo(gameObject); DataSource.Discription.SubscribeToText(ModeInput).AddTo(gameObject); DataSource.Address.SubscribeToText(LocationText).AddTo(gameObject); DataSource.Address.SubscribeToText(LocationInput).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); VolumeInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Name.Value = s); ModeInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Discription.Value = s); LocationInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Address.Value = s); ImageTypeToggle.OnValueChangedAsObservable().Subscribe(b => { DataSource.ImageType.Value = b ? OriginalImageType.Panorama : OriginalImageType.Normal; }).AddTo(gameObject); #endregion #region Button Click //保存 SaveButton.onClick.AsObservable().Subscribe(onClick => { SaveData(); }).AddTo(gameObject); //查看原图 ViewButton.onClick.AsObservable().Subscribe(onClick => { ViewImage(); }); //关闭 transform.Find("TitleBar/CloseButton").GetComponent