반응형
DamageOnTouch.cs
[Flags]
public enum TriggerAndCollisionMask
{
IgnoreAll = 0,
OnTriggerEnter = 1 << 0,
OnTriggerStay = 1 << 1,
OnTriggerEnter2D = 1 << 6,
OnTriggerStay2D = 1 << 7,
All_3D = OnTriggerEnter | OnTriggerStay,
All_2D = OnTriggerEnter2D | OnTriggerStay2D,
All = All_3D | All_2D
}
public TriggerAndCollisionMask TriggerFilter = AllowedTriggerCallbacks;
// ...
public virtual void OnTriggerStay(Collider collider)
{
if (0 == (TriggerFilter & TriggerAndCollisionMask.OnTriggerStay)) return;
Colliding(collider.gameObject);
}
public virtual void OnTriggerEnter(Collider collider)
{
if (0 == (TriggerFilter & TriggerAndCollisionMask.OnTriggerEnter)) return;
Colliding(collider.gameObject);
}
반응형
'Unity > Unity 리서치' 카테고리의 다른 글
C# 확장매소드(Extension Method) (0) | 2023.02.16 |
---|---|
gameObject에 SendMessage 보내기 (0) | 2023.01.25 |
Collider2D, Collider 상속 관계 (0) | 2023.01.23 |
유니티 강좌 모음 (0) | 2023.01.03 |
[RTS Engine] Object Pooling 이 제대로 안될 때 (0) | 2022.03.30 |