浏览代码

Add collider event

/main
Laurent 5 年前
当前提交
bf6c3032
共有 2 个文件被更改,包括 69 次插入0 次删除
  1. 58
      Runtime/LevelScripting/Events/OnColliderEvent.cs
  2. 11
      Runtime/LevelScripting/Events/OnColliderEvent.cs.meta

58
Runtime/LevelScripting/Events/OnColliderEvent.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Events
{
[RequireComponent(typeof(Collider))]
public class OnColliderEvent : EventBase
{
[ReorderableList]
public Callable[] onCollisionEnter;
[ReorderableList]
public Callable[] onCollisionExit;
[ReorderableList]
public Callable[] onCollisionStay;
public bool OnlyInteractWithTag = false;
[EnableIf("OnlyInteractWithTag")]
public string Tag = "Player";
private void OnCollisionEnter(Collider other)
{
if (OnlyInteractWithTag && other.tag == Tag)
{
Callable.Call(onCollisionEnter, other.gameObject);
}
if (!OnlyInteractWithTag)
{
Callable.Call(onCollisionEnter, other.gameObject);
}
}
private void OnCollisionExit(Collider other)
{
if (OnlyInteractWithTag && other.tag == Tag)
{
Callable.Call(onCollisionExit, other.gameObject);
}
if (!OnlyInteractWithTag)
{
Callable.Call(onCollisionExit, other.gameObject);
}
}
private void OnCollisionStay(Collider other)
{
if (OnlyInteractWithTag && other.tag == Tag)
{
Callable.Call(onCollisionStay, other.gameObject);
}
if (!OnlyInteractWithTag)
{
Callable.Call(onCollisionStay, other.gameObject);
}
}
}
}

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


fileFormatVersion: 2
guid: 086b61f209a45d64aa1dae4267461fc5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存