Tooltipspawner

the two methods in the itemtooltipspawner are public override. what does override do?
in the tooltipspawner script we use the two methods from itemtooltipspawner with public abstract void. Does this mean it gets hold of the methods from the itemtooltipspawner since that script inherits from tooltipspawner?

and last the two methods are exectued inside IPointerEnterHandler and IPointerExitHandler. are these methods executed when these events happen?

1 Like

In C#, the override keyword is used to indicate that a method in a derived class is intended to override a method with the same signature in the base class. This means that when an instance of the derived class is created, calling the overridden method will call the implementation in the derived class instead of the base class.

So, in the ItemTooltipSpawner script, when you mark the two methods with public override, you’re indicating that these methods are overriding methods that were declared in a base class (in this case, the TooltipSpawner class).

Regarding your second question, the abstract keyword in C# is used to indicate that a method does not have an implementation and must be implemented by any non-abstract derived class. In the TooltipSpawner class, the two methods are marked as public abstract void, which means that any derived class must provide an implementation for these methods.

And yes, in Unity, the IPointerEnterHandler and IPointerExitHandler interfaces are used to handle mouse pointer events on UI elements. So, when a pointer enters or exits an element that has an attached script implementing these interfaces, the corresponding methods (OnPointerEnter and OnPointerExit) will be executed. In the ItemTooltipSpawner script, these methods are used to show and hide the tooltip when the mouse pointer enters or exits an item.

hope this helps!

5 Likes

I don’t have much to add to that. Excellent answers.

1 Like

yes that made it clear thnx!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms