- バックアップ一覧
- ソース を表示
- OAR Converter/Unity3D/Underwater_u5 は削除されています。
Underwater_u5 スクリプト †[edit]
using UnityEngine;
using System.Collections;
public class Underwater_u5 : MonoBehaviour
{
//This script enables underwater effects. Attach to main camera.
//Define variable
public int underwaterLevel = 0;
//The scene's default fog settings
private bool defaultFog;
private Color defaultFogColor;
private float defaultFogDensity;
private Material defaultSkybox;
void Start ()
{
//Set the background color
defaultFog = RenderSettings.fog;
defaultFogColor = RenderSettings.fogColor;
defaultFogDensity = RenderSettings.fogDensity;
defaultSkybox = RenderSettings.skybox;
GetComponent<Camera>().backgroundColor = new Color(0, 0.4f, 0.7f, 1);
}
//
void Update ()
{
if (transform.position.y < underwaterLevel)
{
RenderSettings.fog = true;
RenderSettings.fogColor = new Color(0, 0.4f, 0.7f, 0.6f);
RenderSettings.fogDensity = 0.04f;
RenderSettings.skybox = null;
}
else
{
RenderSettings.fog = defaultFog;
RenderSettings.fogColor = defaultFogColor;
RenderSettings.fogDensity = defaultFogDensity;
RenderSettings.skybox = defaultSkybox;
}
}
}