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 snedgel · Mar 04, 2013 at 05:22 PM · buttonvideopauseclick

Play a video ingame by clickin on gameobject

All is in the title :) I just search how to play an video when i click with the mouse on an gameobject and put it in pause when i re click on the same ( or other ) game object .

I'm very bad at scripting and here is where i am with the script ^^ :)

 var PlayButton : GameObject;
 
 function OnMouseDown () {
     renderer.material.mainTexture.Play();
 }


Thanks for helping

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by snedgel · Mar 05, 2013 at 01:02 PM

Doesn't work .... On what i have to click to start the video ?

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
avatar image
0

Answer by 3dws · Mar 05, 2013 at 10:47 AM

do you import your video clip in unity and assign it to material of the object? do you know that u must use the Quicktime movie clips in unity3d? if not , u must convert it in .mov clip

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 snedgel · Mar 05, 2013 at 10:51 AM 0
Share

I have a .mov ;)

I have no problem to run the video with

 renderer.material.mainTexture.Play();

But i want to click to a specific gameobject to run the video

avatar image 3dws · Mar 06, 2013 at 06:22 AM 0
Share

ok u must use 2 object . 1 for move texture (movie object) and other for Play Button .

U must create 1 script for play button and in it u must access to movie object .

u can use this code on Play Buttonobject:

 var move : GameObject;
 
 function start(){
 move= GameObject.Find("movieobject"); 
 // now u can access to movie object
 }
 
 
 function On$$anonymous$$ouseDown () {
  
        if (move.renderer.material.mainTexture.isPlaying) {
          move.renderer.material.mainTexture.Pause();
        }
        else {
          move.renderer.material.mainTexture.Play();
  
     }
 }
avatar image snedgel · Mar 08, 2013 at 10:15 AM 0
Share

Thanks, it works :)

But now i have an another problem . $$anonymous$$y video start when i press the playmode ... I just want to play the video when i click on the Gameobject " PlayButton" .

avatar image fabio1955 · Mar 08, 2013 at 10:34 AM 0
Share

Is the PlayButton a separate Object? If so drop the start function and assign the movie using the inspector. If not so split the original mesh in two or more parts..

avatar image
0

Answer by fabio1955 · Mar 05, 2013 at 02:03 PM

On mousedown will work on the object the script is attached to. Did you attach the script to some object? Just asking because you said you are "very bad at scripting"...

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

13 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

Related Questions

pause game 2 Answers

Unity android button and Time.timescale problems 1 Answer

A node in a childnode? 1 Answer

GUITexture OnMouseDown Problem 1 Answer

Button at one end of the room opens door on other 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