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 malkere · Feb 22, 2015 at 12:42 PM · uicanvasinventoryrpgtooltip

New UI Is active but not drawing

I'm using a tooltip script to enable/disable the tooltip window when it's over slots that contain a script telling it to do so (inventory/loot/equipment, etc.) To keep the tooltip from erroneously staying open if the inventory for example is closed I have:

 PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.SetActive(false);

turning the tooltip off when the inventory window gets OnDisable(). The problem is then turning the inventory back on... It won't... I can see it enabling properly in the inspector and the canvas outline/wireframe is even drawing, all of its subcomponent are properly active, but it draws nothing in the game window nor scene view. If the tooltip is not active when I close the inventory I can open/close it without draw problems, so I assume it has something to do with the tooltip, but don't see anything amiss... If I change something else, like disabling the whole UI and re-enable it via the inspector then it will draw fine for me...

here's the entire tooltip script:

 public class TooltipUI : MonoBehaviour {
 
     public Text tooltipText;
 
     void OnEnable () {
         transform.position = new Vector3(Input.mousePosition.x + 20, Input.mousePosition.y, 0);
     }
 
     void Update () {
         transform.position = new Vector3(Input.mousePosition.x + 20, Input.mousePosition.y, 0);
     }
 
     public void SetText (string str) {
         tooltipText.text = str;
     }
 }

here is the line from Update() in the PlayerInput script making the action:

 if (Input.GetKeyDown(KeyCode.I)) { PlayerData.mainUI.GetComponent<MainUI>().inventoryUI.SetActive(!PlayerData.mainUI.GetComponent<MainUI>().inventoryUI.activeSelf); }

there's really nothing very difficult going on. The two heirarchies are as follows:

MainUI -> Windows -> InventoryUI

MainUI -> TooltipUI

this keeps the tooltip always ontop of the Inventory.

the ContainerSlot script on the inventory slots has the following script, though it shouldn't make any difference as to whether the inventory window will render or not...??

 public void OnPointerEnter (PointerEventData eventData)    {
         if (location == loc.inventory) {
             if (PlayerData.inventory[slot] != null) {
                 PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.GetComponent<TooltipUI>().SetText(PlayerData.inventory[slot]._item.Tooltip());
                 PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.SetActive(true);
             }
         }
         else if (location == loc.equipment) {
             if (PlayerData.equipment[slot] != null) {
                 PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.GetComponent<TooltipUI>().SetText(PlayerData.equipment[slot]._item.Tooltip());
                 PlayerData.mainUI.GetComponent<MainUI>().tooltipUI.SetActive(true);
             }
         }
     }

I R confused, bug?

Comment
Add comment · Show 3
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 Mmmpies · Feb 22, 2015 at 01:03 PM 0
Share

First thing to do is add some Debug.Logs in there to make sure that OnPointerEnter is firing:

 Debug.Log("Set Active in loc.inventory called");
 
 // and in the equipment
 
 Debug.Log("Set Active in loc.equipment called");

See if it's actually being called.

avatar image malkere · Feb 23, 2015 at 10:07 AM 0
Share

everything is being called fine. the loc variable lets the TooltipUI window know whether it's handling inventory items or character equipment items or loot window items, etc. doesn't actually affect the EquipmentUI. I can run in un-maximized and see the window turning on and off fine. I can pause and see that it (the EquipmentUI window), all of it's parents, and all of children are properly active. The outline is drawing, but it's contents are all invisible. see attached pics... kind of hard with just words.

alt text

alt text

avatar image malkere · May 20, 2015 at 01:10 PM 0
Share

I still have this problem.

 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.I)) { PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().inventoryUI.SetActive(!PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().inventoryUI.activeSelf); }
 
 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.C)) { PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().equipmentUI.SetActive(!PlayerData.mainUI.GetComponent<$$anonymous$$ainUI>().equipmentUI.activeSelf); }


It's very simple script, I don't have to push them at the same time or anything. Yet sometimes they completely stop responding. As posted above, they are properly activating/deactivating in the inspector, but stop actually drawing themselves.

It's to the point where I'm going to have to start just refreshing the whole GUI to try and stop it. I'll go post on the bug forum a link to here. If it were to happen in build it would be a complete gamebreaker...

0 Replies

· Add your reply
  • Sort: 

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

22 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GetComponent() Problem with getting value. 1 Answer

Why do contents of nested Panel spill outside parent? 0 Answers

How do I make an instantiated UI GameObject visible without parenting it to the Canvas? 1 Answer

Close UI using Canvas Group 1 Answer

OnPointerExit Not Being Triggered 1 Answer


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