Pull mesh.uv into a new array, edit them as you like, then pass the array back in to the mesh (you can't just edit them directly from mesh.uv, you have to feed it the entire array at once like mesh.uv = myEditedUVArray; ).
Be careful with editing the mesh or the sharedMesh values. mesh is that specific instance of the mesh, sharedMesh will actually edit the source mesh and thus affect all versions of that mesh in your scene (and if you're working in the editor, it actually affects the mesh itself and will keep any changes you make until you reimport it into your project).
EDIT: Or, as kio suggests below, edit the material's settings for offset and scale
I managed to getting it working by animating the offset and scale like kio suggested, now all i need is for that animated node to work as the alpha for tiled diffuse but when i tile the diffuse the alpha tiles with it... even though it says 10x10 next to diffuse and still 1x1 next to the alpha. Recon I'd have to have two separate UV sets?
Depends on the shader code. I'm guessing it's custom 'cause the built-in stuff doesn't have a separate alpha.
Probably it's using the same offset settings as the diffuse at the moment. Worth checking that the alpha and diffuse aren't sampling using the same lookup uv (generated inside the shader by altering the uv coords by the offset/scale of a given texture).
Replies
Your 2 best options are to either:
A: animate your uvs in Unity's animation editor with tile offset or
B: make/find a uv scrolling script. Here is a good starting place.
I hope that helps.
It's possible to script it, as gsokol mentioned.
Do you recon that could be scripted? (By one of our programmers of course)
The green square being the UV island.
You'd want to look at the Mesh class http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html
Pull mesh.uv into a new array, edit them as you like, then pass the array back in to the mesh (you can't just edit them directly from mesh.uv, you have to feed it the entire array at once like mesh.uv = myEditedUVArray; ).
Be careful with editing the mesh or the sharedMesh values. mesh is that specific instance of the mesh, sharedMesh will actually edit the source mesh and thus affect all versions of that mesh in your scene (and if you're working in the editor, it actually affects the mesh itself and will keep any changes you make until you reimport it into your project).
EDIT: Or, as kio suggests below, edit the material's settings for offset and scale
just animate the offsert&scale value of the texture. ( maybe unity fbx import even supports that on a material level? )
if you want to do it in code - this should get you started:
http://docs.unity3d.com/Documentation/ScriptReference/Material.SetTextureOffset.html
http://docs.unity3d.com/Documentation/ScriptReference/Material.SetTextureScale.html
I managed to getting it working by animating the offset and scale like kio suggested, now all i need is for that animated node to work as the alpha for tiled diffuse but when i tile the diffuse the alpha tiles with it... even though it says 10x10 next to diffuse and still 1x1 next to the alpha. Recon I'd have to have two separate UV sets?
Probably it's using the same offset settings as the diffuse at the moment. Worth checking that the alpha and diffuse aren't sampling using the same lookup uv (generated inside the shader by altering the uv coords by the offset/scale of a given texture).
.........................................
Shader "Transparent/Diffuse + Extra Alpha"
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_AlphaMap ("Additional Alpha Map (Greyscale)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _AlphaMap;
float4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a * tex2D(_AlphaMap, IN.uv_MainTex).r;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
.........................................
However when I changed it to this:
.........................................
Shader "Transparent/Diffuse + Extra Alpha"
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_AlphaMap ("Additional Alpha Map (Greyscale)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _AlphaMap;
float4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv_Alpha;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a * tex2D(_AlphaMap, IN.uv_Alpha).r;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
.........................................
That broke it :P Can you tell i'm no coder? :P
It shares the same name as the texture property you're after the settings for, which is _AlphaMap in this case