[Basic Type](../groups/Basic Type.Basic Type.md) / MulticastGameObjectDelegate
MulticastGameObjectDelegate Class
Broadcast agency
Usage example: create a script named "MultidelExample", open the script, enter the following code to save, run the game, and print out 5.
ts
@Component
export default class ActionExample extends Script {
// Example function that satisfies the GameObjectDelegateFuncType constraint
public async addNumbers(object: GameObject): Promise<void> {
console.log(object.gameObjectId);
}
protected async onStart(): Promise<void> {
// Instantiate MulticastGameObject Delegate class
const delegateInstance = new MulticastGameObjectDelegate();
// Method for adding MulticastGameObject Delegate instance
delegateInstance.add(this.addNumbers);
// Method for broadcasting MulticastGameObject Delegate instances
const rocket = await GameObject.asyncSpawn("162807" ,{transform: new Transform(new Vector(300, 210, 0), new Rotation(0, 0, 0), new Vector(1, 1, 1))}) as Model;
delegateInstance.broadcast(rocket);
}
}
@Component
export default class ActionExample extends Script {
// Example function that satisfies the GameObjectDelegateFuncType constraint
public async addNumbers(object: GameObject): Promise<void> {
console.log(object.gameObjectId);
}
protected async onStart(): Promise<void> {
// Instantiate MulticastGameObject Delegate class
const delegateInstance = new MulticastGameObjectDelegate();
// Method for adding MulticastGameObject Delegate instance
delegateInstance.add(this.addNumbers);
// Method for broadcasting MulticastGameObject Delegate instances
const rocket = await GameObject.asyncSpawn("162807" ,{transform: new Transform(new Vector(300, 210, 0), new Rotation(0, 0, 0), new Vector(1, 1, 1))}) as Model;
delegateInstance.broadcast(rocket);
}
}
Table of contents
Methods
add(func : GameObjectDelegateFuncType ): void other |
---|
Add proxy event |
broadcast(obj : GameObject ): void other |
Trigger proxy event |
clear(): void other |
Clear proxy events (dangerous operation, please note which proxy events you are clearing) |
remove(func : GameObjectDelegateFuncType ): void other |
Delete proxy event |
Methods
add
• add(func
): void
other
Add proxy event
Parameters
func GameObjectDelegateFuncType | Event callback function default: |
---|
broadcast
• broadcast(obj
): void
other
Trigger proxy event
Parameters
obj GameObject | Trigger Object Object |
---|
clear
• clear(): void
other
Clear proxy events (dangerous operation, please note which proxy events you are clearing)
remove
• remove(func
): void
other
Delete proxy event
Parameters
func GameObjectDelegateFuncType | event callbacks |
---|