Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
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 this error Assets/Script/PreLoaderBar.js(137,10): BCW0023: WARNING: This 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
Add comment · 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 : Text$$anonymous$$esh;
 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
0

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

thank you the problem was releated to the multiple return break

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

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 to make Headbobber on joystick Android 2 Answers

'GetComponent' is not a member of 'Object'. 2 Answers

Is there a way to scale everything in my game (GUI, text size, etc.) on Android in Javascript? 2 Answers

How to email highscore through android? 2 Answers

How To Create Android 3d Game Jump Button 2 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