- Home /
Can't access another script, think it may be due to namespace/public class ?
I'm having trouble accessing another script in my project. This is the script I want to access -
using System;
using UnityEngine;
namespace UnityStandardAssets.ImageEffects
{
[ExecuteInEditMode]
[RequireComponent (typeof(Camera))]
[AddComponentMenu ("Image Effects/Camera/Vignette and Chromatic Aberration")]
public class VignetteAndChromaticAberration : PostEffectsBase
{
public enum AberrationMode
{
Simple = 0,
Advanced = 1,
}
public AberrationMode mode = AberrationMode.Simple;
public static float intensity = 0.0f; //I CHANGED THIS TO A STATIC VARIABLE !
and I'm using this script to access/change the other script -
using UnityEngine;
using System.Collections;
public class FadeOut : MonoBehaviour
{
private bool levelCompleted = false;
public float fadeAmount;
void OnTriggerEnter(Collider collider)
{
if(collider.gameObject.name == "Player")
{
levelCompleted = true;
}
}
void Update()
{
if(levelCompleted = true)
{
VignetteAndChromaticAberration.intensity += fadeAmount;
}
}
}
I'm getting this error -
Assets/Scripts/FadeOut.cs(22,25): error CS0103: The name `VignetteAndChromaticAberration' does not exist in the current context
I think (please correct me if I'm wrong) its something to do with namespace / public class. I've not come across a script yet that uses the namespace thing so that I tink is why I having issues with finding the 'other' script.
???
$$anonymous$$any thanks.... sorted :)
Want to move your reply to answers section so I can up-vote it for you.
and prevented me from gaining karma...lol But thanks anyway
;)
Answer by Glurth · Mar 16, 2015 at 03:11 PM
You'll need to include:
using UnityStandardAssets.ImageEffects;
at the top of any file that wishes to access that namespace.
What about the oposite ? I'm using a namespace and can't access other scripts whithout namespace inside that one.
Your answer
Follow this Question
Related Questions
How do I access a static function in JS? 1 Answer
find prefabs that extend Base Class c# 0 Answers
Defining a public class in C# 1 Answer