Not working condition: gameObject.layer==LayerMask.GetMask...

How can I check the object for several layers? The example below does not work! I want to have one variable where all the layers with which I want to compare the object can be written. This is more convenient than the NameToLayer

LayerMask layersContact;

void Start()
    {
        layersContact= LayerMask.GetMask("Road", "Terrain");
    }

void Update()
    {
        if (gameObject.layer == layersContact)
        {
            Debug.Log("WORK!!!");
        }
    }

@Lesnikus
I had the same problem you did, and I couldn’t get it to work. After reading through the unity documentation I came to the conclusion that layermask is used exclusively for physics racyast, check sphere, line cast, and the like, so it can’t be used in a regular if statement. My solution was to use a check sphere, but I’m not sure if that would help you in your case.
Unity Layers documentation: Unity - Manual: Layers
Unity Layermask Documentation: Unity - Scripting API: LayerMask