mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-30 00:48:00 +01:00
70 lines
No EOL
2.3 KiB
C#
70 lines
No EOL
2.3 KiB
C#
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace CinemaDirector
|
|
{
|
|
/// <summary>
|
|
/// An Event for disabling any behaviour that has an "enabled" property.
|
|
/// </summary>
|
|
[CutsceneItemAttribute("Game Object", "Disable Behaviour", CutsceneItemGenre.ActorItem)]
|
|
public class DisableBehaviour : CinemaActorEvent
|
|
{
|
|
public Component Behaviour;
|
|
|
|
// Options for reverting in editor.
|
|
[SerializeField]
|
|
private RevertMode editorRevertMode = RevertMode.Revert;
|
|
|
|
// Options for reverting during runtime.
|
|
[SerializeField]
|
|
private RevertMode runtimeRevertMode = RevertMode.Revert;
|
|
|
|
/// <summary>
|
|
/// Trigger this event and Disable the chosen Behaviour.
|
|
/// </summary>
|
|
/// <param name="actor">The actor to perform the behaviour disable on.</param>
|
|
public override void Trigger(GameObject actor)
|
|
{
|
|
Component b = actor.GetComponent(Behaviour.GetType()) as Component;
|
|
if (b != null)
|
|
{
|
|
Behaviour.GetType().GetMember("enabled");
|
|
|
|
PropertyInfo fieldInfo = Behaviour.GetType().GetProperty("enabled");
|
|
fieldInfo.SetValue(Behaviour, false, null);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reverse trigger this event and Enable the chosen Behaviour.
|
|
/// </summary>
|
|
/// <param name="actor">The actor to perform the behaviour enable on.</param>
|
|
public override void Reverse(GameObject actor)
|
|
{
|
|
Component b = actor.GetComponent(Behaviour.GetType()) as Component;
|
|
if (b != null)
|
|
{
|
|
PropertyInfo fieldInfo = Behaviour.GetType().GetProperty("enabled");
|
|
fieldInfo.SetValue(b, true, null);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Option for choosing when this Event will Revert to initial state in Editor.
|
|
/// </summary>
|
|
public RevertMode EditorRevertMode
|
|
{
|
|
get { return editorRevertMode; }
|
|
set { editorRevertMode = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Option for choosing when this Event will Revert to initial state in Runtime.
|
|
/// </summary>
|
|
public RevertMode RuntimeRevertMode
|
|
{
|
|
get { return runtimeRevertMode; }
|
|
set { runtimeRevertMode = value; }
|
|
}
|
|
}
|
|
} |