Alright, Ive asked this various ways but my situation is I have several (over 100) objects that have screens that need to play animated videos on them. There does not need to be sound, but this is for VR so performance is an issue.
So far, after trying render textures and video materials and seeing that fps dropped, Ive been using this script to flip through sets of pngs and put them in the diffuse slot of a material:
public class VideoPlayerRawImage : MonoBehaviour
{
public Texture[] frames;
public int framesPerSecond = 60;
public bool isEmissive = false;
void Update()
{
int index = (int)(Time.time * framesPerSecond) % frames.Length;
this.GetComponent<Renderer>().material.mainTexture = frames[index];
if(isEmissive)
{
this.GetComponent<Renderer>().material.SetTexture("_EmissionMap", frames[index]);
}
if(index >= frames.Length-1)
{
index = 0;
}
}
Is this the most efficient way to play videos? What would be a drawback to this method/is there a better way?
VideoPlayer
? \$\endgroup\$ – TomTsagk Feb 18 '19 at 10:01.sharedMaterial
through only one of theRenderer
s. \$\endgroup\$ – Philipp Feb 19 '19 at 15:32