Assigning textures in project panel to materials dynamically or via editor scripts

Is it possible to assign textures in project panel to materials via editor scripts, or at runtime?

Correct me if I misunderstood the question, but I think this may be what you’re trying to achieve?

    public Texture colorMap;//Assign this in inspector
    public Texture colorMap2;//Assign this in inspector
    
//The next lines will assign the above textures to the gameobject's material texture:
    if (condition)
    {
    gameObject.renderer.material.mainTexture = colorMap;
    }
    else if (!condition)
    {
    gameObject.renderer.material.mainTexture = colorMap2;
    
    }

Depending on the shader you may have access to other textures as well through scripting, such as normal maps, etc.