Files
beyond/Assets/ThirdParty/PlayMaker/Actions/Editor/SetCameraFOVActionEditor.cs
2024-11-20 15:21:28 +01:00

53 lines
1.5 KiB
C#

using HutongGames.PlayMaker.Actions;
using HutongGames.PlayMakerEditor;
using UnityEditor;
using UnityEngine;
using System.Collections;
namespace HutongGames.PlayMakerEditor
{
[CustomActionEditor(typeof(HutongGames.PlayMaker.Actions.SetCameraFOV))]
public class SetCameraFOVActionEditor : CustomActionEditor
{
private GameObject cachedGameObject;
private Camera camera;
public override bool OnGUI()
{
return DrawDefaultInspector();
}
public override void OnSceneGUI()
{
var setCameraFOVAction = (HutongGames.PlayMaker.Actions.SetCameraFOV)target;
if (setCameraFOVAction.fieldOfView.IsNone)
{
return;
}
var go = setCameraFOVAction.Fsm.GetOwnerDefaultTarget(setCameraFOVAction.gameObject);
var fov = setCameraFOVAction.fieldOfView.Value;
if (go != null && fov > 0)
{
if (go != cachedGameObject || camera == null)
{
camera = go.GetComponent<Camera>();
cachedGameObject = go;
}
if (camera != null)
{
var originalFOV = camera.fieldOfView;
camera.fieldOfView = setCameraFOVAction.fieldOfView.Value;
Handles.color = new Color(1, 1, 0, .5f);
SceneGUI.DrawCameraFrustrum(camera);
camera.fieldOfView = originalFOV;
}
}
}
}
}