using System; using UnityEngine; public class OnaholeNodeIconButton : MonoBehaviour, IOnaholeNodeButton { public string uniqueName { get; set; } public OnaholeNodeButton.SelectType selectType { get { return this.selectType_; } set { this.selectType_ = value; if (value == OnaholeNodeButton.SelectType.None) { this.bg.alpha = this.defaultBGAlpha; } else if (value == OnaholeNodeButton.SelectType.Focus) { this.bg.alpha = 1f; } else if (value == OnaholeNodeButton.SelectType.Select) { this.bg.alpha = 1f; } else if (value == OnaholeNodeButton.SelectType.Disable) { this.bg.alpha = 0.2f; } } } private void Awake() { this.defaultBGAlpha = this.bg.alpha; this.selectType = OnaholeNodeButton.SelectType.None; this.SetCopyTargetSprite(this.copyTargetSprite); } public void SetCopyTargetSprite(UISprite sprite) { if (sprite == null || this.iconSprite == null) { return; } this.copyTargetSprite = sprite; this.iconSprite.atlas = this.copyTargetSprite.atlas; this.iconSprite.spriteName = this.copyTargetSprite.spriteName; this.iconSprite.SetDimensions(this.copyTargetSprite.width, this.copyTargetSprite.height); this.iconSprite.SetDirty(); this.Update(); } private void Update() { if (this.iconSprite != null && this.copyTargetSprite != null) { this.iconSprite.color = this.copyTargetSprite.color; } } GameObject IOnaholeNodeButton.get_gameObject() { return base.gameObject; } [SerializeField] private UIWidget bg; [SerializeField] private UISprite iconSprite; [SerializeField] private UISprite copyTargetSprite; private float defaultBGAlpha; private OnaholeNodeButton.SelectType selectType_; }