Jump to content
  • Advertisement
Sign in to follow this  
4d69636861656c

Unity Windows in Unity

This topic is 819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to find a way of opening some windows with some info by pressing a button.

I have a loop that looks like this:

  if (System.SystemSize >= 5)
        {
            scrollPosition = GUI.BeginScrollView(new Rect(5, 100 + GUIPlanetPosition, 225, 400), scrollPosition, new Rect(0, 0, 50, 750));
            for (int i = 0; i < System.SystemSize; i++)
            {
                GUI.Button(new Rect(25, 100 + GUIPlanetPosition, 175, 40), Planet[i].PlanetName); // Press to show info in new window, each button shows different info
                GUIPlanetPosition = GUIPlanetPosition + 50;
            }
            GUI.EndScrollView();
        }

My question is if anyone knows of a way to do this in Unity. As far as I can tell, even if I manage to draw a new window, it would draw for 'i' times, so what could I use in this case?

Share this post


Link to post
Share on other sites
Advertisement

Without going to actually look, I believe the commonly used method is to have the window already created and toggle its 'active' state when you want it to appear.

Share this post


Link to post
Share on other sites

My question is if anyone knows of a way to do this in Unity. As far as I can tell, even if I manage to draw a new window, it would draw for 'i' times, so what could I use in this case?

Yes, don't use that system.

 

The old UI system was somewhat confusing to use and difficult to use well. It was designed with a different mindset from what most people thought about in a UI. It assumed the people using the UI system had a background in using lightweight self-processed UI elements rather than the event-driven model so many people prefer. It had many potentially-confusing quirks such as updating at least every video frame rather than updating every simulator update (those are generally different rates), and updating multiple times based on events being triggered (such as many mouse movements detected during a single graphics frame).  Trying to explain to someone why their UI code was called a seemingly random number of times over a different duration was often done poorly. Couple that with people not writing code that worked well with the UI system's design, treating it like an update and event-driven system and less like a self-processed probe, and the end result was that very few people used their old UI system well and they decided to rewrite it.

 

The rewritten UI system (linked in the post above) is in my view less elegant and more bloated internally, but externally it is easier for people to use in their more familiar model.  It takes more internal processing work, but most developers don't seem to mind in favor of more friendly development.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!