Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by rukawan44 · Aug 22, 2016 at 06:45 PM · c#rotationrecttransformz-axis

Passing Vector3 Values to RectTransform.Rotation

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 [i]);
 
         for (int i = 0; i < 5; i++) {
             qTiles [i].sprite = tileSprite [(int)qList [i]];
             print ("index " + i + ": " +rList [i]);
 
             //rTiles [i].Rotate (0, 0, (int)rList [i]);
             rTiles [i].Rotate(new Vector3 (0, 0, (int)rList [i]));
         }//for
     }
 }

The values I'm passing to the index at my print statement

print ("index " + i + ": " +rList [i]);

is correct and I'm getting the proper numbers I should get and printed. which means my 'Queue` Implementation is correct. Here's the console output

alt text

But when I try to pass it to the RectTransform as the z value, I'm getting wrong results for its rotation.

rTiles [i].Rotate(new Vector3 (0, 0, (int)rList [i]));

And this will be the result:

alt text

Note that the last value or the last 4th index from my queue should be for the 5th QueueTile GameObject and the last index value from the queue is 0 and I don't even know where I got that 90.00001 and it is not from the index 0 from my queue because the z value on 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!

console.png (53.6 kB)
hek.png (31.9 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by TashaSkyUp · Mar 15, 2017 at 09:26 PM

Just taking a stab here. Do the elements of in rTiles[] already have a Z rotation? The function .Rotate rotates a transform further, it does not set the rotation.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

224 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Torrent rotation to face an object rotating on Z axis only. Define facing axes as X 1 Answer

How do you change your z axis in a movement script. 1 Answer

How to limit only one axis rotation? c# 1 Answer

Limiting gameObjects rotation on Zaxis giving wierd results 1 Answer

How to move an object on a 2d plane forward, backward, and in a rotation about the mouse position? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges