- Home /
WebGL - Upload photo to game from PC
Hi.
I'm created app for WebGL and have a question
How can I upload a photo to game from browser on PC?
Comment
Best Answer
Answer by dval · Jan 11, 2016 at 11:26 AM
You would need to handle it the same way you handle all user uploads to your server. You need an HTML Form for submitting the images, and a server that can handle uploads. Optionally, you could use something like SFTP if your just collecting textures from your team.
When you store the files, make sure they are in a readable directory. Then you can access them with:
public string url = "http://yourserver.com/uploads/webcamTexture.jpg";
IEnumerator Start() {
WWW www = new WWW(url);
yield return www;
Renderer renderer = GetComponent<Renderer>();
renderer.material.mainTexture = www.texture;
}
Docs for the WWW class.
Your answer
