yyl
1 天以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using UnityEngine.UI;
using UnityEngine;
 
 
 
public class ImageEx : Image
{
 
    CanvasAddition m_CanvasAddition;
    public CanvasAddition canvasAddition {
        get {
            return this.m_CanvasAddition ?? (this.m_CanvasAddition = this.GetComponentInParent<CanvasAddition>());
        }
    }
 
    Material materialRecorder;
 
    [SerializeField]
    bool m_Gray = false;
    public bool gray {
        get {
            return this.m_Gray;
        }
        set {
            if (this.gray == value)
            {
                return;
            }
 
            this.m_Gray = value;
            if (!inited)
            {
                return;
            }
 
            if (this.m_Gray)
            {
                this.material = this.canvasAddition == null ? MaterialUtility.GetDefaultSpriteGrayMaterial() : this.canvasAddition.spriteGrayMaterial;
            }
            else
            {
                this.material = materialRecorder;
            }
        }
    }
 
    [SerializeField] string m_IconKey = string.Empty;
 
    bool inited = false;
    protected override void Awake()
    {
        base.Awake();
        materialRecorder = this.material;
        inited = true;
        if (this.m_Gray)
        {
            this.material = this.canvasAddition == null ? MaterialUtility.GetDefaultSpriteGrayMaterial() : this.canvasAddition.spriteGrayMaterial;
        }
 
        if (!string.IsNullOrEmpty(m_IconKey))
        {
            this.SetSprite(m_IconKey);
        }
    }
}