yyl
17 小时以前 9c7efb57bf1b21954c7d81b705c8a8a34e7fb364
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
66
67
68
69
using UnityEngine;
using System;
 
 
public static class MaterialUtility
{
 
    public static Material GetDefaultSpriteGrayMaterial()
    {
        return ResManager.Instance.LoadAsset<Material>("Materials", "SpriteGray");
    }
 
    public static Material GetInstantiatedSpriteGrayMaterial()
    {
        var material = new Material(GetDefaultSpriteGrayMaterial());
        return material;
    }
 
    public static Material GetSmoothMaskGrayMaterial()
    {
        return ResManager.Instance.LoadAsset<Material>("Materials", "SmoothMaskGray");
    }
 
    public static Material GetInstantiatedSpriteTwinkleMaterial()
    {
        var material = ResManager.Instance.LoadAsset<Material>("Materials", "Flash");
        return new Material(material);
    }
 
    public static Material GetUIDefaultGraphicMaterial()
    {
        return UnityEngine.UI.Image.defaultGraphicMaterial;
    }
 
    public static Material GetGUIRenderTextureMaterial()
    {
        return ResManager.Instance.LoadAsset<Material>("Materials", "UI_RenderTexture");
    }
 
    public static void SetRenderSortingOrder(this GameObject root, int sortingOrder, bool includeChildren)
    {
 
        if (root == null)
        {
            throw new NullReferenceException();
        }
 
        if (includeChildren)
        {
            var renderers = root.GetComponentsInChildren<Renderer>();
            for (var i = 0; i < renderers.Length; i++)
            {
                var renderer = renderers[i];
                renderer.sortingOrder = sortingOrder;
            }
        }
        else
        {
            var renderer = root.GetComponent<Renderer>();
            if (renderer != null)
            {
                renderer.sortingOrder = sortingOrder;
            }
        }
    }
 
 
 
}