You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
10 years ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
|
||
|
namespace Fungus.Script
|
||
|
{
|
||
|
[CommandName("Move To View")]
|
||
|
[HelpText("Moves the camera to a location specified by a View object.")]
|
||
|
public class MoveToView : FungusCommand
|
||
|
{
|
||
|
public float duration;
|
||
|
public Fungus.View targetView;
|
||
|
public bool waitUntilFinished = true;
|
||
|
|
||
|
public override void OnEnter()
|
||
|
{
|
||
|
CameraController cameraController = CameraController.GetInstance();
|
||
|
|
||
|
if (waitUntilFinished)
|
||
|
{
|
||
|
cameraController.waiting = true;
|
||
|
}
|
||
|
|
||
|
Vector3 targetPosition = targetView.transform.position;
|
||
|
Quaternion targetRotation = targetView.transform.rotation;
|
||
|
float targetSize = targetView.viewSize;
|
||
|
|
||
|
cameraController.PanToPosition(targetPosition, targetRotation, targetSize, duration, delegate {
|
||
|
if (waitUntilFinished)
|
||
|
{
|
||
|
cameraController.waiting = false;
|
||
|
Continue();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (!waitUntilFinished)
|
||
|
{
|
||
|
Continue();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override string GetSummary()
|
||
|
{
|
||
|
if (targetView == null)
|
||
|
{
|
||
|
return "<no view selected>";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "Move to " + targetView.name;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|