- Home /
How to download pdf in virtual art gallery
Hi,
I'm a teacher who is trying to learn a bit about Unity to create a 3D art gallery to showcase our students' artworks.
A mockup trial version is here: http://www.mylongrun.com/smartmaths/WebPlayer.html
As you can see, you can click on a canvas and it will open a pdf file which contains info about that artwork. Each student will submit their own jpg (to go on the canvas) and their own pdf (which will describe their artwork)
Problem: At the moment, the pdf loads in the same window as the unity game. Therefore, it's not very practical. You can read the pdf, but if you want to look at another, you've got to hit the back button, which then takes you to the start, and re-loads the project.
Question: Is it possible to alter the script below, so that the pdf opens in a new tab or new window in the user's browser?
Thanks very much for your time,
Dave
Script:
var url = "url"; var link = "link"; var range : float; var theplayer : GameObject; var loaded : boolean;
var loadingimage : Texture2D;
function Update () {
range=Vector3.Distance(theplayer.transform.position,transform.position); if (range<25 && loaded==false){ loaded=true; getimage(); } }
function getimage(){ renderer.material.mainTexture = loadingimage; // access url var www : WWW = new WWW (url);
// wait yield www;
// place image renderer.material.mainTexture = www.texture; }
function OnMouseDown () { Application.OpenURL (link); }
Hello Dave! For the future please format your code, it makes it so much easier to read. :) To do this, when composing your question, select your code and press the Code Sample button. (the one with the 101010). Have a great day!
Answer by captain00000000 · Oct 06, 2012 at 02:02 PM
I also trying to similar project. Work with Numbers naming names (such as "001" "002" "003"). The data (such as 001.JPG 001.PNG 001.ogg 001.TXT ) upload to server. Creat a father objects, all works are child objects, and Get name of child objects. From the server batch download all the data. Through the father add data to child , and the name of data is childName +".jpg" or childName +".txt" ... This is my test : http://www.redsky.org.cn/00test/
Answer by Aron-Versteeg · May 08, 2013 at 08:40 PM
hi Dave,
I'm having the same problem trying to open a PDF in a new web tab from Unity. I came across your post when looking for a solution. When checking your mockup trial version it seems that it DOES open PDF's in a new window. Did you find a solution and changed the script?
if so, would you be willing to share it? Thanks in advance, Aron
Answer by Graham-Dunnett · May 08, 2013 at 08:44 PM
See:
http://docs.unity3d.com/Documentation/Manual/UnityWebPlayerandbrowsercommunication.html
This page explains how your Unity code can call Javascript code running in the browser. Since Unity cannot open a new browser window directly, you need to tell the hosting page to open a new browser window.
thx for your link. I solved the issue using this comment http://forum.unity3d.com/threads/154226-Proper-way-to-open-URL-in-flash
Your answer
Follow this Question
Related Questions
Download Links from GUI 2 Answers
how to download pdf/image file in unity web player? 1 Answer
Printable a Certificate for completing a task 1 Answer
Downloadable manual 2 Answers
Downloading unity 3 4 Answers