- Home /
Texture rotation by renderer.material.SetMatrix
Need help to get the following code work in my 2d project. I want to be able to rotate texture but nothing happens.
#pragma strict
function Update ()
{
var rot = Quaternion.Euler (0, 0, Time.time * 5);
var m = Matrix4x4.TRS (Vector3.zero, rot, Vector3(1,1,1) );
renderer.material.SetMatrix ("_Rotation", m);
}
This is only going to work if the shader has a _Rotation property. What shader are you using?
There is no '_Rotation' property in the Unlit/Transparent shader. If you click on the 'edit...' button for any shader, you can open it in $$anonymous$$onodevelop. You can then look at the 'Properties {}' block to see if it has a '_Rotation' property. }
Do a google search for "unity3d shader _rotation" for many hits including this one:
http://www.gabemccauleyportfolio.com/3/post/2012/03/texture-rotation-strumpy-shader-editor.html
That link is dead and most of the stuff it turns up is too complicated by far.
Answer by illustir · Apr 21, 2015 at 06:18 PM
I have been looking around for a solution to this problem the past hours and am extremely disappointed that nothing is available.