That's because NGUI doesn't use your material. It makes a copy for its own draw calls.
If you want to set some material property, you need to subscribe to widget.onRender
I tried applying widget.onRender. and it didn't work.
Material maskedMaterial = new Material(maskShader);
// assign the textures
maskedMaterial.SetTexture("_AlphaTex", maskTexture.mainTexture);
maskedMaterial.SetTexture("_MainTex", mainTexture.mainTexture);
maskedMaterial.SetTextureOffset("_AlphaTex", new Vector2(x, y));
// assign the material
mainTexture.material = maskedMaterial;
AND
void OnRender (Material mat) {
mat.SetTextureOffset("_AlphaTex", new Vector2(.10f, .10f));
Debug.Log("offsetX: " + mat.GetTextureOffset("_AlphaTex").x + " offsety: " + mat.GetTextureOffset("_AlphaTex").y);
}
// on render debug shows correct values
Above is my code for assigning material, the material has the shader. But it still dont apply offsets.