- Home /
Any possibility to play a video in unity free?
^ This.
Thanks in advance
h4wkeye
(Seems like a reasonable question to me, up-voting out of negative land ...)
Answer by arky25 · Dec 28, 2012 at 01:28 PM
I wrote a script wich reads out all pictures out of a folder. You can use Virtualdub to make your clip to pictures, load the folder into unity 3d and then type in the name of the folder in the script. The script looks like this.
#pragma strict
var imageFolderName = "";
var MakeTexture = false;
var pictures = new Array();
var loop = false;
var counter = 0;
var Film = true;
var PictureRateInSeconds:float = 1;
private var nextPic:float = 0;
function Start () {
if(Film == true){
PictureRateInSeconds = 0.04166666666666666666;
}
var textures : Object[] = Resources.LoadAll(imageFolderName);
for(var i = 0; i < textures.Length; i++){
Debug.Log("found");
pictures.Add(textures[i]);
}
}
function Update () {
if(Time.time > nextPic){
nextPic = Time.time + PictureRateInSeconds;
counter += 1;
if(MakeTexture){
renderer.material.mainTexture = pictures[counter];
}
}
if(counter >= pictures.length){
Debug.Log("fertig");
if(loop){
counter = 0;
}
}
}
you have to create a Resources folder and put the folder with the pictures into that folder. But it works great!
thank you very much it wont let me thumbs up dont know why worked like a charm 100% credit to you AR$$anonymous$$Y25 saved the day for my project
Not sure why this answer got down-voted, but since it helped @brae out I thought it deserved to be voted back up. I also reformatted the code to be more readable -- @arky25, when posting code you can select the code block and hit the little 101 button to reformat it (basically it all needs to be indented).
If you have Photoshop cs6 then you can use it to create picture sequence from clips. Just go to File > Export > Render Video. Hope it help...
i can't make work ! i get this error ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count. Parameter name: index 3 System.Collections.ArrayList.ThrowNewArgumentOutOfRangeException (System.String name, System.Object actual, System.String message) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections/ArrayList.cs:3261)
Thanks!
try to add counter after the if(makeTexture) statement
if($$anonymous$$akeTexture){ renderer.material.mainTexture = pictures[counter]; }
nextPic = Time.time + PictureRateInSeconds;
counter += 1;
Answer by kahalany · Jul 06, 2012 at 01:49 PM
Hi, h4wkeye.
I wrote a script that does just that and more. You can find it in the asset store under the name "Universal Video Texture". Also with my script you're not limited to just a short video clip. Works perfectly with Unity free, web, ios and and Android.
Here's the link: http://u3d.as/content/royie-kahalany/universal-video-texture/35M
Have fun!
Royie
i hate spam as much as the next person but to be fair, it was relevant to the question
actually all of @kahalany 's posts have been on topic to the question being asked, and for the most part is offering a free option, so in reality it just it so happens/coincidence that he is able to copy and paste his answer with slight modification.
it seems more that you are spam$$anonymous$$g a comment to his answers then he is spam$$anonymous$$g answers.
@Tseng: It's not really unsolicited since that's exactly the topic of the question. He only posted his solution on questions with that specific topic. It's not spam if you post a link to a solution. The solution doesn't need to be free of charge, that's not a requirement for this site. A lot people developed middleware and put it on the AssetStore. I posed a lot links to assets on the store if it fits the question.
This site is a knowledge base all around unity. If someone needs to view a video with unity free, he will find a solution. If you have an open source solution feel free to post it here. The voting system should take care of what is a good and what's a bad solution.
@Tseng actually @Bunny83 was talking about my comment where I was directly stating the the solution being given was free.
and on the "he did help not a single person with a different problem" to which "so...?"
if a person feels that they are knowledgeable about a specific topic like AI for instance, and they only answered questions based on AI then by your logic that person would be unwanted. which just seems snobbish "you have to be able to help everybody with any kind of problem" then there would be no such thing as a specialist.
not to mention if this package does what it claims, and is related to the topic then that is not spam, and your viagra example is flawed for the same reason (once is a mention/answer to the problem 2 on the same page might start to be spam, and 3+ I would be messaging a mod myself).
now if he was going into a question about AI, and posting about his video asset package then I would be right beside you to the best of my ability, but he didn't he posted a solution to the problem of "Any possibility to play a video in unity free?" with "yes, and here is one of them" so like I said before. you purposefully going to each post he has made (which have all been on topic to the question being asked) and proclai$$anonymous$$g with some all-mighty statement "this is spam" is unfounded, and either spam itself, or trolling/harassing the user.
if you really feel that his answers are spam then flag them as such, and let a moderator decide otherwise just move on.
@Tseng It's relevant to the topic, it helps people and he's not selling anything. It's not spam, he just so happens to have something that helps in the context. So what that he's done it before. He's helped the poster way more than you have so please kindly shut the f. up unless you have something actually constructive to say. Thank you.
Answer by shuichi_saitoh · Mar 10, 2015 at 04:43 PM
With Unity 5 (free, personal edition), MoviewTexture seems working, although online manual denoted that MovieTexture is "Pro/Advanced only feature" yet, and it seems work only with .ogv (OGG Theora) format file (not working with .mp4, .mov file in my env).
I'm not sure it is defect of the Unity 5 editor, or is spec. but with the following steps the MovieTexture worked in my environment: 1. import .ogv file into unity project 2. drag&drop the .ogv file to a Plane, to assign the movie as the texture. 3. write a script using MovieTexture.Play() method as described in script reference, to play the movie
^Unity 5 ships w/ all the pro features that Unity 4 had, but for free.
Answer by Jason-H · Mar 31, 2011 at 03:29 PM
If it's a short video, you can render out each frame to an individual texture and cycle through the textures through code at whatever frame rate you need.
@jasonh - sorry for reply to old thread here, but I was thinking the same thing. Is there a way to use Unity's native Theora video decoder at runtime, grab each frame, and apply to a texture?
Answer by jonas-echterhoff · Mar 31, 2011 at 03:12 PM
Video support is limited to Unity Pro. If you are targeting the web player, you can show video using other plugins (QuickTime, Flash), and switch between them using JavaScript, though.