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 bryanbob · Jan 22, 2014 at 08:01 AM · c#movietexture

How to make a seamless transition between movie clips?

Hello everyone. I have a few movie clips which need to be played based on user input. I have created the script but the problem is, it blinks while changing to next clip. Below are the example of my script.

c# Code

void update() { renderer.material.mainTexture = movieTexture1; movieTexture1.Play();

//movieTexture1 only play once

if(movieTexture1.isPlaying == false) { renderer.material.mainTexture = movieTexture2; movieTexture2.Play(); } }

i simply play the next clip after the current one stopped. Are there another way to do it? Thank You for your help.

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
0

Answer by Drakulo · Jan 22, 2014 at 10:05 AM

To remove the blink effect, you can use 2 different GameObjects associated with the proper movie clip as texture. Instead of changing the texture, enable or disable the GameObjects and start playing the movierespectively.

Example : GameObject A linked to movie A, GameObject B linked to movie B. Start with A enabled and B disabled. To switch from A to B, disable A, enable B and start playing the B movie texture.

Comment
Add comment · Show 1 · 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 bryanbob · Jan 23, 2014 at 03:55 AM 0
Share

thanks Drakulo. i've created the script but it still blinks. i don't think my script was correct. i've posted the script in the thread

avatar image
0

Answer by bryanbob · Jan 23, 2014 at 03:49 AM

thank you Drakulo for the reply. Im totally new with unity scripting. to be more detail, i've created three plane objects with movieTexture. following are the script to play the clip. with this script, it blinks when playing the next clip:

 using UnityEngine;
 using System.Collections;
 
 public class PlayMovieClip2 : MonoBehaviour {
 
     public int ind= 0;
 
     public GameObject g1;
     public GameObject g2;
     public GameObject g3;
     
     // Use this for initialization
     void Start () {
     }
     bool once = true;
     // Update is called once per frame
     void Update () {
 
         if(ind==0)
         {
             g1.SetActive (true);
             //renderer.enabled = true;
             (g1.renderer.material.mainTexture as MovieTexture).Play ();
             if(once)
             {
                 StartCoroutine(PlayNext((g1.renderer.material.mainTexture as MovieTexture).duration, 1));
                 once = false;
             }
 
             g2.SetActive (false);
             g3.SetActive (false);
         }
         else if(ind==1)
         {
             g2.SetActive (true);
             //renderer.enabled = true;
             (g2.renderer.material.mainTexture as MovieTexture).Play ();
             if(once)
             {
             StartCoroutine(PlayNext((g2.renderer.material.mainTexture as MovieTexture).duration, 2));
                 once = false;
             }
             g1.SetActive (false);
             g3.SetActive (false);
         }
         else if(ind==2)
         {
             g3.SetActive (true);
             //renderer.enabled = true;
             (g3.renderer.material.mainTexture as MovieTexture).Play ();
             if(once)
             {
                 StartCoroutine(PlayNext((g3.renderer.material.mainTexture as MovieTexture).duration, 3));
                 once = false;
             }
             g2.SetActive (false);
             g1.SetActive (false);
 
 
         }
         else
         {
             g1.SetActive (false);
             g2.SetActive (false);
             g3.SetActive (false);
         }
     }
     
     private IEnumerator PlayNext(float duration, int idx)
     {
         yield return new WaitForSeconds(duration);
         ind = idx;
         once=true;
     }
 }
Comment
Add comment · Show 1 · 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 Drakulo · Jan 23, 2014 at 11:40 AM 0
Share

You should not call Play more than once. This method starts playing the movie clip on your texture so calling it every frame can produce unwanted behaviours. Secondly, ins$$anonymous$$d of using a custom code to manage the video reading only once, there is a variable to manage this : $$anonymous$$ovieTexture.loop.

Cut your code in small methods, it makes it easier to understand / debug.

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

19 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

Related Questions

Multiple Cars not working 1 Answer

Video Scrubber Bar & Rewind using MovieTexture? 0 Answers

Distribute terrain in zones 3 Answers

A node in a childnode? 1 Answer

How to toggle the visibility of GUI Button 3 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