Unity 6.3
0 онлайн 74 гостей 3 в системе
Вход

VisualEffectAsset.GetEvents

Declaration

public void GetEvents(List<string> names);

Параметры

Параметр Описание
имена Список, который эта функция заполняет именами систем событий.

Описание

Получает имя каждого События, подключенного к системе.

Чтобы увеличить скорость процесса поиска, предварительно выделить names вводный список.

Дополнительные ресурсы: VisualEffect.SendEvent.

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.");
        }
    }
}

Этот пример регистрирует все доступные события в приложенном файле VisualEffectAsset.