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 British89 · May 16, 2012 at 10:55 PM · webplayerstream

Webplayer Stream problem

Hello, I have a java script that acts as my menu in game, The game build is a Webplayer "Streamed"

I want the script to display a GUItexture and disable the menu while the scene is being loaded and then load into the scene once its 100%

The first part of the script works but nothing happens after the else{ statement

 if(GUI.Button (Rect ((Screen.width/2)-350,(Screen.height/2)-100,80,20), "Play")) {
    if (Application.GetStreamProgressForLevel(1) == 1)
       Application.LoadLevel ("Scene");
       else {
             percentageLoaded = Application.GetStreamProgressForLevel(1) * 100;
             GetComponent(GUITexture).enabled = true;
             GetComponent(MainMenu).enabled = false;
             guiText.text = percentageLoaded.ToString();
             
       }  
    }
Comment
Add comment
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

1 Reply

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

Answer by Bunny83 · May 16, 2012 at 11:16 PM

I guess you want it like this:

 function Start()
 {
     GetComponent(GUITexture).enabled = true;
     GetComponent(MainMenu).enabled = false;
 }
 
 function OnGUI()
 {
     if (Application.GetStreamProgressForLevel(1) == 1)
     {
         if(GUI.Button (Rect ((Screen.width/2)-350,(Screen.height/2)-100,80,20), "Play"))
         {
             Application.LoadLevel ("Scene");
         }
     }
     else
     {
         percentageLoaded = Application.GetStreamProgressForLevel(1) * 100;
         guiText.text = percentageLoaded.ToString();
     }  
 }

This will display your GUITexture while the progress is below 1.0 and when it's fully loaded, show the GUI.Button to load the level.

You might want to disable your GUITexture and the GUIText once the level is loaded...

Comment
Add comment · Show 4 · 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
avatar image British89 · May 16, 2012 at 11:48 PM 0
Share

Thanks what you added kind of showed me the way, I got the GUItexture to enable and the menu to disable AFTER i have pressed the "Play" button, The GUItexture is a loading screen image so i want that to display untill the next scene has fully streamed to 100% and then to automatically load the next scene, The problem im having is, Without me pressing the Play button, the game will just start anyway once its 100%, So how do i get it to wait untill i have pressed play before loading the scene? Here is were i am at the moment

 if(GUI.Button (Rect ((Screen.width/2)-350,(Screen.height/2)-100,80,20), "Play")) {
    if (Application.GetStreamProgressForLevel(1) == 1)
       GetComponent(GUITexture).enabled = true;
       GetComponent($$anonymous$$ain$$anonymous$$enu).enabled = false;
       percentageLoaded = Application.GetStreamProgressForLevel(1) * 100;
       guiText.text = percentageLoaded.ToString();
     }  else {
            if (Application.GetStreamProgressForLevel(1) == 100)
             percentageLoaded = Application.GetStreamProgressForLevel(1) * 100;
             Debug.Log("Game started without pressing play");
             
       }
avatar image Bunny83 · May 17, 2012 at 01:37 AM 0
Share

Uhmm... why do you still have the GUI button around all this? That would mean all that code is only executed once when you pressed the button...

Also a GUI.Button only works inside the OnGUI function...

Your code is now a total chaos and doesn't make any sense. Your indention is also wrong, maybe you want to check your brackets and logic...

I will edit my answer to show this code snippet in a full script.

avatar image British89 · May 17, 2012 at 01:58 AM 0
Share

Yeah its a mess first time trying to get things to work with strea$$anonymous$$g webplayer

 var $$anonymous$$enu$$anonymous$$usic : AudioClip;
 var buttonColor : Color = Color.red;
 var BackgroundColor : Color = Color.green;
 private var about : boolean = false;
 private var chooseQuality : boolean = false;
 function Start(){
    //Set Time Scale
    Time.timeScale = 1.0;
    //Find Cam
    transform.position = camera.main.transform.position;
    //Add Audio and Play It
    gameObject.AddComponent(AudioSource);
    audio.volume = .5;
    audio.clip = $$anonymous$$enu$$anonymous$$usic;
    audio.Play();
    audio.loop = true;
    //----------------------------------
 }
 function Update (){
    //Unlock $$anonymous$$ouse
    Screen.lockCursor = false;
 }
 function OnGUI (){
    //Gui Color
     GUI.contentColor = buttonColor;
     GUI.backgroundColor = BackgroundColor;
     //Buttons
     
     if(GUI.Button (Rect ((Screen.width/2)-350,(Screen.height/2)-100,80,20), "Play")) 
     {
         if (Application.GetStreamProgressForLevel(1) == 1)
             GetComponent(GUITexture).enabled = true;
               GetComponent($$anonymous$$ain$$anonymous$$enu).enabled = false;
               percentageLoaded = Application.GetStreamProgressForLevel(1) * 100;
               guiText.text = percentageLoaded.ToString();
         }else{
                if (Application.GetStreamProgressForLevel(1) == 100)
                 percentageLoaded = Application.GetStreamProgressForLevel(1) * 100;
                 Debug.Log("Game started without pressing play");
 
           }      
    
    if(GUI.Button (Rect ((Screen.width/2)-350,(Screen.height/2)-50,80,20), "Options")) {
       //
       QualityOn();
    }
    if(GUI.Button (Rect ((Screen.width/2)-350,(Screen.height/2),80,20), "Controls")){
       AboutOn();
       
    }
    if(GUI.Button (Rect ((Screen.width/2)-350,(Screen.height/2) + 100,80,20), "Quit")){
       //Quit
       Application.Quit();
    }
    //Others
    if(about){
       GUI.color = Color.white;
       GUI.Label(Rect ((Screen.width/2) - 250,(Screen.height/2) - 100,500,500), GUIContent("$$anonymous$$OVE: W-A-S-D \n\n" +"RUN: Shift \n\n" + "JU$$anonymous$$P: Space \n\n"+"CROUCH: Ctrl \n\n"+"Shot: $$anonymous$$ouse1 \n\n"
       + "AI$$anonymous$$: $$anonymous$$ouse2 \n\n" + "SWITCH WEAPONS: $$anonymous$$ouse Wheel \n\n" + "FIRE $$anonymous$$ODE: Q \n\n" + "USE: E \n\n" + "LIGHT: F \n\n"));
       
       //Do not remove this
       
       //GUI.Label(Rect ((Screen.width/2) - 250,(Screen.height/2) + 250,500,500);
    }
    if(chooseQuality){
       about = false;
       //Give a Label
       GUI.Label(Rect ((Screen.width/2)-200,(Screen.height/2) - 100,100,40), "Quality Settings");
       
       if(GUI.Button (Rect ((Screen.width/2)-20,(Screen.height/2)-50,80,20), "High")){
          QualitySettings.currentLevel = QualityLevel.Fantastic;
          chooseQuality = false;
       }
       if(GUI.Button (Rect ((Screen.width/2)-120,(Screen.height/2)-50,80,20), "$$anonymous$$edium")){
          QualitySettings.currentLevel = QualityLevel.Good;
          chooseQuality = false;
       }
       if(GUI.Button (Rect ((Screen.width/2)-220,(Screen.height/2)-50,80,20), "Low")){
          QualitySettings.currentLevel = QualityLevel.Fastest;
          chooseQuality = false;
       }
    
    }
 }
 function AboutOn (){
    about = true;
    chooseQuality = false;
    yield WaitForSeconds(10);
    about = false;
 }
 function QualityOn (){
    chooseQuality = true;
    about = false;
 }
avatar image British89 · May 17, 2012 at 02:03 AM 0
Share

Basically how i have this set out, there are currently 3 scenes, Scene 0 = is splash screen transaction Scene 1 = $$anonymous$$ain menu Scene 2 = Game

The thing im having trouble with is the fact its s$$anonymous$$$$anonymous$$g, So by the time the main menu has loaded the "Start" button wont load the game as its not fully streamed to 100% yet so im stuck looking at the main menu, So i want it to show a loading screen after i press the play button, once its at 100% the game scene loads in.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

RTMP Video Stream in Unity 2 Answers

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

unityplayer problem on mac 2 Answers

Why won't the webplayer work after I install it? 3 Answers

How To Use LoadUnityWeb To Load a New Webplayer 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