• 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 /
avatar image
Question by Diego89 · Apr 17, 2014 at 12:47 PM · androidjavascriptpreloader

Error BCW0015 and BCW0023 but they both work, how to solve it?

Hi Guys,

I'm working on a Android application in Unity I have wrote a script, that works perfectly however the engine gives me to warning. Can you help me.

 #pragma strict
 
 var async: AsyncOperation = null;
 var TText : TextMesh;
 
 
 private var Tfloar : float;
 private var Tint : int;
 
 private var Once : boolean = true;
 
 private var Text1 : String = "info1";
 private var Text2 : String = "info2";
 private var Text3 : String = "info3";
 private var Text4 : String = "info4";
 private var Text5 : String = "info5";
 private var Text6 : String = "info6";
 private var Text7 : String = "info7";
 private var Text8 : String = "info8";
 private var Text9 : String = "info9";
 private var Text10 : String = "info10";
 private var Text11 : String = "info11";
 private var Text12 : String = "info12";
 private var Text13 : String = "info13";
 private var Text14 : String = "info14";
 private var Text15 : String = "info15";
 private var Text16 : String = "info16";
 private var Text17 : String = "info17";
 private var Text18 : String = "info18";
 private var Text19 : String = "info19";
 private var Text20 : String = "info20";
 
 var TLevelCount : LevelCount = null; 
 
 function Update () 
 {
     
     if (TLevelCount == null) // search for an object call LevelCountOb
     {
         TLevelCount    = GameObject.Find("LevelCountOb").GetComponent(LevelCount);
     }
     
     if (TLevelCount != null) // if he found the object 
     {
         switch (TLevelCount.LevelToLoad)
         {
             case 2:
                 if (Once)
                 {
                     Once = false;
                     Load();
                     TText.text = GetRandom();
                 }
                 break;
             case 3:
                 if (Once)
                 {
                     Once = false;
                     Load();
                     TText.text = GetRandom();
                 }
                 break;
             case 4:
                 if (Once)
                 {
                     Once = false;
                     Load();
                     TText.text = GetRandom();
                 }
                 break;
             case 5:
                 if (Once)
                 {
                     Once = false;
                     Load();
                     TText.text = GetRandom();
                 }
                 break;
             case 6:
                 if (Once)
                 {
                     Once = false;
                     Load();
                     TText.text = GetRandom();
                 }
                 break;
             case 7:
                 if (Once)
                 {
                     Once = false;
                     Load();
                     TText.text = GetRandom();
                 }
                 break;
             case 8:
                 if (Once)
                 {
                     Once = false;
                     Load();
                     TText.text = GetRandom();
                 }
                 break;
         }
     }
         
 }
 
 function Load()// load another level
 {
     if (TLevelCount != null && async == null)
     {
         async = Application.LoadLevelAsync(TLevelCount.LevelToLoad);
         yield async;
     }
 }
 
 function GetRandom(): String // get the information
 {
     var RandoT : int = Random.Range(1, 21);
     
     print("the random number is: " +RandoT);
 
     switch (RandoT)
     {
         case 1:
             return Text1;
             break;
         case 2:
             return Text2;
             break;
         case 3:
             return Text3;
             break;
         case 4:
             return Text4;
             break;
         case 5:
             return Text5;
             break;
         case 6:
             return Text6;
             break;
         case 1:
             return Text1;
             break;
         case 7:
             return Text7;
             break;
         case 8:
             return Text8;
             break;
         case 9:
             return Text9;
             break;
         case 10:
             return Text10;
             break;
         case 11:
             return Text11;
             break;
         case 12:
             return Text12;
             break;
         case 13:
             return Text13;
             break;
         case 14:
             return Text14;
             break;
         case 15:
             return Text15;
             break;
         case 16:
             return Text16;
             break;
         case 17:
             return Text17;
             break;
         case 18:
             return Text18;
             break;
         case 19:
             return Text19;
             break;
         case 20:
             return Text20;
             break;
     }
 
 }

Now t$$anonymous$$s error Assets/Script/PreLoaderBar.js(137,10): BCW0023: WARNING: T$$anonymous$$s method could return default value implicitly. happen on get random

and the second one Assets/Script/PreLoaderBar.js(143,9): BCW0015: WARNING: Unreachable code detected. the Switch.

The code works but I would like to know where is the problem.

Thank you

Comment

People who like this

0 Show 3
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 Graham-Dunnett ♦♦ · Apr 17, 2014 at 01:50 PM 1
Share

BCW0015 is probably related to your break after each return. If the function returns it never gets to the break. If you can highlight what your line 137 is, we can probably work out what that BCW0023 is.

avatar image Graham-Dunnett ♦♦ · Apr 17, 2014 at 01:58 PM 1
Share

Actually, spoke too soon. BCW0023 means that your function GetRandom can get to the end of the switch statement, and hit the end of the function and not return anything. Or, put another way, if I call GetRandom(-42) what string should I get?

avatar image jonSG · Apr 17, 2014 at 03:05 PM 0
Share

I don't know unity script so this is just a guess, but I think you might simplify your code using:

 #pragma strict
  
 var async: AsyncOperation = null;
 var TText : TextMesh;
 private var Tfloar : float;
 private var Tint : int;
 private var Once : boolean = true;
 private var myText : String[] = [];
 var TLevelCount : LevelCount = null; 
 
 function Start () 
 {
   myText = [
               "info1",  "info2",  "info3",  "info4",  "info5",  "info6",  "info7",  "info8",  "info9",
     "info10", "info11", "info12", "info13", "info14", "info15", "info16", "info17", "info18", "info19",
     "info20"
   ];
 }
  
 function Update () 
 {
   if (TLevelCount == null) {
     TLevelCount = GameObject.Find("LevelCountOb").GetComponent(LevelCount);
   } else if ( Once ) {
     Once = false;
     Load(TLevelCount.LevelToLoad);
     TText.text = GetRandom();
   }
 }
  
 function Load(LevelToLoad : int)// load another level
 {
   if (async != null) { return; }
   async = Application.LoadLevelAsync(LevelToLoad);
   yield async;
 }
  
 function GetRandom(): String // get the information
 {
     var RandoT : int = Random.Range(0, myText.length);
     print("the random number is: " + RandoT);
     return myText[RandoT];
 }

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Diego89 · Apr 17, 2014 at 06:52 PM

thank you the problem was releated to the multiple return break

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

22 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

Related Questions

How do i need to change this script for mobile? 1 Answer

Please Help!!! my LineRenderer Script is not show when bulid on android device 1 Answer

Mobile Tap Issue 1 Answer

Access Violation 0xc0000005) in module Unity.exe 0 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers


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