Interface Type: Difference between revisions

From Resonite Wiki
mNo edit summary
m fix link
Line 4: Line 4:


== Example ==
== Example ==
An example of an interface type used within Resonite is [[Type:IButton|IButton]]. It is implemented by multiple button-like components like [[Button (Component)|Button]], [[PhysicalButton (Component)|PhysicalButton]] and [[TouchButton (Component)|TouchButton]]. All of those components implement the behavior of a '''''button that can be pressed''''' as defined in [[Type:IButton|IButton]]. Because of this, you can use either of them as a valid reference to plug into the "Button" input of the [[Button Events (ProtoFlux)|Button Events ProtoFlux node]], which requires a [[Global (ProtoFlux)|global]] of type [[Type:IButton|IButton]].
An example of an interface type used within Resonite is [[Type:IButton|IButton]]. It is implemented by multiple button-like components like [[Button (Component)|Button]], [[PhysicalButton (Component)|PhysicalButton]] and [[TouchButton (Component)|TouchButton]]. All of those components implement the behavior of a '''''button that can be pressed''''' as defined in [[Type:IButton|IButton]]. Because of this, you can use either of them as a valid reference to plug into the "Button" input of the [[Button Events (ProtoFlux)|Button Events ProtoFlux node]], which requires a [[ProtoFlux:Global|global]] of type [[Type:IButton|IButton]].

Revision as of 17:49, 9 February 2024

Interface types are reference types that don't refer to a specific component, but a C# Interface that can be implemented by one or multiple component classes. Interfaces are used to describe a specific common behavior that similar classed may want to implement. Because clases that implement a specific interface are required to implement the methods and properties defined in that interface, they can all be assigned to a variable of the interface type, making them very userful within Resonite.

In C# it is convention to start interface class names with the capital letter 'I'.

Example

An example of an interface type used within Resonite is IButton. It is implemented by multiple button-like components like Button, PhysicalButton and TouchButton. All of those components implement the behavior of a button that can be pressed as defined in IButton. Because of this, you can use either of them as a valid reference to plug into the "Button" input of the Button Events ProtoFlux node, which requires a global of type IButton.