Let’s say I have this code:
class A
{
public void OnPointerEnter(PointerEventData eventData)
{
StartHover();
}
public void OnSelect(BaseEventData eventData)
{
StartHover();
}
public void OnPointerExit(PointerEventData eventData)
{
StopHover();
}
public void OnDeselect(BaseEventData eventData)
{
StopHover();
}
void StartHover()
{
Debug.log("A");
}
void StopHover()
{
Debug.log("A");
}
}
class B : A
{
void StartHover()
{
Debug.log("B");
}
void StopHover()
{
Debug.log("B");
}
}
If I now make a script of class B attached to a button will the onPointerEnter functions still call the starthover in class B? Is this a good example of how to use inheritance? (I have multiple interface objects that should have some logic upon interaction, but some of it is common). Do I understand correctly that simply redefining the function I will get “BA” but using new keyword I’ll get only “B” because the old version is overriden?