Change material texture runtime

I have a Material Mt and a Texture Tx (not Texture2D)
How do I change the maintexture of the Mt with Tx?

Mt.texture=Tx; does not have effect
SetTexture make error.

The correct use of SetTexture is described in this page of the Unity documentation: Unity - Scripting API: Material.SetTexture

A simplification of their example would be:

using UnityEngine;

public class Example : MonoBehaviour {

    public Texture mainTexture;  // Set this texture in the inspector

    void Start ()
    {
            GetComponent<Renderer>().material.SetTexture("_MainTex", mainTexture);
    }
}

If you’re still getting an error doing it this way, show us the error and the code you’re using, so we can see what might be going wrong.

Tx is read from disk and I want to assign it to Skybox.

My code is currently

Texture Tx;

// Reading from disk

RenderSettings.skybox.SetTexture("_Tex",Tx);

Error:
Error assigning 2D texture to CUBE texture property ‘_Tex’: Dimensions must match
UnityEngine.Material:SetTexture (string,UnityEngine.Texture)

at the line RenderSettings.skybox.SetTexture(“_Tex”,Tx)

Also my skybox, and its Material in the Assets become white.

This happens even if I load the original image of the material.

Instead if I use

Texture Tx;

// Reading from disk

RenderSettings.skybox.SetTexture("_MainTex",Tx);

I have no error but nothing happens

So you Texture that you want assign is Cubemap?

The texture originally assigned has TextureShape=Cube. The one I want to assign probably no: I load it with UnityWebRequest, get a Texture object.
At this point I suppose I should set TextureShape=Cube in the new one too, but I failed.
I’ve read examples online that use TextureImporter which is part of UnityEditor though, so it wouldn’t work compiled.

Actually I noticed that UnityWebRequest returns a Texture2D but I assign it in a Texture.