using System; using UnityEngine; using Yotogis; public class YotogiOldSkillIcon : MonoBehaviour { public void Awake() { this.ui2d_sprite_ = base.GetComponent(); this.box_collider_ = base.GetComponent(); NDebug.AssertNull(this.ui2d_sprite_); } public void OnDestroy() { if (this.ui2d_sprite_.sprite2D != null && this.ui2d_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.ui2d_sprite_.sprite2D.texture); } } public void SetSkillData(Skill.Old.Data skill_data) { this.skill_data_ = skill_data; if (this.skill_data_ == null) { if (this.ui2d_sprite_.sprite2D != null && this.ui2d_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.ui2d_sprite_.sprite2D.texture); } this.ui2d_sprite_.sprite2D = null; } else { this.LoadImage(this.skill_data_.icon_file_name); } } public void LoadImage(string file_name) { file_name += ".tex"; if (!GameUty.FileSystemOld.IsExistentFile(file_name)) { file_name = "icon_none.tex"; } this.tex_ = ImportCM.CreateTexture(file_name); Sprite sprite = Sprite.Create(this.tex_, new Rect(0f, 0f, (float)this.tex_.width, (float)this.tex_.height), default(Vector2)); sprite.name = file_name; if (this.ui2d_sprite_.sprite2D != null && this.ui2d_sprite_.sprite2D.texture != null) { UnityEngine.Object.DestroyImmediate(this.ui2d_sprite_.sprite2D.texture); } this.ui2d_sprite_.sprite2D = sprite; this.ui2d_sprite_.SetDimensions(this.IconSize, this.IconSize); if (this.box_collider_ != null && this.AutoColliderChange) { this.box_collider_.size = new Vector3((float)this.IconSize, (float)this.IconSize, 1f); } } public void SetOnClickEvent(YotogiOldSkillIcon.OnClickEvent set_event) { UIButton component = base.GetComponent(); if (component == null || set_event == null) { return; } this.on_click_event_ = set_event; EventDelegate eventDelegate = new EventDelegate(this, "OnClickButtonCallBack"); EventDelegate.Parameter parameter = eventDelegate.parameters[0]; parameter.obj = base.gameObject; EventDelegate.Add(component.onClick, eventDelegate); } public Skill.Old.Data skill_data { get { return this.skill_data; } } private void OnClickButtonCallBack(GameObject my) { if (this.on_click_event_ != null) { this.on_click_event_(my, my.GetComponent()); } } public int IconSize = 80; public bool AutoColliderChange = true; private UI2DSprite ui2d_sprite_; private BoxCollider box_collider_; private Texture2D tex_; private Skill.Old.Data skill_data_; private YotogiOldSkillIcon.OnClickEvent on_click_event_; public delegate void OnClickEvent(GameObject my, YotogiOldSkillIcon click_obj); }