Rotating Rect Transform

Hey guys!

I am looking to rotate an image on my canvas via its Rect Transform value. I have tried this on all of the different Canvas types and it still does not rotate. Your thoughts? Thanks guys!

var timeCounter : int = 0;
var x : float;
var y : float;
var z : float;

function Update()
{
timeCounter += Time.deltaTime;

x = Mathf.Cos(timeCounter);
y = Mathf.Sin(timeCounter);
z = 0;

GetComponent.<RectTransform>().tranform.rotation = Quaternion.Euler(x,y,z);

print("X: " + x + "Y: " + y + "Z: " + z);
}

transform
not
tranform

also I believe you don’t need the GetComponent.(), you should just be able to reference the transform directly

As a note, this code shouldn’t compile, which means you should have been able to see an error in the Unity console (check the very bottom of the window). This is your first place to look for problems, and when you come here, always paste in any errors you have along with the code!

You can press F5 in the monodevelop to see if the code compiles… Also to rotate (simple) you can use this method

this.transform.Rotate(Vector3.right, Mathf.Deg2Rad * rotationY); // This is for right left rotation which im using with mouse drag… if you change Vector3.right to Vector3.up then you will have upwards rotation too

Hey guys sorry for the delay I do have it in Unity as Transform, that was a typo when I wrote it here in the thread!

I will try what you suggested Lib!

Thanks guys!