Hello Guys, I would like to ask a question about my script for the rotation of my 2D RectTransform object. Here is my C# Script:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class QTileViz : MonoBehaviour {
public Queuing queuing = new Queuing();
public Image[] qTiles;
public RectTransform[] rTiles;
public Sprite[] tileSprite;
ArrayList qList;
ArrayList rList;
// Use this for initialization
void Start () {
qList = queuing.queue.GetList ();
rList = queuing.queue.GetYRotations ();
}
// Update is called once per frame
public void UpdateViz () {
rList = queuing.queue.GetYRotations ();
print ("List Size:" + rList.Count);
//for (int i = 0; i < rList.Count; i++)
// print ("index " + i + ": " +rList *);*
-
for (int i = 0; i < 5; i++) {*
qTiles .sprite = tileSprite [(int)qList ];
_ print ("index " + i + ": " +rList );_
//rTiles .Rotate (0, 0, (int)rList );
rTiles .Rotate(new Vector3 (0, 0, (int)rList ));
* }//for*
* }*
}
The values I’m passing to the index at my print statement
print ("index " + i + ": " +rList *);
*
*is correct and I’m getting the proper numbers I should get and printed. which means my 'QueueImplementation is correct. Here's the console output*_</em></em></em></em></em></em></em> <em><em><em><em><em><em><em>_*[76697-console.png*_</em></em></em></em></em></em></em></em></em>|76697]*_</em></em></em></em></em></em></em> <em><em><em><em><em><em><em>_*But when I try to pass it to the RectTransform as the
z value, I'm getting wrong results for its rotation.*_</em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em>
rTiles .Rotate(new Vector3 (0, 0, (int)rList ));*_</em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em>_*And this will be the result:*_</em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em>_*[76698-hek.png*_</em></em></em></em></em></em></em></em></em>|76698]*_</em></em></em></em></em></em></em></em></em> <em><em><em><em><em><em><em><em><em>_* <em><em><em><em><em><em><em><em><em>_* <em><em><em><em><em><em><em><em><em>_*Note that the last value or the last 4th index from my queue should be for the 5th
QueueTileGameObject and the last index value from the queue is
0and I don't even know where I got that
90.00001and it is not from the
index 0from my queue because the
z valueon the
RectTransform[]just making random numbers that is close to my types of
z` which is
0,
90,
180,
270
I hope you can inspect my code and tell me what’s going on or is it at Unity problem?
I hope you understand. And sorry for my long question. I can’t find any other way to explain this. Sorry for bad English.
TIA
Cheers!_