Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FallDetect2 : MonoBehaviour
{
public Texture2D fadeOutTexture;
public float fadeSpeed = 0.8f;
public GameObject SpwnEff;
private int drawDepht = 1000;
private float alpha = 1.0f;
private int fadeDir = -1;
void OnGUI()
{
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, alpha);
GUI.depth = drawDepht;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
}
public float BeginFade(int direction)
{
fadeDir = direction;
return (fadeSpeed);
}
void Start()
{
GameVariables.checkpoint = new Vector3(3, 6, -14);
SpwnEff SetActive(false);
}
void Update()
{
if (transform.position.y < -12)
{
transform.position = GameVariables.checkpoint;
alpha = 10;
SpwnEff SetActive(true);
}
}
void OnLevelWasLoaded()
{
// alpha = 1;
BeginFade(-1);
}
}
using System.Collections.Generic;
using UnityEngine;
public class FallDetect2 : MonoBehaviour
{
public Texture2D fadeOutTexture;
public float fadeSpeed = 0.8f;
public GameObject SpwnEff;
private int drawDepht = 1000;
private float alpha = 1.0f;
private int fadeDir = -1;
void OnGUI()
{
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, alpha);
GUI.depth = drawDepht;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
}
public float BeginFade(int direction)
{
fadeDir = direction;
return (fadeSpeed);
}
void Start()
{
GameVariables.checkpoint = new Vector3(3, 6, -14);
SpwnEff SetActive(false);
}
void Update()
{
if (transform.position.y < -12)
{
transform.position = GameVariables.checkpoint;
alpha = 10;
SpwnEff SetActive(true);
}
}
void OnLevelWasLoaded()
{
// alpha = 1;
BeginFade(-1);
}
}