using UnityEngine; using UnityEngine.UI; using UniRx; public class BuildingInformationPanel : UIView { #region Variables //单位名称 public Text NameText; public InputField NameInput; //单位地址 public Text AddressText; public InputField AddressInput; //单位坐标 public Text CoordsText; public InputField CoordsInput; //楼层数 public Text FloorsText; public InputField FloorsInput; //占地面积 public Text FloorAreaText; public InputField FloorAreaInput; //建筑面积 public Text BuildingAreaText; public InputField BuildingAreaInput; //建筑高度 public Text HeightText; public InputField HeightInput; //建筑结构 public Text StructureText; public InputField StructureInput; //使用性质 public Text PropertyText; public InputField PropertyInput; //耐火等级 public Text GradeText; public InputField GradeInput; //企业法人 public Text JuridicalPersonText; public InputField JuridicalPersonInput; //法人电话 public Text JuridicalPersonPhoneText; public InputField JuridicalPersonPhoneInput; //消防负责人 public Text FireHeadText; public InputField FireHeadInput; //负责人电话 public Text FireHeadPhoneText; public InputField FireHeadPhoneInput; public Button SaveButton; #endregion public override void Awake() { base.Awake(); #region DataSource Bind DataSource.Name.SubscribeToText(NameText).AddTo(gameObject); DataSource.Name.SubscribeToText(NameInput).AddTo(gameObject); DataSource.Address.SubscribeToText(AddressText).AddTo(gameObject); DataSource.Address.SubscribeToText(AddressInput).AddTo(gameObject); DataSource.Coords.SubscribeToText(CoordsText).AddTo(gameObject); DataSource.Coords.SubscribeToText(CoordsInput).AddTo(gameObject); DataSource.Floors.SubscribeToText(FloorsText).AddTo(gameObject); DataSource.Floors.SubscribeToText(FloorsInput).AddTo(gameObject); DataSource.FloorArea.SubscribeToText(FloorAreaText).AddTo(gameObject); DataSource.FloorArea.SubscribeToText(FloorAreaInput).AddTo(gameObject); DataSource.BuildingArea.SubscribeToText(BuildingAreaText).AddTo(gameObject); DataSource.BuildingArea.SubscribeToText(BuildingAreaInput).AddTo(gameObject); DataSource.Height.SubscribeToText(HeightText).AddTo(gameObject); DataSource.Height.SubscribeToText(HeightInput).AddTo(gameObject); DataSource.Structure.SubscribeToText(StructureText).AddTo(gameObject); DataSource.Structure.SubscribeToText(StructureInput).AddTo(gameObject); DataSource.Property.SubscribeToText(PropertyText).AddTo(gameObject); DataSource.Property.SubscribeToText(PropertyInput).AddTo(gameObject); DataSource.Grade.SubscribeToText(GradeText).AddTo(gameObject); DataSource.Grade.SubscribeToText(GradeInput).AddTo(gameObject); DataSource.JuridicalPerson.SubscribeToText(JuridicalPersonText).AddTo(gameObject); DataSource.JuridicalPerson.SubscribeToText(JuridicalPersonInput).AddTo(gameObject); DataSource.JuridicalPersonPhone.SubscribeToText(JuridicalPersonPhoneText).AddTo(gameObject); DataSource.JuridicalPersonPhone.SubscribeToText(JuridicalPersonPhoneInput).AddTo(gameObject); DataSource.FireHead.SubscribeToText(FireHeadText).AddTo(gameObject); DataSource.FireHead.SubscribeToText(FireHeadInput).AddTo(gameObject); DataSource.FireHeadPhone.SubscribeToText(FireHeadPhoneText).AddTo(gameObject); DataSource.FireHeadPhone.SubscribeToText(FireHeadPhoneInput).AddTo(gameObject); NameInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Name.Value = s).AddTo(gameObject); AddressInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Address.Value = s).AddTo(gameObject); CoordsInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Coords.Value = s).AddTo(gameObject); FloorsInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Floors.Value = s).AddTo(gameObject); FloorAreaInput.OnValueChangedAsObservable().Subscribe(s => DataSource.FloorArea.Value = s).AddTo(gameObject); BuildingAreaInput.OnValueChangedAsObservable().Subscribe(s => DataSource.BuildingArea.Value = s).AddTo(gameObject); HeightInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Height.Value = s).AddTo(gameObject); StructureInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Structure.Value = s).AddTo(gameObject); PropertyInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Property.Value = s).AddTo(gameObject); GradeInput.OnValueChangedAsObservable().Subscribe(s => DataSource.Grade.Value = s).AddTo(gameObject); JuridicalPersonInput.OnValueChangedAsObservable().Subscribe(s => DataSource.JuridicalPerson.Value = s).AddTo(gameObject); JuridicalPersonPhoneInput.OnValueChangedAsObservable().Subscribe(s => DataSource.JuridicalPersonPhone.Value = s).AddTo(gameObject); FireHeadInput.OnValueChangedAsObservable().Subscribe(s => DataSource.FireHead.Value = s).AddTo(gameObject); FireHeadPhoneInput.OnValueChangedAsObservable().Subscribe(s => DataSource.FireHeadPhone.Value = s).AddTo(gameObject); #endregion #region Button Click SaveButton.OnClickAsObservable() .Subscribe(_ => { SaveData(); }); transform.Find("TitleBar/CloseButton").GetComponent