Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by phyzikalgamer · Aug 30, 2016 at 07:21 PM · fadefadeinfade out

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!

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Landern · Aug 30, 2016 at 07:28 PM 0
Share

Is screenfader unityscript/javascript? is it outside of the unity namespace(meaning it's been specified)?

avatar image phyzikalgamer Landern · Aug 31, 2016 at 08:58 AM 0
Share

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

avatar image mj321 · Aug 30, 2016 at 07:33 PM 0
Share

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.

avatar image phyzikalgamer mj321 · Aug 31, 2016 at 09:03 AM 0
Share

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);
     }
 }   

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

66 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[SOLVED]Fade in Fade out problem 1 Answer

What's the easiest way to fade a sprite in? - Looking for equiv of jQuery's fadeIn() 0 Answers

...Smashing myself endlessly in the face with a brick.. 0 Answers

How to fade in and out a image in a loop?,How do I fade in and out image on a loop? 0 Answers

I have New Game text/button in my Canvas/Scene and I want when I click New Game to fade out! READ MORE! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges