• 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 Zapittaja · Apr 22, 2018 at 10:55 AM · popupmouseoverpop-up

Weird behaviour with PointerEventData, UI popup,Weird behaviour with PointerEventData, mirrored position.

Hello. We are creating a game that is basically generated on the canvas. Now I've encountered a problem with our inventory system that is generated with grid layout element. Everything else works, except our pop item description. It's location is mirrored. When I move my mouse to right, it shows the item on the left (on top of the left item). Middle item shows just as it's supposed to. Example picture

Should mention that our Canvas is set to "Screen Space - Camera", due to usage of postprocessing stack. And here is the code used on itemdescription:

 public class ItemDescriptionPopUp : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
 {
     //[HideInInspector]
     public Image ItemDescBackground;            // Reference to the popup text background, set in code
     //[HideInInspector]
     public Text ItemDescText;                   // Reference to the popup text, set in code
     public int itemIndex;                       // Reference to the item's switchlist index, set in inspector
     public Image itemIcon;                      // Reference to the item's icon, set in inspector
 
     private Item _item;                         // Current item
 
     // At the start, get the references from the objects.
     void OnEnable()
     {
         ItemDescBackground = gameObject.transform.Find("ItemImageBackground").GetComponent<Image>();
         ItemDescText = gameObject.transform.Find("ItemImageBackground").transform.Find("ItemImageText").GetComponent<Text>();
     }
 
     // When mouse is over the object..
     public void OnPointerEnter(PointerEventData eventData)
     {
         ItemDescBackground.gameObject.SetActive(true);      // Show background
         ItemDescText.gameObject.SetActive(true);            // Show text
     }
 
     // When mouse leaves the object..
     public void OnPointerExit(PointerEventData eventData)
     {
         ItemDescBackground.gameObject.SetActive(false);     // Hide background
         ItemDescText.gameObject.SetActive(false);           // Hide text
     }
 
     // Setup the item's information from the list (only gets the items that are TRUE on gamecontroller's switch list)
     public void Setup(Item currentItem, InventoryPage currentInventory)
     {
         if (currentItem.itemSwitchIndex == 1)
         {
             _item = currentItem;
             ItemDescText.text = "Cigarette count: " + GameController.gameController.cigaretteCount;
             itemIndex = _item.itemSwitchIndex;
             itemIcon.sprite = _item.itemIcon;
         }
         else
         {
             _item = currentItem;
             ItemDescText.text = _item.itemDescText;
             itemIndex = _item.itemSwitchIndex;
             itemIcon.sprite = _item.itemIcon;
         }
     }
 }



Thank you for the help, I've been trying to figure out this for few days now.

please-help.png (34.8 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Zapittaja · Apr 23, 2018 at 10:59 PM

Found the root of the problem. The code itself is working. We were the ones that were broken.

We had forgotten a inventory refresh function inside a Update call. So the inventory got refreshed by the Update() speeds. And this caused the weird behaviour.

Leaving this ticket here in case someone runs into same problem :)

Comment
Add comment · Share
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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

79 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 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 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 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

EditorGUILayout.Popup() ignores repetitive Strings in the Array 1 Answer

Activate Gui Texture On Trigger Activate 1 Answer

How to create a popup when hovering over specific words in UI.text 1 Answer

Text box pop up on mouseover 1 Answer

Just downloaded Unity and my 30-day trial is already expired? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges