少年修仙传客户端代码仓库
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using UnityEngine;
using System.Collections;
using System;
 
 
public static class LayerUtility
{
    public static readonly int DefaultLayer = LayerMask.NameToLayer("Default");
    public static readonly int DefaultMask = 1 << DefaultLayer;
 
    public static readonly int GroundLayer = LayerMask.NameToLayer("Ground");
    public static readonly int GroundMask = 1 << GroundLayer;
 
    public static readonly int Wall = LayerMask.NameToLayer("Wall");
    public static readonly int WallMask = 1 << Wall;
 
    public static readonly int UILayer = LayerMask.NameToLayer("UI");
    public static readonly int UIMask = 1 << UILayer;
 
    public static readonly int DevisableUI = LayerMask.NameToLayer("DevisableUI");
    public static readonly int DevisableUIMask = 1 << DevisableUI;
 
    public static readonly int UIEffectLayer = LayerMask.NameToLayer("UIEffect");
    public static readonly int UIEffectMask = 1 << UILayer;
 
    public static readonly int HUDLayer = LayerMask.NameToLayer("HUD");
    public static readonly int HUDMask = 1 << HUDLayer;
 
    public static readonly int Player = LayerMask.NameToLayer("Player");
    public static readonly int PlayerMask = 1 << Player;
 
    public static readonly int Monster = LayerMask.NameToLayer("Monster");
    public static readonly int MonsterMask = 1 << Monster;
 
    public static readonly int TransparentFX = LayerMask.NameToLayer("TransparentFX");
    public static readonly int TransparentFXMask = 1 << TransparentFX;
 
    public static readonly int Hero = LayerMask.NameToLayer("Hero");
    public static readonly int HeroMask = 1 << Hero;
 
    public static readonly int MapTrigger = LayerMask.NameToLayer("MapTrigger");
    public static readonly int MapTriggerMask = 1 << MapTrigger;
 
    public static readonly int Walkble = LayerMask.NameToLayer("WalkbleLayer");
    public static readonly int WalkbleMask = 1 << Walkble;
 
    public static readonly int BossShow = LayerMask.NameToLayer("BossShow");
    public static readonly int BossShowMask = 1 << BossShow;
 
    public static readonly int BattleEffectLow = LayerMask.NameToLayer("BattleEffectLow");
    public static readonly int BattleEffectLowMask = 1 << BattleEffectLow;
    public static readonly int BattleEffectMid = LayerMask.NameToLayer("BattleEffectMid");
    public static readonly int BattleEffectMidMask = 1 << BattleEffectMid;
    public static readonly int BattleEffectHigh = LayerMask.NameToLayer("BattleEffectHigh");
    public static readonly int BattleEffectHighMask = 1 << BattleEffectHigh;
 
    public static readonly int Hide = LayerMask.NameToLayer("Hide");
    public static readonly int HideMask = 1 << Hide;
 
    public static readonly int MaskShow = LayerMask.NameToLayer("MaskShow");
    public static readonly int MaskShowMask = 1 << MaskShow;
 
 
    public static void SetLayer(this GameObject _gameObject, int _layer, bool _recursive)
    {
        if (_gameObject == null)
        {
            return;
        }
 
        _gameObject.layer = _layer;
 
        if (_recursive && _gameObject.transform.childCount > 0)
        {
            var childCount = _gameObject.transform.childCount;
            for (var i = 0; i < childCount; i++)
            {
                var child = _gameObject.transform.GetChild(i);
                SetLayer(child.gameObject, _layer, true);
            }
        }
 
    }
 
}