using UnityEngine; using UnityEngine.UI; using UniRx; using AX.ImageViewer; using System; public class SiameseConnectionAttributePanel : UIView { //位置 public Text LocationText; public InputField LocationInput; //类型 public Text TypeText; public InputField TypeInput; //编号 public Text NumberText; public InputField NumberInput; //范围 public Text RangeText; public InputField RangeInput; //图片类型 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.Type.SubscribeToText(TypeText).AddTo(gameObject); DataSource.Type.SubscribeToText(TypeInput).AddTo(gameObject); //编号 DataSource.Number.SubscribeToText(NumberText).AddTo(gameObject); DataSource.Number.SubscribeToText(NumberInput).AddTo(gameObject); //范围 DataSource.Range.SubscribeToText(RangeText).AddTo(gameObject); DataSource.Range.SubscribeToText(RangeInput).AddTo(gameObject); LocationInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Location.Value = s); NumberInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Number.Value = s); TypeInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Type.Value = s); RangeInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Range.Value = s); //图片类型 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); #endregion #region Button Click //保存 SaveButton.onClick.AsObservable().Subscribe(onClick => { SaveData(); }).AddTo(gameObject); //查看原图 ViewButton.onClick.AsObservable().Subscribe(onClick => { ViewImage(); }).AddTo(gameObject); //上传图片 OpenImageFile.OnLoadTextureFinished = texture => { UploadImage(texture); }; transform.Find("TitleBar/CloseButton").GetComponent