浏览代码

Attachment Action / Timeline Control Action / Fix in OnTriggerHook (missing instigator on exit)

/main
Thomas ICHÉ 5 年前
当前提交
8cba14c2
共有 5 个文件被更改,包括 114 次插入2 次删除
  1. 4
      Runtime/Hooks/OnTriggerHook.cs
  2. 54
      Runtime/Actions/AttachToObjectAction.cs
  3. 11
      Runtime/Actions/AttachToObjectAction.cs.meta
  4. 36
      Runtime/Actions/TimelineControlAction.cs
  5. 11
      Runtime/Actions/TimelineControlAction.cs.meta

4
Runtime/Hooks/OnTriggerHook.cs


}
if (OnlyInteractWithTag && other.tag == Tag )
{
Callable.Call(onTriggerExit);
Callable.Call(onTriggerExit, other.gameObject);
Callable.Call(onTriggerExit);
Callable.Call(onTriggerExit, other.gameObject);
}
}
}

54
Runtime/Actions/AttachToObjectAction.cs


using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients.Actions
{
public class AttachToObjectAction : ActionBase
{
public enum Action
{
Attach,
Detach,
ToggleAttachment
}
public Action action = Action.Attach;
[ReorderableList]
public GameObject[] objectsToAttach;
public bool AttachInstigator = false;
public GameObject parentObject;
public bool KeepScale;
public override void Execute(GameObject instigator = null)
{
if (parentObject == null)
{
Debug.LogWarning("No Object to attach to.");
return;
}
if (objectsToAttach != null)
{
foreach (var obj in objectsToAttach)
DoAttach(obj, parentObject, action, KeepScale);
}
if (AttachInstigator && instigator != null)
DoAttach(instigator, parentObject, action, KeepScale);
}
static void DoAttach(GameObject attachment, GameObject parent, Action action, bool keepScale)
{
if(action == Action.Attach || (action == Action.ToggleAttachment && attachment.transform.parent != parent.transform))
{
attachment.transform.parent = parent.transform;
}
else if(action == Action.Detach || (action == Action.ToggleAttachment && attachment.transform.parent == parent.transform))
{
attachment.transform.parent = null;
}
}
}
}

11
Runtime/Actions/AttachToObjectAction.cs.meta


fileFormatVersion: 2
guid: aed55c2329e1acb4f9941668ae341432
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

36
Runtime/Actions/TimelineControlAction.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
namespace GameplayIngredients.Actions
{
public class TimelineControlAction : ActionBase
{
public enum TimelineControlMode
{
Play,
Stop,
Pause,
Loop,
Hold
}
public PlayableDirector director;
public TimelineControlMode mode = TimelineControlMode.Play;
public override void Execute(GameObject instigator = null)
{
switch(mode)
{
case TimelineControlMode.Play: director.Play(); break;
case TimelineControlMode.Stop: director.Stop(); break;
case TimelineControlMode.Pause: director.Pause(); break;
case TimelineControlMode.Loop: director.extrapolationMode = DirectorWrapMode.Loop; break;
case TimelineControlMode.Hold: director.extrapolationMode = DirectorWrapMode.Hold; break;
}
}
}
}

11
Runtime/Actions/TimelineControlAction.cs.meta


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