rj-action-library/Runtime/VirtualCameras/Effects/PlayCameraEffect.cs

64 lines
1.3 KiB
C#

using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class PlayCameraEffect:Action
{
[Export]
public CameraEffect cameraEffect;
[Export]
public bool useActiveCameraSlot = false;
[ExportGroup("Other Camera Slot")]
[Export]
public VirtualCamera3DSlot cameraSlot;
[Export]
public int cameraSlotIndex = -1;
[Export]
public Selector cameraSlotSelector;
protected override void _OnTrigger()
{
var manager = VirtualCamera3DManager.Get();
var resolvedSlot = useActiveCameraSlot ? manager.activeSlot : cameraSlot;
if ( resolvedSlot == null && cameraSlotIndex != -1 )
{
if ( cameraSlotIndex != -1 )
{
resolvedSlot = manager.GetSlot( cameraSlotIndex );
}
else if ( cameraSlotSelector != null )
{
resolvedSlot = Selectors.GetFromDirectChildren<VirtualCamera3DSlot>( manager, cameraSlotSelector );
}
}
if ( resolvedSlot == null )
{
// this.LogError( "No camera slot found" );
return;
}
// this.LogInfo( "Camera slot found" );
resolvedSlot.SetCameraEffect( cameraEffect );
}
}
}