enum Type{
Monster = 1 << 0,
Human = 1 << 1,
Boss = 1 << 2,
}
Type unit = Type.Mosnter | Type.Boss;
Type eSearch = Type.Monster | Type.Human | Type.Boss;
Debug.Log((eSearch & unit) != 0); // True
Debug.Log(eSearch.HasFlag(unit)) // True
eSearch = Type.Monster | Type.Human;
Debug.Log((eSearch & unit) != 0); // True
Debug.Log(eSearch.HasFlag(unit)) // False
I want to know in detail why the first and second result values are different when using the above code.
HasFlag seems to make a perfect comparison, so please tell me what bit operations (such as '&') are internal actions.
Ps. I understand the first and second '&' operations.
Thank you for reading.