- Home /
Underwater Blur Effect Help
Hey, I'm testing out my underwater blur and it's not working, can someone tell me why?
I get this error : Underwatersrc.cs(12,15): error CS0103: The name `underwaterblurt' does not exist in the current context
Here's the code
using UnityEngine;
using System.Collections;
public class Underwatersrc : MonoBehaviour {
public AudioClip Underwatersound;
void Blureffectunderwater(){
BlurEffect underwaterblur = Camera.main.gameObject.GetComponent (typeof(BlurEffect)) as BlurEffect;
if(underwaterblur == null)
{
underwaterblur = Camera.main.gameObject.AddComponent(typeof(BlurEffect)) as BlurEffect;
underwaterblur.iterations = 2;
underwaterblur.blurSpread = 0.2f;
underwaterblur.enabled = true;
}
}
void Update() {
if(Camera.main.transform.position.y < 26){
RenderSettings.fogMode = FogMode.Exponential;
RenderSettings.fog = true;
RenderSettings.fogDensity = 0.085f;
RenderSettings.fogColor = new Color (0.22f, 0.65f, 0.77f, 0.5f);
underwaterblur = true;
}
else {
RenderSettings.fogMode = FogMode.Linear;
RenderSettings.fog = true;
RenderSettings.fogDensity = 0.85f;
RenderSettings.fogColor = Color.white;
}
}
}
Answer by SisterKy · Nov 24, 2012 at 08:31 PM
... underwaterblurt is not underwaterblur. There's a 't' too much.
Ok so i fixed that spelling error, but i still get: underwatersrc.cs(28,10): error CS0103: The name `underwaterblur' does not exist in the current context
from a very rough look on it i think you defined the variable in the function Blurreffectunderwater but try to access it in function Update? Also, in function Update, you do underwaterblur = true; that won't do. You need underwaterblur.enabled = true...
Your answer
Follow this Question
Related Questions
Script compile errors with following hack & slash tutorial 2 Answers
CS0103 error when building scenes 0 Answers
CS0103 Error 1 Answer
Accessing a js static var from a c# script 1 Answer
Error cs0103 name CurMenu does not exist 2 Answers