chrisgregan
10 years ago
7 changed files with 133 additions and 93 deletions
@ -0,0 +1,68 @@
|
||||
using UnityEngine; |
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace Fungus.Script |
||||
{ |
||||
[CommandName("Fade To View")] |
||||
[HelpText("Fades the camera out and in again at a location specified by a View object.")] |
||||
public class FadeToView : FungusCommand |
||||
{ |
||||
public float duration; |
||||
public Fungus.View targetView; |
||||
public bool waitUntilFinished = true; |
||||
public Color fadeColor = Color.black; |
||||
public Texture2D fadeTexture; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (targetView == null) |
||||
{ |
||||
Continue(); |
||||
return; |
||||
} |
||||
|
||||
CameraController cameraController = CameraController.GetInstance(); |
||||
|
||||
if (waitUntilFinished) |
||||
{ |
||||
cameraController.waiting = true; |
||||
} |
||||
|
||||
if (fadeTexture) |
||||
{ |
||||
cameraController.screenFadeTexture = fadeTexture; |
||||
} |
||||
else |
||||
{ |
||||
cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32); |
||||
} |
||||
|
||||
cameraController.FadeToView(targetView, duration, delegate { |
||||
if (waitUntilFinished) |
||||
{ |
||||
cameraController.waiting = false; |
||||
Continue(); |
||||
} |
||||
}); |
||||
|
||||
if (!waitUntilFinished) |
||||
{ |
||||
Continue(); |
||||
} |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
if (targetView == null) |
||||
{ |
||||
return "<no view selected>"; |
||||
} |
||||
else |
||||
{ |
||||
return "Fade to " + targetView.name; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 8b3057c17923c47bbbbf6dd0d8ecef99 |
||||
guid: 437f9a4e3dbc647f9bdce95308418bff |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
@ -0,0 +1,55 @@
|
||||
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; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 45c952ea1ad444e479b570fa242679c5 |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
@ -1,92 +0,0 @@
|
||||
using UnityEngine; |
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace Fungus.Script |
||||
{ |
||||
[CommandName("Set View")] |
||||
[HelpText("Moves the camera to a location specified by a View object. Supports Move and Fade transitions over a period of time.")] |
||||
public class SetView : FungusCommand |
||||
{ |
||||
public enum Transition |
||||
{ |
||||
Move, |
||||
Fade |
||||
} |
||||
|
||||
public Transition transition; |
||||
public float duration; |
||||
public Fungus.View targetView; |
||||
public bool waitUntilFinished = true; |
||||
public Color fadeColor = Color.black; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
CameraController cameraController = CameraController.GetInstance(); |
||||
|
||||
if (waitUntilFinished) |
||||
{ |
||||
cameraController.waiting = true; |
||||
} |
||||
|
||||
if (transition == Transition.Fade) |
||||
{ |
||||
cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32); |
||||
|
||||
cameraController.FadeToView(targetView, duration, delegate { |
||||
if (waitUntilFinished) |
||||
{ |
||||
cameraController.waiting = false; |
||||
Continue(); |
||||
} |
||||
}); |
||||
} |
||||
else if (transition == Transition.Move) |
||||
{ |
||||
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() |
||||
{ |
||||
string description = ""; |
||||
|
||||
switch (transition) |
||||
{ |
||||
case Transition.Move: |
||||
description = "Move to "; |
||||
break; |
||||
case Transition.Fade: |
||||
description = "Fade to "; |
||||
break; |
||||
} |
||||
|
||||
if (targetView == null) |
||||
{ |
||||
description = "<no view selected>"; |
||||
} |
||||
else |
||||
{ |
||||
description += targetView.name; |
||||
} |
||||
|
||||
return description; |
||||
} |
||||
} |
||||
|
||||
} |
Binary file not shown.
Loading…
Reference in new issue