Find Rotation of GameObject : Unity

Hello everyone …

I have one object which is rotating on z axis. Based on the rotation of that object i want to change the texture of another object.

For that i have written one script :

function Update () {

	if(rotateArrow.transform.eulerAngles.z > 90 && rotateArrow.transform.eulerAngles.z < 270)
	{
		
		transform.renderer.material.SetTexture("_MainTex", p_stand_text_left);
		gameObject.tag = "player_left";
		
	}
	
	 if(rotateArrow.transform.eulerAngles.z < 90 && rotateArrow.transform.eulerAngles.z > 270)
	{
		Debug.Log("do" + rotateArrow.transform.eulerAngles.z);
		transform.renderer.material.SetTexture("_MainTex", p_stand_text_right);
		gameObject.tag = "player_right";
	}
}

But not working as i am changing the rotation of the object.

So what is mistake in my script?

Can anyone guide me. I have also tried by using transform.rotation.z then also its not working.
Thanks you all for your support and help till now.

There is one problem here:

if(rotateArrow.transform.eulerAngles.z < 90 && rotateArrow.transform.eulerAngles.z > 270)

eulerAngles.z will never be both ‘< 90’ and ‘> 270’. I think you want and ‘||’ here.

But handling rotations like this may not get you want you want even after fixing this bug. It depends on what other rotations are going on. If the ‘z’ rotation is the only one done (both at edit time and runtime), then it will likely work.