• Advertisement
Sign in to follow this  

Unity Windows in Unity

This topic is 640 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;

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

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

Since (4.6ish?) Unity has a new UI system, based less on code and more on the scene editor. There are a lot of different UI elements that can be put on a canvas that renders over the screen, and these could be set to enable/disable with a script.


UI component tutorials:


Edited by SpikeViper

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
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By nihitori
      The Emotional Music Vol. I pack focuses on beautiful and esoteric orchestral music, capable of creating truly emotive and intimate moods. It features detailed chamber strings, cello and piano as the main instruments, resulting in a subtle and elegant sound never before heard in video game royalty-free music assets.

      The pack includes 5 original tracks, as well as a total of 47 loops based on these tracks (long loops for simple use and short loops for custom / complex music layering).

      Unity Asset Store link: https://www.assetstore.unity3d.com/en/#!/content/107032
      Unreal Engine Marketplace link: https://www.unrealengine.com/marketplace/emotional-music-vol-i

      A 15 seconds preview of each main track is available on Soundcloud:
    • By RoKabium Games
      Another one of our new UI for #screenshotsaturday. This is the inventory screen for showing what animal fossils you have collected so far. #gamedev #indiedev #sama
    • By eldwin11929
      We're looking for programmers for our project.
      Our project is being made in Unity
      -Skills in Unity
      We're looking for programmers who can perform a variety of functions on our project.
      Project is a top-down hack-and-slash pvp dungeon-crawler like game. Game is entirely multiplayer based, using randomized dungeons, and a unique combat system with emphasis on gameplay.
      We have a GDD to work off of, and a Lead Programmer you would work under.
      Assignments may include:
      -Creating new scripts of varying degrees specific to the project (mostly server-side, but sometimes client-side)
      -Assembling already created monsters/characters with existing or non-existing code.
      -Creating VFX
      -Assembling already created environment models
      If interested, please contact: eldwin11929@yahoo.com
      This project is unpaid, but with royalties.
      Additional Project Info:
      Bassetune Reapers is a Player-verus-Player, competitive dungeon crawler. This basically takes on aspects of dungeon crawling, but with a more aggressive setting. Players will have the option to play as the "dungeon-crawlers" (called the 'Knights', or "Knight Class", in-game) or as the "dungeon" itself (literally called the 'Bosses', or "Boss Class", in-game). What this means is that players can choose to play as the people invading the dungeon, or as the dungeon-holders themselves.
      Key Features:
      -Intense, fast-paced combat
      -Multiple skills, weapons, and ways to play the game
      -Tons of different Bosses, Minibosses, creatures and traps to utilize throughout the dungeon
      -Multiple unique environments
      -Interesting, detailed lore behind both the game and world
      -Intricate RPG system
      -Ladder and ranking system
      -Lots of customization for both classes s of customization for both classes
    • By RoKabium Games
      Custom coffee mugs have arrived... More caffeine!
      Have a great weekend everyone! 
      #gamedev #indiedev #sama #caffeine
    • By Atwo Studios
      Hey guys,

      Anthony here from Atwo Studios bringing you some new updates for the new year!
      In this video I go over our game ROY, the new games and some general updates to the company!

      If you have not checked out ROY feel free to give it a try! Many people have said they enjoyed the game thus far!
      ROY: https://goo.gl/o6JJ5P
  • Advertisement