Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by rohan bhangui · Oct 09, 2011 at 07:46 PM · javascriptgui

gui rotational issues

i am try to rotate a gui around a certain position but i am having trouble with the code.......here is what keeps happening. picture of problem here

i want that that circled gui in the case.....but when ever im moving around ( do a dive or something) it always finds some way of getting out of the gui (ignore the background grey gui and the compass one)

this is the script im using to do the horizon thing:

 //Horizon Instrument
 
 var X:float=1366;
 var Y:float=768;
 
 var  mainskin : GUISkin; //This is to connect the script with the guiskin
 
 var bgImage : Texture2D; // background image that is 256 x 32
 var ypos : float= -24;
 var xpos : float= -25;
 var fgImage : Texture2D; // foreground image that is 256 x 32
 var pitch = 0; // a float between 0.0 and 1.0
 var tilt:float=0.0;
 
 function OnGUI () {
 
 GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3(1.0*Screen.width/X, 1.0*Screen.height/Y, 1.0));
 
 GUI.skin =  mainskin; //The guiskin in use
 
     //Frontneigung || Pitch forward backward
     //210 ist der Zentrierpunkt in der Textur, der Horizont auf Null || 210 is the centerpoint in the texture, the horizon at 0
     if (moveairplane.rotationx < 180) pitch = -210-moveairplane.rotationx;
     else pitch = -210-moveairplane.rotationx+360;
     // Seitenneigung || Tilt sidewards
     tilt=moveairplane.rotationz;
 
     // Create one Group to contain both images
     // Adjust the first 2 coordinates to place it somewhere else on-screen
     GUI.BeginGroup (Rect (Screen.width*5/8, Screen.height/10, Screen.width*0.8, Screen.height*0.8 ));
 
     // Create a second Group which will be clipped
     // We want to clip the image and not scale it, which is why we need the second Group    
     GUI.BeginGroup (Rect (0,0,82,90));
 
     // Draw the foreground image
     //---------------------------------------------------------
     //Here comes the rotation
     var matrixBackup:Matrix4x4  = GUI.matrix;
     //var thisAngle:float = tilt;
     var pos:Vector2 = Vector2(0,0); // rotatepoint in texture. 
     
     GUIUtility.RotateAroundPivot(tilt, pos);
 
     var thisRect:Rect = Rect(0,pitch,84,512); //x position, y position, size x, size y
 
     GUI.DrawTexture(thisRect, fgImage);
     GUI.matrix = matrixBackup; 
     
     // End group
     GUI.EndGroup ();
     // Draw the background image. In front of the other texture. That`s why it is here.
     GUI.DrawTexture (Rect (xpos,ypos,185,185), bgImage);
     // End group
     GUI.EndGroup ();
         
     
 }


can anyone help me figure this out?

Comment
Add comment · Show 1
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
avatar image syclamoth · Oct 09, 2011 at 10:43 PM 0
Share

You should really be using GUIUtility.RotateAroundPivot- it's there to help, and it'll fix any problems you have with weird matricies.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

GuiTexture For Jump A Character 0 Answers

The first object in selection grid can't be activated. Why? 1 Answer

Cant get my gui in the quiwindow to load there functions... 1 Answer

If statement only work once? 1 Answer

Temperature Script? 3 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