Files
BH3/Assets/Plugins/Assembly-CSharp-firstpass/CinemaDirector/DisableBehaviour.cs
2025-08-13 09:26:42 +08:00

63 lines
1.3 KiB
C#

using System.Reflection;
using CinemaSuite.Common;
using UnityEngine;
namespace CinemaDirector
{
[CutsceneItem("Game Object", "Disable Behaviour", new CutsceneItemGenre[] { CutsceneItemGenre.ActorItem })]
public class DisableBehaviour : CinemaActorEvent
{
public Component Behaviour;
[SerializeField]
private RevertMode editorRevertMode;
[SerializeField]
private RevertMode runtimeRevertMode;
public RevertMode EditorRevertMode
{
get
{
return editorRevertMode;
}
set
{
editorRevertMode = value;
}
}
public RevertMode RuntimeRevertMode
{
get
{
return runtimeRevertMode;
}
set
{
runtimeRevertMode = value;
}
}
public override void Trigger(GameObject actor)
{
Component component = actor.GetComponent(Behaviour.GetType());
if (component != null)
{
PropertyInfo property = ReflectionHelper.GetProperty(Behaviour.GetType(), "enabled");
property.SetValue(Behaviour, false, null);
}
}
public override void Reverse(GameObject actor)
{
Component component = actor.GetComponent(Behaviour.GetType());
if (component != null)
{
PropertyInfo property = ReflectionHelper.GetProperty(Behaviour.GetType(), "enabled");
property.SetValue(component, true, null);
}
}
}
}