Hi,
Here we go:
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Camera)]
[Tooltip("Set the size of an Ortho camera")]
public class CameraSetOrthographicSize : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(Camera))]
[Tooltip("The orthographic camera.")]
public FsmOwnerDefault camera;
[RequiredField]
[Tooltip("Size")]
public FsmFloat size;
[Tooltip("Repeat every frame.")]
public bool everyFrame;
private Camera cam;
public override void Reset()
{
camera = null;
size = 100f;
}
public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(camera);
if (go == null)
{
return;
}
cam = go.camera;
if (cam==null)
{
return;
}
if (!cam.isOrthoGraphic)
{
return;
}
DoSetSize();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoSetSize();
}
void DoSetSize()
{
cam.orthographicSize = size.Value;
}
public override string ErrorCheck()
{
var go = Fsm.GetOwnerDefaultTarget(camera);
if (go != null)
{
cam = go.camera;
if (cam!=null)
{
if (!cam.isOrthoGraphic)
{
return "Camera needs to be Orthographic";
}
}
}
return "";
}
}
}
Bye,
Jean