Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by roberto_sc · May 22, 2013 at 09:14 PM · bugwebplayerurlapplication.openurl

Application.OpenURL not working with Data URI

If you enter the following URI in the browser:

 data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==

it will show a 5x5 pixels red circle.

I'm trying to do this inside Unity with Application.OpenURL or Application.ExternalEval("window.open(url,'_blank')") but it does nothing. It doesn't work on editor nor on Mac build, but strangely it works on the Web Player (and that's why I think my code is working).

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ByteSheep · May 22, 2013 at 10:07 PM 0
Share

Application.ExternalEval is only available in the webplayer.. Have you tried using this for your standalone build?

 Application.OpenURL("data:image/png;base64,iVBORw0$$anonymous$$GgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIB$$anonymous$$E0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==");


avatar image roberto_sc · May 22, 2013 at 11:31 PM 0
Share

yes, you are right. But I tried using OpenURL, the result is the same (I wrote this in the question).

avatar image ByteSheep · May 22, 2013 at 11:44 PM 0
Share

Application.OpenURL should work, to test what is going wrong try testing some of these and see if it will open a browser window:

 Application.OpenURL("http://answers.unity3d.com/index.html");

and if that works then you can try the following (note that it has the url address as a string rather than a variable):

 Application.OpenURL("data:image/png;base64,iVBORw0$$anonymous$$GgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIB$$anonymous$$E0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==");

Let us know if the first code snippet works - it should since it is just a normal url.

avatar image roberto_sc · May 23, 2013 at 12:05 AM 0
Share

I did it, it open regular URLs and don't open when the URI is a string.

avatar image roberto_sc · May 23, 2013 at 01:09 AM 0
Share

Thank you very much for this. I really don't know anything about web dev, so this will help a lot. Yet, OpenURL will accept URI when you use the web player, so maybe there is another answer on why it doesn't work on editor. But for my application, I'll stick with your solution.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ByteSheep · May 23, 2013 at 02:18 AM

Yeah I just tested it and it looks like the OpenURL function will only allow the http: and https: protocols.
This makes what you are trying to do a bit more complicated.. You could use OpenURL to open a php page and pass the image info as a GET variable. Then the php page could open the image for you. So it might look something like:

 var open_url = "http://yourdomain.com/open_image.php";
 
 open_url += "?imageinfo=" + ImageBytes; //add your image byte array
 
 Application.OpenURL(open_url);

Then the php file could look like this:

 <?php
 
 if(isset($_GET['imageinfo']))
 {
   $image_info = $_GET['imageinfo'];
   $data_URI = "data:image/png;base64,";
 
   echo "<meta http-equiv='refresh' content='0;url=".$data_URI."".$image_info."'>";
 }
 
 ?>



Here's an example project using this method.

OpenURL.zip

Note that the server the php page is hosted on is currently really slow, so it takes a few seconds before it redirects to the actual image.. With a proper server on a normal webpage the load time should normally be under a second.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Dynamic object Instantiate 1 Answer

WebPlayer has severe bug in Generics constraint verification (found in Unity 3.3.0f4) 3 Answers

ExternalEval not working on Mac? 0 Answers

Crash when closing our game in WebPlayer builds 2 Answers

How can I open an URL without using Application.OpenURL? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges