using System; using UnityEngine; public class PhotSaveLoagDataUnit : MonoBehaviour { public string title { get { return this.title_input_.value; } set { this.title_input_.value = value; } } public string comment { get { return this.comment_input_.value; } set { this.comment_input_.value = value; } } public string date_text { get { return this.data_label_.text; } set { this.data_label_.text = value; } } public int maid_count { get { return int.Parse(this.maid_count_label_.text); } set { this.maid_count_label_.text = value.ToString("d2"); } } public bool new_sloat { get { return this.new_sprite_object_.activeSelf; } set { this.new_sprite_object_.SetActive(value); } } public bool visible_content { get { return this.data_info_obj_.activeSelf; } set { this.RemoveInputFocus(); this.data_info_obj_.SetActive(value); } } public bool enabled_button { get { return this.main_btn_.isEnabled; } set { this.RemoveInputFocus(); this.main_btn_.isEnabled = value; } } public object save_data_object { get { return this.save_data_object_; } set { this.save_data_object_ = value; } } public byte[] thumbnail { set { if (value == null || value.Length <= 0) { if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture); } this.thumbnail_sprite_.sprite2D = null; return; } Texture2D texture2D = new Texture2D(1, 1, TextureFormat.ARGB32, false); texture2D.LoadImage(value); Sprite sprite2D = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2)); if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture); } this.thumbnail_sprite_.sprite2D = sprite2D; this.thumbnail_sprite_.SetDimensions(texture2D.width, texture2D.height); } } public Texture2D thumbnail_tex { set { if (value == null) { if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture); } this.thumbnail_sprite_.sprite2D = null; return; } Sprite sprite2D = Sprite.Create(value, new Rect(0f, 0f, (float)value.width, (float)value.height), default(Vector2)); if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture); } this.thumbnail_sprite_.sprite2D = sprite2D; this.thumbnail_sprite_.SetDimensions(value.width, value.height); } } public void Awake() { this.main_btn_ = base.GetComponent(); EventDelegate.Add(this.main_btn_.onClick, new EventDelegate.Callback(this.OnClickEvent)); this.data_info_obj_ = UTY.GetChildObject(base.gameObject, "Content/DataInfo", false); this.title_input_ = UTY.GetChildObject(this.data_info_obj_, "Title/InputField", false).GetComponent(); EventDelegate.Add(this.title_input_.onChange, new EventDelegate.Callback(this.OnChangeTitle)); this.comment_input_ = UTY.GetChildObject(this.data_info_obj_, "Comment/InputField", false).GetComponent(); EventDelegate.Add(this.comment_input_.onChange, new EventDelegate.Callback(this.OnChangeComment)); this.data_label_ = UTY.GetChildObject(this.data_info_obj_, "Date", false).GetComponent(); this.maid_count_label_ = UTY.GetChildObject(this.data_info_obj_, "NumberOfEmployees/Number", false).GetComponent(); this.new_sprite_object_ = UTY.GetChildObject(this.data_info_obj_, "NewLabel", false); this.new_sprite_object_.SetActive(false); this.thumbnail_sprite_ = UTY.GetChildObject(this.data_info_obj_, "Thum", false).GetComponent(); string empty = string.Empty; this.comment = empty; this.title = empty; this.maid_count = 0; } public void OnDestroy() { if (this.thumbnail_sprite_ != null && this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture); } this.thumbnail_sprite_.sprite2D = null; } public void RemoveInputFocus() { this.title_input_.RemoveFocus(); this.comment_input_.RemoveFocus(); } private void OnChangeTitle() { if (this.onChangeTitle != null) { this.onChangeTitle(this); } } private void OnChangeComment() { if (this.onChangeComment != null) { this.onChangeComment(this); } } private void OnClickEvent() { if (this.onClick != null) { this.onClick(this); } } public Action onClick; public Action onChangeTitle; public Action onChangeComment; private UIButton main_btn_; private GameObject data_info_obj_; private UIInput title_input_; private UIInput comment_input_; private UILabel data_label_; private UILabel maid_count_label_; private GameObject new_sprite_object_; private UI2DSprite thumbnail_sprite_; private object save_data_object_; }