-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added OnVFXOutputEvent / Fixes for VFX Actions / Added AssemblyInfo Defines * Updated Changelog
- Loading branch information
Showing
9 changed files
with
116 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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 | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.