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
0
Question by pasoftdev · Oct 17, 2012 at 10:31 PM · guiscaleonguimatrixexecution order

Is there a way to set a GUI.matrix that will be used by all OnGui() functions?

Hello,

I'm making my own gui library using mvc pattern, since each object I'm making (a button for example) has its own data/logic and its own OnGui function, I was wondering if there's a way to set a scale matrix on a script so that each OnGui function use that matrix or do I need to set this scale matrix on the beginning of each OnGui function? I've tried setting this scale matrix on a script and I made it execute as the first script by setting its priority on Project Settings-> Script execution order, the scale matrix is successfully applied however it works only for objects being drawn in the same script, objects being drawn from other OnGui use the default matrix, to make them use that matrix I need to reapply it in the beginning of the OnGui. any better workaround?

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
1

Answer by Bunny83 · Oct 17, 2012 at 10:55 PM

Unity prepares the environment for each callback it's going to invoke. So the answer is: Yes, you need to set it in each OnGUI function seperately.

The static nature of a lot of things in Unity might make you think it's a statemachine. Well, it actually is, but it's not completely under your control. Unity uses those variables to provide state information for the current execution of a callback. The Event class, which is the most important thing in OnGUI, works the same way. Camera.current is another example

Comment
Add comment · Show 3 · 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
avatar image pasoftdev · Oct 17, 2012 at 11:28 PM -1
Share

Thank you for your reply. So I guess I'll leave it for each OnGUI and make some tests to see the impact it has on the performance, if it is unacceptable I'll rewrite my system to have a single OnGUI. :)

avatar image whydoidoit · Oct 17, 2012 at 11:48 PM 0
Share

If you are worried about performance, don't use OnGUI! Performance isn't really it's strong point...

You could always store your matrix in a static variable and just put it in place on each OnGUI call.

avatar image pasoftdev · Oct 20, 2012 at 04:46 PM -1
Share

of course I won't recalculate the matrix every time :) I know OnGUI is not that perfor$$anonymous$$g yet I found it good enough for a not too complex gui, also by enable/disable on-demand those scripts I got some very good results :)

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

11 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

Related Questions

Scaling problem for mobile 0 Answers

How can I scale the insides of a ScrollView 0 Answers

GUI - Scale GUIs According to Resolution 6 Answers

Scaling the GUI using a matrix issues 2 Answers

GUI.Matrix Problems 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