Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by eddiebuildsmc · Apr 13, 2019 at 07:02 PM · button2d gamevideoclip

Showing the button when the VideoPlayer finishes

I am trying to make a final scene which starts with a short video. I've already managed to play the clip with the VideoPlayer GameObject, but the problem is that the button which is there as a part of the Canvas overlaps my video the whole time.

The button should be there to send you back to the main screen (basically to end and restart the game). Is there any way to make the button appear only when the video has finished playing? Or to hide the video when it stops playing? But in this case, how do I set my video to play in front of the button?

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 KevRev · Apr 17, 2019 at 08:42 PM 0
Share

Add a CanvasGroup to the Canvas.

I'll use dummy variables for the canvas group and the video. Change these for your variables.

 Start()
 {
   StartCoroutine(Play$$anonymous$$yVideo());
 }
 
 IENumerator Play$$anonymous$$yVideo()
 {
  cg.alpha=0;
  cg.interactable=false;
  video.Prepare();
  video.Play();
  While (video.IsPlaying())
  {
    yield return null;
  }
 cg.alpha=1;
 cg.interactable=true;
 }

$$anonymous$$ake sure you save everything before you run this, because if I've got the while loop wrong, you'll be stuck in an unbreakable loop.

I'm doing this from memory on my mobile so apologies if the code is not 100%.

avatar image NikitaDemidov KevRev · Apr 18, 2019 at 08:04 AM 0
Share

Shouldn't it be

StartCoroutine(Play$$anonymous$$yVideo());

Because else it isn't going to work, is it?

avatar image KevRev NikitaDemidov · Apr 18, 2019 at 09:49 AM 0
Share

Correct sorry. :)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by NikitaDemidov · Apr 17, 2019 at 08:03 PM

You can change the alfa-channel in your Button/Video.

Many Objects have a standard color. If you write obj.color = new Color(obj.color.r,obj.color.g,obj.color.b,0f); You can't see the Object. obj.color = new Color(obj.color.r,obj.color.g,obj.color.b,1f); makes the Object appear.

If the button is an UI-Sprite try this:

 void Start()
 {
 /*Starting the video(I don't know how to do this)*/
 Invoke("ButtonOk" , videolenght);
 }
 
 void ButtonOk()
 {
 
 Button.GetComponent<Image>().color = new Color(0, 0, 0, 1f);
 /*Add somthig like Button.getComponent<ButtonScr>().ButtonReady = true; Because else you still can press on the button even if it is invisible*/
 }

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

210 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 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 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 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 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 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 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 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 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 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

Implement a shoot button for Android Device 0 Answers

Problems recording my 2d game made with Unity (laggy / stuttering). 0 Answers

Image appearing after clicking a button 1 Answer

UI Text Editing Problem, What's Wrong? Need Anybody to Assist 1 Answer

Help! Create interactive button with an image + c# Script 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