#if HAVE_NODECANVAS && HAVE_SLATE && HAVE_SLATE_CAMRIGPATCH
using System;
using UnityEngine;
using ParadoxNotion.Design;
using NodeCanvas.Framework;
using Slate;
namespace Framework.Cameras {
/// Places the camera at the last view of a shot
[ParadoxNotion.Design.Category("Camera")]
[ParadoxNotion.Design.Description("Shows the last view of a shot camera")]
public class ShowShotCameraTask : ActionTask {
/// Shot at which the camera will be placed
[RequiredField]
public BBParameter Shot;
/// Camera from which the cutscene will be played back
[RequiredField]
public BBParameter Camera;
/// Summary of what this action does
protected override string info {
get {
return
"Place " + this.Camera.ToString() +
" at " + this.Shot.ToString();
}
}
/// Called once when the action is executed
protected override void OnExecute() {
Transform shotTransform = this.Shot.value.transform;
// This is a custom property I added to Slate 1.7.2. Will not compile
// without modding Slate accordingly.
if(DirectorCamera.reparentExistingRig) {
if(DirectorCamera.cameraRigRoot != null) {
DirectorCamera.cameraRigRoot.parent = shotTransform;
DirectorCamera.cameraRigRoot.localPosition = Vector3.zero;
DirectorCamera.cameraRigRoot.localRotation = Quaternion.identity;
}
} else {
Transform cameraTransform = this.Camera.value.transform;
cameraTransform.parent = shotTransform;
cameraTransform.localPosition = Vector3.zero;
cameraTransform.localRotation = Quaternion.identity;
const bool disablePrevious = true;
this.Camera.value.Activate(disablePrevious);
}
EndAction();
}
}
} // namespace Framework.Cameras
#endif // HAVE_NODECANVAS && HAVE_SLATE