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
1
Question by realfateh · Mar 06, 2013 at 12:46 AM · wwwvideomovietexture

how can i put button to stop this movie?

hello ; my main problem is because of i have to define var www = new WWW(url) into function i can't access from another function like OnGUI().

 var url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
 function Start () {
     // Start download
     var www = new WWW(url);
 
     // Make sure the movie is ready to start before we start playing
     var movieTexture = www.movie;
     while (!movieTexture.isReadyToPlay)
         yield;
 
 
     // Initialize gui texture to be 1:1 resolution centered on screen
     guiTexture.texture = movieTexture;
 
     transform.localScale = Vector3 (0,0,0);
     transform.position = Vector3 (0.5,0.5,0);
     guiTexture.pixelInset.xMin = -movieTexture.width / 2;
     guiTexture.pixelInset.xMax = movieTexture.width / 2;
     guiTexture.pixelInset.yMin = -movieTexture.height / 2;
     guiTexture.pixelInset.yMax = movieTexture.height / 2;
 
     // Assign clip to audio source
     // Sync playback with audio
     audio.clip = movieTexture.audioClip;
 
     // Play both movie & sound
     movieTexture.Play();
     audio.Play();
 }
 // Make sure we have gui texture and audio source
 @script RequireComponent (GUITexture)
 @script RequireComponent (AudioSource)
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 realfateh · Mar 06, 2013 at 09:17 AM 0
Share

thank you jbarba ;but my problem is i can't access to movieTexture from onGUI becuse of i define in into the start function.

avatar image hoy_smallfry · Mar 06, 2013 at 04:55 PM 0
Share

Then define it out of the Start function, like this:

 var movieTexture : $$anonymous$$ovieTexture;
 function Start () {
     www = new WWW(url);
     movieTexture = www.movie;
avatar image realfateh · Mar 06, 2013 at 11:00 PM 0
Share

thank you so much ;and one important question .how can i put a button to remove video from RA$$anonymous$$ because i have at least 30 video and when i play, video size goes to RA$$anonymous$$ and stay there when i play 10 video my RA$$anonymous$$ is completely full!! what do you think ?

2 Replies

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

Answer by Statement · Mar 06, 2013 at 03:05 PM

Just move the variable out of the function scope so it becomes a member variable.

 var www : WWW;
 var movieTexture : MovieTexture;
 function Start () {
     www = new WWW(url);
     movieTexture = www.movie;
Comment
Add comment · Show 2 · 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 realfateh · Mar 06, 2013 at 10:21 PM 0
Share

thank a lot Statement ♦♦ .and one important question .how can i put a button to remove video from RA$$anonymous$$ because i have at least 30 video and when i play, video size goes to RA$$anonymous$$ and stay there when i play 10 video my RA$$anonymous$$ is completely full!! what do you think ?

avatar image Statement · Mar 07, 2013 at 12:34 AM 0
Share

So, the video is going to be loaded into RA$$anonymous$$. What you should do is dispose of the www object (www.Dispose();) and unload the movie texture. I can't remember from the top of my head if you should use Resources.UnloadAsset() or Object.Destroy() but it should be one or another I think. If you use the wrong one I am sure the log will tell you.

avatar image
0

Answer by hoy_smallfry · Mar 06, 2013 at 04:56 PM

Something like this?

 void OnGUI()
 {
     string label = movieTexture.isPlaying ? "Pause" : "Play";
     if(GUILayout.Button(label))
     {
         if(movieTexture.isPlaying)
         {
             movieTexture.Pause();
         }
         else
         {
             movieTexture.Play();
         }
     }
 }

Then define it outside of the Start function, like this:

 var movieTexture : MovieTexture;
 function Start () {
     www = new WWW(url);
     movieTexture = www.movie;
     // ... rest of the code.

That way, both functions can use it!

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

12 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

Related Questions

Splash videos on android and iOS? 0 Answers

Smooth Synchronized HD Video Playback 0 Answers

MovieTexture .ogg file size limit? 0 Answers

Movie Texture - lost first few seconds and long start up times 2 Answers

WWW.movie doesn't work 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