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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
2
Question by MikeGameDev · Apr 05, 2015 at 04:30 AM · uiunity5movietexture

MovieTexture in UI Panel

I'm trying to play a video in the UI, with my canvas in Screen Space Camera Render Mode.

I've something similar in the past with the old UI system, but I'm trying to do this with the Unity 5's new UI system.

Alternatively, I can set the render mode to World Space and place a Quad where I want to display the video, the only problem with this is that I would need to resize the size of my orthographic camera based on the size of the canvas. Is there a built in way to this?

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

2 Replies

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

Answer by moxiewhimsy · Apr 05, 2015 at 04:49 AM

You can do this with a UI > RawImage component. Set the Movie Texture as the Texture of the RawImage component. The Material field can be used to dress up the playback.

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 MikeGameDev · Apr 05, 2015 at 05:29 AM 0
Share

Works perfectly. Thanks!

avatar image moxiewhimsy · Apr 05, 2015 at 05:35 AM 1
Share

No problem. :) Also note you can use the same method to add Render Textures to the new UI.

avatar image MikeGameDev · Apr 05, 2015 at 05:37 AM 0
Share

Oh snap, just remembered render textures are free now. Will definitely play with this in the future :)

avatar image magonicolas · Dec 21, 2016 at 03:07 PM 0
Share

How do I play the video?

avatar image
2

Answer by Fattie · Jul 03, 2015 at 08:09 AM

In conjunction to Moxie's answer and to save someone some typing, here's a handy script - just attach it to the RawImage and play

Use space, and use WADX, QE, ZC and S keys.

 /*
 (C) 2015
 your R&D lab
 */
 
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using UnityEngine.Events;
 
 public class MovieDev:MonoBehaviour
     {
     
     MovieTexture mt;
     RectTransform rt;
     Vector2 origPos;
     
     void Awake()
         {
         rt = GetComponent<RectTransform>();
         origPos = rt.anchoredPosition;
         
         
         RawImage rim = GetComponent<RawImage>();
         mt = (MovieTexture)rim.mainTexture;
         }
     
     void Update()
         {
         
         if (Input.GetButtonDown("Jump"))
             {
             if (mt.isPlaying)
                 {
                 mt.Stop();
                 }
             else
                 {
                 mt.Stop();
                 mt.Play();
                 }
             }
         
         if (Input.GetKeyDown(KeyCode.W))
             rt.Translate(0f, 1f, 0f);
         if (Input.GetKeyDown(KeyCode.X))
             rt.Translate(0f, -1f, 0f);
             
         if (Input.GetKeyDown(KeyCode.A))
             rt.Translate(-1f, 0f, 0f);
         if (Input.GetKeyDown(KeyCode.D))
             rt.Translate(1f, 0f, 0f);
         
         if (Input.GetKeyDown(KeyCode.S))
             {
             rt.anchoredPosition = origPos;
             rt.eulerAngles = Vector3.zero;
             rt.localScale = new Vector3( 1f, 1f, 1f );
             }
         
         if (Input.GetKeyDown(KeyCode.Q))
             rt.Rotate(0f, 0f, .25f);
         if (Input.GetKeyDown(KeyCode.E))
             rt.Rotate(0f, 0f, -.25f);
         
         if (Input.GetKeyDown(KeyCode.Z))
             {
             float scaleNow = rt.localScale.x;
             if (scaleNow < 0.5f ) return;
             scaleNow = scaleNow - 0.01f;
             rt.localScale = new Vector3( scaleNow, scaleNow, 1f );
             }
         if (Input.GetKeyDown(KeyCode.C))
             {
             float scaleNow = rt.localScale.x;
             if (scaleNow > 1.5f ) return;
             scaleNow = scaleNow + 0.01f;
             rt.localScale = new Vector3( scaleNow, scaleNow, 1f );
             }
         
         }
 }


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

22 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

Related Questions

why the slider does not appear in correct place in the game view ? 0 Answers

I can't click to an UI button. 3 Answers

Unity UI handling 2 touches 1 Answer

UI Callout-Label for Parts of a 3D Model?? 1 Answer

Does Unity UI System have a foldable field? 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