浏览代码

OnVFXOutputEvent (#52)

* Added OnVFXOutputEvent / Fixes for VFX Actions / Added AssemblyInfo Defines

* Updated Changelog
/main
GitHub 3 年前
当前提交
9ec6abec
共有 9 个文件被更改,包括 157 次插入12 次删除
  1. 6
      CHANGELOG.md
  2. 3
      Editor/PropertyDrawers/CallableReorderableList.cs
  3. 42
      Icons/Misc/ic-vfx.png
  4. 5
      Runtime/GameplayIngredients.asmdef
  5. 1
      Runtime/GameplayIngredients.cs
  6. 19
      Runtime/LevelScripting/Actions/VFXSendEventAction.cs
  7. 20
      Runtime/LevelScripting/Actions/VFXSetPropertyAction.cs
  8. 62
      Runtime/LevelScripting/Events/OnVFXOutputEvent.cs
  9. 11
      Runtime/LevelScripting/Events/OnVFXOutputEvent.cs.meta

6
CHANGELOG.md


#### Added
* Added `OnVFXOutputEvent` that triggers upon a visual effect output event
* Added `WarnDisabledModuleAttribute` for GameplayIngredientsBehaviors that need to be disabled (encapsulate into #ifdefs )
* Added New Input System support:
* Handles presence/absence of both systems (legacy/new) in Screenshot Manager, UIEventManager

* `OnInputDirectEvent` polls state without InputActions
* `OnPlayerInputAction` gets input from a `PlayerInput`
* Reworked PlayerInput for FirstPersonController using both Input Systems
#### Fixed
* Fixed Callable add Menu that did not set correctly non-public callable lists.
## 2020.2.6

3
Editor/PropertyDrawers/CallableReorderableList.cs


using UnityEditor;
using UnityEditorInternal;
using System.Linq;
using System.Reflection;
namespace GameplayIngredients.Editor
{

{
public static void AddCallable(this GameObject gameObject, Component component, string propertyName, System.Type t)
{
var field = component.GetType().GetFields().Where(f => f.Name == propertyName).FirstOrDefault();
var field = component.GetType().GetFields(BindingFlags.Public| BindingFlags.Instance | BindingFlags.NonPublic).Where(f => f.Name == propertyName).FirstOrDefault();
var val = field.GetValue(component) as Callable[];
if (t != null && typeof(Callable).IsAssignableFrom(t))

42
Icons/Misc/ic-vfx.png

之前 之后
宽度: 32  |  高度: 32  |  大小: 2.8 KiB

5
Runtime/GameplayIngredients.asmdef


"name": "com.unity.modules.screencapture",
"expression": "1.0.0",
"define": "MODULE_SCREENCAPTURE"
},
{
"name": "com.unity.visualeffectgraph",
"expression": "10.0.0",
"define": "PACKAGE_VFXGRAPH"
}
],
"noEngineReferences": false

1
Runtime/GameplayIngredients.cs


public const string rigsPath = basePath + "Rigs/";
public const string timerPath = basePath + "Timers/";
public const string stateMachinePath = basePath + "State Machines/";
public const string vfxPath = basePath + "VFX/";
}

19
Runtime/LevelScripting/Actions/VFXSendEventAction.cs


using UnityEngine;
#if PACKAGE_VFXGRAPH
#endif
[AddComponentMenu(ComponentMenu.actionsPath + "VFX Send Event Action")]
[Callable("Game", "Misc/ic-vfx.png")]
#if !PACKAGE_VFXGRAPH
[WarnDisabledModule("Visual Effect Graph")]
#endif
[AddComponentMenu(ComponentMenu.vfxPath + "VFX Send Event Action")]
[Callable("Visual Effects", "Misc/ic-vfx.png")]
#if PACKAGE_VFXGRAPH
[NonNullCheck]
#endif
#if PACKAGE_VFXGRAPH
var attrib = visualEffect.CreateVFXEventAttribute();
visualEffect.SendEvent(eventName, attrib);
visualEffect?.SendEvent(eventName);
#else
Debug.LogWarning("VFXSendEventAction 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
}
public override string GetDefaultName()

20
Runtime/LevelScripting/Actions/VFXSetPropertyAction.cs


using UnityEngine;
#if PACKAGE_VFXGRAPH
#endif
[AddComponentMenu(ComponentMenu.actionsPath + "VFX Set Property Action")]
[Callable("Game", "Misc/ic-vfx.png")]
#if !PACKAGE_VFXGRAPH
[WarnDisabledModule("Visual Effect Graph")]
#endif
[AddComponentMenu(ComponentMenu.vfxPath + "VFX Set Property Action")]
[Callable("Visual Effects", "Misc/ic-vfx.png")]
public class VFXSetPropertyAction : ActionBase
{
public enum DataType

UInt,
Int
}
#if PACKAGE_VFXGRAPH
#endif
[FormerlySerializedAs("parameter")]
public string property = "Property";

{
int id = Shader.PropertyToID(property);
if(HasParameter(id))
#if PACKAGE_VFXGRAPH
if (HasProperty(id))
{
if (!Override)
visualEffect.ResetOverride(id);

}
}
}
#else
Debug.LogWarning("VFXSetPropertyAction 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
bool HasParameter(int id)
bool HasProperty(int id)
{
switch(dataType)
{

62
Runtime/LevelScripting/Events/OnVFXOutputEvent.cs


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
}
}

11
Runtime/LevelScripting/Events/OnVFXOutputEvent.cs.meta


fileFormatVersion: 2
guid: 68ebf341e2a981b47b256be279fd4bf8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 9a14315cb05b557459e14128a03f988f, type: 3}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存