If I continue with the C # interface, can I eat?

In this question, I mention Unity3D, but is commonly used in C #.

Unity3D has an interface that looks like this.

public class SomeRobot:MonoBehaviour, IPointerDownHandler
    {
    public void OnPointerDown(PointerEventData data)
        {
        Debug.Log("Gets called whenever someone touches the screen...");
        }

There are no problems so far.

I create my own interface.

public interface IFUHandler:IPointerDownHandler
    {
    void OnBlah (PointerEventData data);
    }

Suppose I have a daemon or something else that causes OnBlah to interface users.

public class SomeRobot:MonoBehaviour, IFUHandler
    {
    public void OnBlah(PointerEventData data)
        {
        Debug.Log("Gets called when blah happens...");
        }

There are no problems so far. BUT

public class SomeRobot:MonoBehaviour, IFUHandler
    {
    public void OnBlah(PointerEventData data)
        {
        Debug.Log("Gets called when blah happens...");
        }
    public void OnPointerDown(PointerEventData data)
        {
        Debug.Log("this DOES still get called also...");
        }

In fact, OnPointerDownit is still being called. Which makes sense.

BUT ... is there a way for my interface to use OnPointerDown calls ?

So that the consumer who subscribes to IFUHandleractually does not receive calls OnPointerDown?

(But, of course, my challenges OnBlah.)

Or am I just suffering from the thought of "TMIOOK"? (Tied to themselves in OO-nodes of thinking :))

+4
1

: .

:

  • IPointerDownHandler, . , ?

  • public class BaseFUHandler : MonoBehaviour, IFUHandler
    {
    
    public abstract void OnBlah(PointerEventData data);
    
    public void OnPointerDown(PointerEventData data)
    {
        //Gets called, but nothing hapends.
    }
    
+4

Source: https://habr.com/ru/post/1660631/


All Articles