playMaker

Author Topic: Problem with GUI Elements  (Read 5272 times)

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Problem with GUI Elements
« on: August 19, 2015, 04:10:30 PM »
Go I have a rather unique dilemma. I create a Currency counter using a GUI Text component and works fine until I make it a prefab and then it stops. I want it to remain constant but it resets when the scene changes and the only way to carry it over is with Prefabs. When I hit play, I set it to Maximize on play and it disappeared entirely. Has anyone else had this problem? I found no rational explanation for it, but if it happened there it would happen in the final product. What can I do to fix this problem?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Problem with GUI Elements
« Reply #1 on: August 20, 2015, 02:18:54 AM »
hi,
A prefab can not communicate directly with scene objects so that might be the reason, i need more info of what actions you are using

for the disappearing : Maybe when maximized it gets off screen, try testing and set it to the center of your screen

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Re: Problem with GUI Elements
« Reply #2 on: August 20, 2015, 06:45:56 PM »
Here's my basic setup. Collecting a coin adds 10 points to the counter. Obviously I can't pre-animate a counter, so this is the only way to do it. I'm using a GUI Text for the counter itself. It works fine, but I'm trying to get it to remain constant so that it doesn't reset once the player leaves the scene or starts a new Stage. I basically broke the game down into different scenes.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Problem with GUI Elements
« Reply #3 on: August 20, 2015, 07:03:55 PM »
Hi,
you could safe you score @ end of scene and load @ start of next scene?

with playerprefs (free and build-in) or with easy save 2 (not free but with encryption)

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Re: Problem with GUI Elements
« Reply #4 on: September 18, 2015, 09:27:06 PM »
This is a rather old issue, so I'll just put it here since it ties into the same problem. I've noticed that GUI Text elements don't scale to the size of the screen. I'm using GUI text for my scoring system, since I can't possibly pre-animate one. When I hit play, i have the screen set to Maximize,and the GUI text is there, no problem, but then I run a build and in the build the text isn't there anymore. After experimenting, I've noticed it doesn't stay constant to the screen, no matter what resolution you use. Is there anyway to keep GUI text from floating or disappearing off the screen? The screenshots are an example.
« Last Edit: September 18, 2015, 09:34:01 PM by Seiryu33 »

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Re: Problem with GUI Elements
« Reply #5 on: September 18, 2015, 09:50:58 PM »
Second of two

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Problem with GUI Elements
« Reply #6 on: September 19, 2015, 01:59:49 AM »
Hi,
what version of unity are you using?

if lower than 4.6 i suggest to upgrade (make a backup of your project folder before you do) to 4.6 or up and use ugui here is a good tutorial.

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Re: Problem with GUI Elements
« Reply #7 on: September 22, 2015, 06:05:44 PM »
I'm using 5.0. I managed to partly fix the problem by running a build with the specific resolution that fits it, but that won't work if I intend to run the game on several devices with different resolutions.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Problem with GUI Elements
« Reply #8 on: September 23, 2015, 01:34:29 AM »
Hi,
if you want to use different resolutions you really should try ugui so you can "stick you scoreboard in the corner and automatically re sizing it depending on the resolution.

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Re: Problem with GUI Elements
« Reply #9 on: October 26, 2015, 08:20:45 AM »
So I experimented with Ui on my counter and while it does scale to the size of the screen, it doesn't work with my current set up. The screenshots are my basic set up. Not much different from my previous one but how do I link this up to a Ui component?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Problem with GUI Elements
« Reply #10 on: October 26, 2015, 03:00:53 PM »
Hi,
You need to get the Ugui Package on the EcoSystem

if you want to use buttons you can check this tutorial :


Seiryu33

  • Full Member
  • ***
  • Posts: 133
Re: Problem with GUI Elements
« Reply #11 on: October 29, 2015, 03:48:00 AM »
I have the most recent uGui package installed. How do I get it to update my score, like small coins being worth 10 points and so on? Apparently, to update uGui text you have to the Set Property action but I don't see the option for text. Am I missing a component?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Problem with GUI Elements
« Reply #12 on: October 29, 2015, 03:55:25 AM »
Hi,
if you have the ugui package you should have the action "uGui Text Set Text"

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Re: Problem with GUI Elements
« Reply #13 on: November 04, 2015, 12:06:15 PM »
Here's the crux of the problem I'm having with using UI components. As you can see from the screenshots, my Set Property action is only giving me a handful of options to adjust the properties for at all. It's not just UI components either. These are the only options for any object I try to use it on. Every tutorial I've seen calls for using the Set Property action, but have far more options available. Am I missing an add-on some where?