Search Unity

Problem: How to use a RawImage with Simple MovieTextures for Unity WebGL

Discussion in 'UGUI & TextMesh Pro' started by Rissatto, Jun 27, 2016.

  1. Rissatto

    Rissatto

    Joined:
    Mar 16, 2013
    Posts:
    5
    Hello

    In my project i’m using a RawImage to play videos with the asset “Simple MovieTextures for Unity WebGL” (WebGLMovieTextures) on GUI.

    The problem is: On MovieTexture the old WebPlayer works well, but on WebGLMovieTextures in RawImage i get only audio.

    Can you help me with this issue. Or show me how to use in a RawImage?

    I tried both ways, this:

    Code (CSharp):
    1. movie = new WebGLMovieTexture("StreamingAssets/videos/video_name.mp4");
    2. GetComponent<RawImage> ().material = new Material (Shader.Find("Diffuse"));
    3. GetComponent<RawImage> ().material.mainTexture = movie;
    4. movie.Play ();
    and this:

    Code (CSharp):
    1. movie = new WebGLMovieTexture("StreamingAssets/videos/video_name.mp4");
    2. GetComponent<RawImage> ().texture = movie;
    3. movie.Play ();
    with no success...
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    You might want to try using the CanvasRender material rather than the RawImage material. Not tried it myself but you might have more success with that. Also be sure to test with different Canvas Types.
     
    Rissatto likes this.
  3. Rissatto

    Rissatto

    Joined:
    Mar 16, 2013
    Posts:
    5
    Like this?

    Code (CSharp):
    1. GetComponent<CanvasRenderer> ().SetTexture(movie);
    Same behavior :(
     
    Last edited: Jun 28, 2016
  4. Rissatto

    Rissatto

    Joined:
    Mar 16, 2013
    Posts:
    5
    I got it! I had to change WebGLMovieTexture.cs

    Code (CSharp):
    1. WebGLMovieTextureUpdate(m_Instance, m_Texture.GetNativeTextureID());
    To
    Code (CSharp):
    1. WebGLMovieTextureUpdate(m_Instance, m_Texture.GetNativeTexturePtr().ToInt32());
    and now the texture works with the this code:

    Code (CSharp):
    1. movie = new WebGLMovieTexture("StreamingAssets/videos/video_name.mp4");
    2. GetComponent<RawImage> ().texture = movie;
    3. movie.Play ();
     
    SimonDarksideJ likes this.
  5. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
    Facing the same issue.. I tried Rissatto's solution but it doesn't work..
     
  6. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
    Do you use some material for the RawImage?
    Anyway, I'm really stuck here, really need help :confused:
     
  7. cgmagic

    cgmagic

    Joined:
    Oct 5, 2013
    Posts:
    12
    Has anyone got it to work ? I am trying the same thing, but did not work with Rissatto's solution neither.
     
  8. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
  9. Gerfeso

    Gerfeso

    Joined:
    Mar 2, 2016
    Posts:
    5
  10. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
    Do you refer to the seeking issue or the video not being rendered on a RawImage?