Previous version UI Error after upgrade

Zaddo

Active member
Hi,

I am not sure how to fix this. I have a problem with my UI after upgrading.

The m_Canvas variable is null in ItemViewSlotPanelToTooltip. At line 95, in initialize it tries to set the variable:
C#:
            if (m_Canvas == null) {
                m_Canvas = GetComponentInParent<Canvas>();
            }

But the ancester whith a canvas "Inventory Canvas" does not get returned by the GetComponentInParent.

This causes the PlacePanel to crash whenever the mouse hovers over the grid at this line:
1642755332911.png

This is what my hierarchy looks like.

1642755008409.png

Is there a way to fix this?
 
Last edited:
Sorry, I rushed this question and I shouldn't have. I didn't want to miss todays support window as I am trying to complete the upgrade tonight, so I can get back with other things tomorrow.

I don't know why the GetComponentInParent is not working. It should find the canvas on the "Inventory Canvas" game object.
Edit: I think it might be because, this component is on "Item Description Panel" and it is disabled.

As a workaround, I just changed the code in ItemViewSlotPanelToTooltip.Initialize to this:

C#:
            if (m_Canvas == null) {
                //m_Canvas = GetComponentInParent<Canvas>();
                Transform ancestorSearch = transform;
                while (m_Canvas == null && ancestorSearch.parent != null)
                {
                    m_Canvas = ancestorSearch.parent.GetComponent<Canvas>();
                    if (m_Canvas != null) break;
                    ancestorSearch = ancestorSearch.parent;
                }
            }
 
Top