浏览代码
OnVFXOutputEvent (#52)
OnVFXOutputEvent (#52)
* Added OnVFXOutputEvent / Fixes for VFX Actions / Added AssemblyInfo Defines * Updated Changelog/main
GitHub
4 年前
当前提交
9ec6abec
共有 9 个文件被更改,包括 157 次插入 和 12 次删除
-
6CHANGELOG.md
-
3Editor/PropertyDrawers/CallableReorderableList.cs
-
42Icons/Misc/ic-vfx.png
-
5Runtime/GameplayIngredients.asmdef
-
1Runtime/GameplayIngredients.cs
-
19Runtime/LevelScripting/Actions/VFXSendEventAction.cs
-
20Runtime/LevelScripting/Actions/VFXSetPropertyAction.cs
-
62Runtime/LevelScripting/Events/OnVFXOutputEvent.cs
-
11Runtime/LevelScripting/Events/OnVFXOutputEvent.cs.meta
|
|||
using UnityEngine; |
|||
#if PACKAGE_VFXGRAPH
|
|||
using UnityEngine.VFX; |
|||
#endif
|
|||
|
|||
namespace GameplayIngredients.Events |
|||
{ |
|||
#if !PACKAGE_VFXGRAPH
|
|||
[WarnDisabledModule("Visual Effect Graph")] |
|||
#else
|
|||
[AddComponentMenu(ComponentMenu.vfxPath + "On VFX Output Event")] |
|||
[RequireComponent(typeof(VisualEffect))] |
|||
#endif
|
|||
public class OnVFXOutputEvent : EventBase |
|||
{ |
|||
public string vfxEventName { get => m_VFXEventName; set { m_VFXEventName = value; CacheEventName(); } } |
|||
[SerializeField] |
|||
string m_VFXEventName = "On Received Event"; |
|||
int m_VFXEventID; |
|||
|
|||
[SerializeField] |
|||
protected Callable[] onEventReceived; |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
CacheEventName(); |
|||
#if PACKAGE_VFXGRAPH
|
|||
GetComponent<VisualEffect>().outputEventReceived += OnVFXOutputEvent_Received; |
|||
#else
|
|||
Debug.LogWarning("OnVFXOutputEvent could not attach to VFX as VFX Graph package is not installed, if you're running HDRP or URP, please install it using package manager."); |
|||
#endif
|
|||
} |
|||
|
|||
private void OnDisable() |
|||
{ |
|||
#if PACKAGE_VFXGRAPH
|
|||
GetComponent<VisualEffect>().outputEventReceived -= OnVFXOutputEvent_Received; |
|||
#endif
|
|||
} |
|||
|
|||
private void OnValidate() |
|||
{ |
|||
CacheEventName(); |
|||
} |
|||
|
|||
void CacheEventName() |
|||
{ |
|||
m_VFXEventID = Shader.PropertyToID(m_VFXEventName); |
|||
} |
|||
|
|||
#if PACKAGE_VFXGRAPH
|
|||
void OnVFXOutputEvent_Received(VFXOutputEventArgs args) |
|||
{ |
|||
if(args.nameId == m_VFXEventID) |
|||
{ |
|||
Callable.Call(onEventReceived, gameObject); |
|||
} |
|||
} |
|||
#endif
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 68ebf341e2a981b47b256be279fd4bf8 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {fileID: 2800000, guid: 9a14315cb05b557459e14128a03f988f, type: 3} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue