ドキュメント

Unity Engine

Unity Engine

GetEvents(List<string>)

Gets the name of every Event connected to a system.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

public void GetEvents(List<string> names)

Parameters

The List that this function populates with the event system names.

Remarks

To increase the speed of the retrieval process, preallocate the
names
input list.
This example logs all available events in the attached
VisualEffectAsset
.
Additional Resources: VisualEffect.SendEvent

Examples

using System.Collections.Generic;using UnityEngine;using UnityEngine.VFX;[ExecuteInEditMode]class LogEventNames : MonoBehaviour{ // Called when the script or GameObject is enabled void OnEnable() { VisualEffect vfx = GetComponent<VisualEffect>(); if (vfx != null && vfx.visualEffectAsset != null) { VisualEffectAsset vfxAsset = vfx.visualEffectAsset; var eventNames = new List<string>(); // Retrieve all events from the VisualEffectAsset and store them in the list vfxAsset.GetEvents(eventNames); if (eventNames.Count == 0) { Debug.Log($"There are no events listed for asset: {vfxAsset}"); } foreach (var eventName in eventNames) { Debug.Log($"Event: {eventName}"); } } else { Debug.Log("Unable to retrieve VisualEffect component or VisualEffectAsset is null."); } }}