Duplicating Unity's mystic Interface power

后端 未结 3 611
刺人心
刺人心 2021-01-06 04:07

Unity3D has an interface like this, for any Component on a MonoBehavior you just do this:

public class LaraCroft:MonoBehaviour,IPointerDownHandler
  {
  publ         


        
3条回答
  •  广开言路
    2021-01-06 04:57

    You say you don't want to do a daemon but that is exactly what Unity is doing. The StandaloneInputModule class that is automatically added when you add a UI component is that daemon.

    What you can do is create a new class derived from one of the classes derived from BaseInputModule (likey PointerInputModule for your case) that can handle listening to trigger and raising your extra events then add that new class to the EventSystem object.

    See the Unity manual section on the Event System for notes on how to create your custom events and more details on what the input module does.

提交回复
热议问题