Search Unity

Load movieTexture from disk at run-time

Discussion in 'Scripting' started by aps502, Apr 30, 2015.

  1. aps502

    aps502

    Joined:
    Nov 14, 2014
    Posts:
    10
    Hi,

    I've managed to use this code to sucessfully load and play a OGV video stored in the Assets\Resources folder.

    However I'd like the user to load video from disk at run-time.

    I know how to do this for a standard image texture, by using .LoadImage in the Texture2D type (i.e. see http://forum.unity3d.com/threads/apply-image-to-plane-primitive.320489/#post-2080102 )

    But how to do this with a MovieTexture?

    Thanks
    A.

    Code (CSharp):
    1. public void loadVideo (GameObject container, string video)
    2.     {
    3.         // Load MovieTexture from Resources Folder
    4.         MovieTexture mat = (MovieTexture)Resources.Load(Path.GetFileNameWithoutExtension(video), typeof(MovieTexture));
    5.        
    6.         MeshRenderer ren = container.GetComponent<MeshRenderer>();
    7.         ren.material.mainTexture = mat;    
    8.         mat.Play();      
    9.     }
     
  2. aps502

    aps502

    Joined:
    Nov 14, 2014
    Posts:
    10
    Does the silence mean is noT possible?

     
  3. KingPeas

    KingPeas

    Joined:
    Aug 29, 2012
    Posts:
    10