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.
83 lines
1.8 KiB
83 lines
1.8 KiB
10 years ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
|
||
10 years ago
|
namespace Fungus
|
||
10 years ago
|
{
|
||
10 years ago
|
[CommandInfo("Camera",
|
||
|
"Fade To View",
|
||
10 years ago
|
"Fades the camera out and in again at a position specified by a View object. Select [Game Object > Fungus > Camera > View] to create a View object.")]
|
||
10 years ago
|
public class FadeToView : Command
|
||
10 years ago
|
{
|
||
10 years ago
|
[Tooltip("Time for fade effect to complete")]
|
||
10 years ago
|
public float duration = 1f;
|
||
10 years ago
|
|
||
|
[Tooltip("View to transition to when Fade is complete")]
|
||
10 years ago
|
public Fungus.View targetView;
|
||
10 years ago
|
|
||
|
[Tooltip("Wait until the fade has finished before executing next command")]
|
||
10 years ago
|
public bool waitUntilFinished = true;
|
||
10 years ago
|
|
||
|
[Tooltip("Color to render fullscreen fade texture with when screen is obscured.")]
|
||
10 years ago
|
public Color fadeColor = Color.black;
|
||
10 years ago
|
|
||
|
[Tooltip("Optional texture to use when rendering the fullscreen fade effect.")]
|
||
10 years ago
|
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)
|
||
|
{
|
||
10 years ago
|
return "Error: No view selected";
|
||
10 years ago
|
}
|
||
|
else
|
||
|
{
|
||
10 years ago
|
return targetView.name;
|
||
10 years ago
|
}
|
||
|
}
|
||
10 years ago
|
|
||
|
public override Color GetButtonColor()
|
||
|
{
|
||
|
return new Color32(216, 228, 170, 255);
|
||
|
}
|
||
10 years ago
|
}
|
||
|
|
||
|
}
|