ScreenFade Help
Hi All,
Im having some trouble getting a screenfade to work.
I have a rawimage named FadeImg with a texture on it.
The ScreenFader script is attached to main camera
and i have a second script on main camera to call the fade and move onto next scene:
 using UnityEngine;
 using System.Collections;
 
 public class introskip : MonoBehaviour {
 
     ScreenFader fadeScr;
     public int SceneNumb;
 
 
     void Awake()
     {
         fadeScr = GameObject.FindObjectOfType<ScreenFader>();
     }
 
     // Use this for initialization
     IEnumerator Start () {
         yield return new WaitForSeconds(10);
         fadeScr.EndScene("Intro");
         Application.LoadLevel ("Title");  }
    
     // Update is called once per frame
     void Update () {
         if (Input.anyKey)
             fadeScr.EndScene("Intro");
         Application.LoadLevel("Title"); }
 }
 
I keep getting this error:
The type or namespace name 'ScreenFader' could not be found (are you missing a using directive or an assembly reference?)
Anyone able to offer any suggestions as to why it isnt working?
Many thanks!
Is screenfader unityscript/javascript? is it outside of the unity namespace(meaning it's been specified)?
Thanks for the reply, i got the script from here:
https://gist.github.com/NovaSurfer/5f14e9153e7a2a07d7c5
Is it looking for something that is on the other script? the instructions were really poor.
Im a complete beginner by the way
ScreenFader doesn't seem to be a Unity class, so we don't know what happens inside the "EndScene" method. $$anonymous$$ost likely it starts a Coroutine internally and returns immediately and that's why you don't see the fade effect.
In the other script named ScreenFader it has a class like below:
public class ScreenFader : $$anonymous$$onoBehaviour
would this be enough for it to reference? Here is the full ScreenFader script:
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using UnityEngine.Scene$$anonymous$$anagement;
 
 public class ScreenFader : $$anonymous$$onoBehaviour
 {
     public Image FadeImg;
     public float fadeSpeed = 1.5f;
     public bool sceneStarting = true;
 
 
     void Awake()
     {
         FadeImg.rectTransform.localScale = new Vector2(Screen.width, Screen.height);
     }
 
     void Update()
     {
         // If the scene is starting...
         if (sceneStarting)
             // ... call the StartScene function.
             StartScene();
     }
 
 
     void FadeToClear()
     {
         // Lerp the colour of the image between itself and transparent.
         FadeImg.color = Color.Lerp(FadeImg.color, Color.clear, fadeSpeed * Time.deltaTime);
     }
 
 
     void FadeToBlack()
     {
         // Lerp the colour of the image between itself and black.
         FadeImg.color = Color.Lerp(FadeImg.color, Color.black, fadeSpeed * Time.deltaTime);
     }
 
 
     void StartScene()
     {
         // Fade the texture to clear.
         FadeToClear();
 
         // If the texture is almost clear...
         if (FadeImg.color.a <= 0.05f)
         {
             // ... set the colour to clear and disable the RawImage.
             FadeImg.color = Color.clear;
             FadeImg.enabled = false;
 
             // The scene is no longer starting.
             sceneStarting = false;
         }
     }
 
 
     public IEnumerator EndSceneRoutine(int SceneNumber)
     {
         // $$anonymous$$ake sure the RawImage is enabled.
         FadeImg.enabled = true;
         do
         {
             // Start fading towards black.
             FadeToBlack();
 
             // If the screen is almost black...
             if (FadeImg.color.a >= 0.95f)
             {
                 // ... reload the level
                 Scene$$anonymous$$anager.LoadScene(SceneNumber);
                 yield break;
             }
             else
             {
                 yield return null;
             }
         } while (true);
     }
 
     public void EndScene(int SceneNumber)
     {
         sceneStarting = false;
         StartCoroutine("EndSceneRoutine", SceneNumber);
     }
 }   
Answer by phyzikalgamer · Sep 01, 2016 at 01:34 PM
so i just re-applied all the scripts and changed zero code then all of a sudden it worked. So infuriating!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                