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 Drum · May 21, 2012 at 04:57 PM · guitextureplanemovie

Move Texture From Plane To GUI And Back

Hi,

I have several planes moving in straight lines across my scene. Each plane has its assigned texture. What I want to be able to do is, on clicking the plane, the texture is displayed in a screen centered static GUI. On clicking this GUI, the texture is re-displayed on the plane, at whatever point the plane has since moved to.

This is my script, which does about half the job, but fails to consistantly react to clicks at all and, though it will clear the GUI texture, it won't then re-display it as required.

tia for any help.

 var url : String;
 var baseurl = "www.someurl.com/filename";
 var filext = ".ogg";
 var num : int;
 var thisTex : MovieTexture;
 var movTexture : MovieTexture;
 var obSpeed : int;
 var isGUI : boolean = false;
 
 
 
 function zoomToGUI(){
     isGUI = true;
     while (!movTexture.isReadyToPlay)
         yield;
     obSpeed = 0;
     guiTexture.enabled = true;
     guiTexture.texture = movTexture;
     transform.Translate(obSpeed * Vector3.up * Time.deltaTime * 2);
     transform.localScale = Vector3 (0,0,0);
     transform.position = Vector3 (0.5,0.5,0);
     guiTexture.pixelInset.xMin = -movTexture.width / 2;
     guiTexture.pixelInset.xMax = movTexture.width / 2;
     guiTexture.pixelInset.yMin = -movTexture.height / 2;
     guiTexture.pixelInset.yMax = movTexture.height / 2;
     // Play movie
     movTexture.Play();
 }
 function playVid(){
     isGUI = false;
     var www = new WWW(url);
     renderer.enabled = false;
     // Make sure the movie is ready to start before we start playing
     movTexture = www.movie;
     while (!movTexture.isReadyToPlay)
         yield;
     obSpeed = 2;
     movTexture.loop = true;
     renderer.enabled = true;
     renderer.material.mainTexture = movTexture;
     movTexture.Play();
     if(movTexture.isPlaying){
         // do nothing
     }else{
         yield WaitForSeconds(5);
         renderer.enabled = false;
     }
 }
 
 function OnMouseDown(){
     if(isGUI == false){
         zoomToGUI();
     }else{
         guiTexture.enabled = false;
         playVid();
     }
 }
 
 function Start () {
     url = baseurl + num + filext;
     playVid();
     // Start download
 }
 
 function Update() {
     transform.Translate(obSpeed * Vector3.up * Time.deltaTime);
 }
 @script RequireComponent (GUITexture)
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 whydoidoit · May 21, 2012 at 06:24 PM 0
Share

Is your redisplay problem down to the fact that zoo$$anonymous$$g to the GUI sets the local transforms scale to 0,0,0 and nothing sets it back? You might be better off just disabling the renderer on the current component rather than doing that scale if that's the effect you are after.

What kind of collider are you using on the component?

avatar image Drum · May 22, 2012 at 08:54 AM 0
Share

It could well be as you say. This is my first real project, so I am still very much learning about the relationship between GUI elements and GameObjects. The moving planes just use a box collider. I could try destroying the plane when it zooms to the GUI, then instantiating another plane when the GUI element is clicked.

avatar image whydoidoit · May 22, 2012 at 10:09 AM 0
Share

Don't destroy the plane, just turn off then renderer with renderer.enabled = false in ZoomToGUI - then don't change the localScale and let me know what the effect is then...

avatar image Drum · Jun 08, 2012 at 02:29 PM 0
Share

localScale was the issue, thanks, I now have it working.

0 Replies

· Add your reply
  • Sort: 

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

Make a Button out of a Textured Plane 2 Answers

Make a movie texture rewind (play again) 3 Answers

Movie GUI Texture Alpha? 1 Answer

Creating a 2D game using planes with textures 1 Answer

Problem With GUI Circle Thickness 0 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