playMaker

Author Topic: Unity 4.6 GUI elements not updating with Playmaker  (Read 8397 times)

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Unity 4.6 GUI elements not updating with Playmaker
« on: March 03, 2015, 11:33:00 PM »
Hello everyone,

I'm setting up the GUI for my project. I notice that in the inspector, values are changing as they should & FSMs are functioning properly.

The only hitch is the GUI's values are not updating on screen like texture & text.

Please help me fix this.

Thanks in advance

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #1 on: March 04, 2015, 02:39:50 AM »
Hi,

 that's very odd, are you sure you are editing the right GameObject? or maybe you locked the inspector?

 Bye,

 Jean

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #2 on: March 04, 2015, 07:19:19 AM »
Can you post screenshots of how you have it setup?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #3 on: March 04, 2015, 08:30:44 AM »
Hi,

 that's very odd, are you sure you are editing the right GameObject? or maybe you locked the inspector?

 Bye,

 Jean

Jean,

None of the objects are locked...I've also had to add the old guiText onto a text object.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #4 on: March 04, 2015, 08:38:52 AM »
UI and GUI are not the same. =)

GUI is legacy, so the actions for GUI don't work for the new UI stuff. Try the UI actions.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #5 on: March 04, 2015, 08:42:27 AM »
UI and GUI are not the same. =)

GUI is legacy, so the actions for GUI don't work for the new UI stuff. Try the UI actions.

I attached the wrong image for the inspector.

I do have the new Text element there but Playmaker was asking for the GUIText, so I added it.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #6 on: March 04, 2015, 08:50:56 AM »
You may be having some issues mixing GUI components with the new UI Canvas system, they might be conflicting with the position of the GUI element as the GUI Text Component tries to put itself at the pixel coordinates that you specify, while the UI Canvas tries to organize and scale its child objects based on the RectTransform.

You should just commit to using either UI or GUI to simplify matters and avoid issues.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #7 on: March 04, 2015, 12:08:50 PM »
You may be having some issues mixing GUI components with the new UI Canvas system, they might be conflicting with the position of the GUI element as the GUI Text Component tries to put itself at the pixel coordinates that you specify, while the UI Canvas tries to organize and scale its child objects based on the RectTransform.

You should just commit to using either UI or GUI to simplify matters and avoid issues.

Lane, I would prefer using new standards-- the GUI is set up that way.

However, when I added the action, Set GUI Text (per tutorial), it looked for the old GUIText object. That's when I added a GUIText.

The inspector does show values being updated for GUIText, but nothing on screen or the new text element.

Shouldn't the variable be passed to the text element?

I don't know what I'm doing wrong regarding the GUI set up.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #8 on: March 04, 2015, 12:26:03 PM »
GUIText is Legacy, it has nothing to do with the UI. You are updating the GUI Text Component but displaying the UI Text component on the screen. The old tutorials regarding GUI are not relevant for the new UI.

If you want to update the UI Text component (which is what you are showing on screen here) you can use the UI Actions (called "uGui" around here) or do it with the Set Property action. The GUI Text component is serving no purpose here and should be removed.

Does this make sense?

We should really make a post to clarify this whole GUI/UI situation...
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #9 on: March 04, 2015, 02:58:44 PM »
GUIText is Legacy, it has nothing to do with the UI. You are updating the GUI Text Component but displaying the UI Text component on the screen. The old tutorials regarding GUI are not relevant for the new UI.

If you want to update the UI Text component (which is what you are showing on screen here) you can use the UI Actions (called "uGui" around here) or do it with the Set Property action. The GUI Text component is serving no purpose here and should be removed.

Does this make sense?

We should really make a post to clarify this whole GUI/UI situation...

It makes perfect sense...I'll head over to add-ons & get uGUI. Unless I'm mistaken, Unity Object > Set Property action still looks for guiText.Text.

Thanks for the help...

-Mark

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #10 on: March 04, 2015, 03:10:53 PM »
GUIText is Legacy, it has nothing to do with the UI. You are updating the GUI Text Component but displaying the UI Text component on the screen. The old tutorials regarding GUI are not relevant for the new UI.

If you want to update the UI Text component (which is what you are showing on screen here) you can use the UI Actions (called "uGui" around here) or do it with the Set Property action. The GUI Text component is serving no purpose here and should be removed.

Does this make sense?

We should really make a post to clarify this whole GUI/UI situation...

It makes perfect sense...I'll head over to add-ons & get uGUI. Unless I'm mistaken, Unity Object > Set Property action still looks for guiText.Text.

Thanks for the help...

-Mark

I'm not certain if we have a .unitypackage published for uGui actions just yet. It was put onto Ecosystem but if you're using 5.0 it may filter the results out in a version check glitch. You can find them on the git rep here if necessary.

In reference to Set Property, you can manipulate any public variable in a Component/Script. There's no assumed targetting, you have to specifically tell it which script you want to target so its really quite straightforward and completely flexible. In the above screenshot you're targetting the GameObject, not the script. Lock the Graph View and drag the actual script to the slot. There is a YouTube Tutorial on using it.

Sorry this is confusing, we're working to make it simpler.
« Last Edit: March 04, 2015, 03:12:32 PM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #11 on: March 04, 2015, 05:28:22 PM »
I'm not certain if we have a .unitypackage published for uGui actions just yet. It was put onto Ecosystem but if you're using 5.0 it may filter the results out in a version check glitch. You can find them on the git rep here if necessary.

There aren't any uGUI actions on the current version. I was looking for it.

In reference to Set Property, you can manipulate any public variable in a Component/Script. There's no assumed targetting, you have to specifically tell it which script you want to target so its really quite straightforward and completely flexible. In the above screenshot you're targetting the GameObject, not the script. Lock the Graph View and drag the actual script to the slot. There is a YouTube Tutorial on using it.

Sorry this is confusing, we're working to make it simpler.

No worries, thanks for being patient & helping out a newbie.

Please bear with me, I'm doing my best to understand this. I don't know what script you're referring to- do I need to create a script (attached to the player) to hold variables, item pick-ups etc.?

Referencing video:


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #12 on: March 04, 2015, 06:08:24 PM »

Up to about the 3:00 mark is what is most relevant for you in this case, but after that is useful too for understanding components and runtime scenarios.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #13 on: March 04, 2015, 06:56:49 PM »
Thanks Lane, will go through it

scr33ner

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Unity 4.6 GUI elements not updating with Playmaker
« Reply #14 on: March 05, 2015, 05:12:35 PM »
I watched the video. From my understanding, I need some code.

I created this:
Code: [Select]
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
/// <summary>
/// Player stats:
/// Use this script to display player stats with
/// new Unity GUI elements. Variables should be
/// received from gObjHealthMgr FSM.
/// </summary>
public class PlayerStatDisplay : MonoBehaviour
{
        //GUI elements open to inspector
public Text guiTxtHealth;
public Text guiTxtLifeCounter;
public Text guiTxtItemCounter;
public object guiHealthTxtr;

        //variables in FSM
public int playerHealthInt;
public int playerLives;
public string playerHealthStr;
public string playerLifeStr;

// Update is called once per frame
void Update ()
{
guiTxtHealth.text = playerHealthStr;
guiTxtLifeCounter.text = playerLifeStr;
}
}

I've attached this script to the gameObject with the FSM as well as the GUI elements.

Code: [Select]
playerHealthStr & playerLifeStr returns nothing

I even tried adding Get Component action to make sure the script would get called on the set up & nothing.

With those methods not working I tried to send the string values to the script (sendMsg.jpg).

In theory, those values should be reflected on the text elements.
but in runtime, nothing is displayed (healthMgrInspector.jpg).


« Last Edit: March 05, 2015, 08:15:36 PM by scr33ner »