Table of Contents

Class BindEventAttribute

Binds an event to UdonSharp.UdonSharpBehaviour on build.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
public class BindEventAttribute : Attribute, IEquatable<BindEventAttribute>
Inheritance
BindEventAttribute
Implements
Inherited Members
Extension Methods

Remarks

There are several ways to use this attribute:

  • Field You can bind the event in the component in the field.
    [BindEvent(nameof(Button.onClick), nameof(_OnButtonClick)] Button button;
    public void _OnButtonClick() { ... }
  • Class You can bind the event in the component attached to the same game object.
    [RequireComponent(typeof(Button))]
    [BindEvent(typeof(Button), nameof(Button.onClick), nameof(_OnButtonClick))]
    public class ButtonHandler : UdonSharpBehaviour {
       public void _OnButtonClick() { ... }
    }

Constructors

BindEventAttribute(string, string)

public BindEventAttribute(string source, string destination)

Parameters

source string
destination string

BindEventAttribute(Type, string, string)

public BindEventAttribute(Type sourceType, string source, string destination)

Parameters

sourceType Type
source string
destination string

Properties

Destination

The destination event name. (The name of a public method with no arguments)

public string Destination { get; set; }

Property Value

string

Source

The source event name. (That is the property name of the event)

public string Source { get; set; }

Property Value

string

SourceType

The source type of the event.

public Type SourceType { get; set; }

Property Value

Type

Remarks

If the component type is different from the field type, you must specify the source type.

Methods

Equals(BindEventAttribute)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(BindEventAttribute other)

Parameters

other BindEventAttribute

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Returns a value that indicates whether this instance is equal to a specified object.

public override bool Equals(object obj)

Parameters

obj object

An object to compare with this instance or null.

Returns

bool

true if obj and this instance are of the same type and have identical field values; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer hash code.