first commit
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
public class CameraFader : MonoBehaviour
|
||||
{
|
||||
|
||||
private static CameraFader _current;
|
||||
private float alpha = 0;
|
||||
private Texture2D _blackTexture;
|
||||
|
||||
private Texture2D blackTexture {
|
||||
get
|
||||
{
|
||||
if ( _blackTexture == null ) {
|
||||
_blackTexture = new Texture2D(1, 1);
|
||||
_blackTexture.SetPixel(1, 1, Color.black);
|
||||
_blackTexture.Apply();
|
||||
}
|
||||
return _blackTexture;
|
||||
}
|
||||
}
|
||||
|
||||
public static CameraFader current {
|
||||
get
|
||||
{
|
||||
if ( _current == null )
|
||||
_current = FindAnyObjectByType<CameraFader>();
|
||||
if ( _current == null )
|
||||
_current = new GameObject("_CameraFader").AddComponent<CameraFader>();
|
||||
return _current;
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeIn(float time) { StartCoroutine(CoroutineFadeIn(time)); }
|
||||
public void FadeOut(float time) { StartCoroutine(CoroutineFadeOut(time)); }
|
||||
|
||||
IEnumerator CoroutineFadeIn(float time) {
|
||||
alpha = 1;
|
||||
if ( time <= 0 ) { alpha = 0; }
|
||||
while ( alpha > 0 ) { yield return null; alpha -= ( 1 / time ) * Time.deltaTime; }
|
||||
}
|
||||
|
||||
IEnumerator CoroutineFadeOut(float time) {
|
||||
alpha = 0;
|
||||
if ( time <= 0 ) { alpha = 1; }
|
||||
while ( alpha < 1 ) { yield return null; alpha += ( 1 / time ) * Time.deltaTime; }
|
||||
}
|
||||
|
||||
void OnGUI() {
|
||||
|
||||
if ( alpha <= 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
GUI.color = new Color(1, 1, 1, alpha);
|
||||
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), blackTexture);
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb452f4aee936a543a1da061a3166e32
|
||||
timeCreated: 1433294396
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Camera/CameraFader.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,23 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Camera")]
|
||||
public class FadeIn : ActionTask
|
||||
{
|
||||
|
||||
public float fadeTime = 1f;
|
||||
|
||||
protected override void OnExecute() {
|
||||
CameraFader.current.FadeIn(fadeTime);
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( elapsedTime >= fadeTime )
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd298722117d35041bc834cf57612a77
|
||||
timeCreated: 1433294375
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Camera/FadeIn.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,23 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Camera")]
|
||||
public class FadeOut : ActionTask
|
||||
{
|
||||
|
||||
public float fadeTime = 1f;
|
||||
|
||||
protected override void OnExecute() {
|
||||
CameraFader.current.FadeOut(fadeTime);
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( elapsedTime >= fadeTime )
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e952924a017858d44b872217916de9c6
|
||||
timeCreated: 1433294749
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Camera/FadeOut.cs
|
||||
uploadId: 704937
|
||||
Reference in New Issue
Block a user