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 user-1613 (google) · Jan 20, 2011 at 02:58 AM · javascriptwebplayerdownloadsendmessagelimit

How much data can I send from the browser through unityObject.SendMessage()?

I want to download content into the Unity web player from a web site that does not host the web player/game. Thus, I have to do the download using something like JSONP from the enclosing web page, rather than from within the plug-in.

So, I imagine that my game will call out to the JavaScript in the browser to start up a jQuery JSONP fetch request. Once that request completes, I need to call unityObject.SendMessage() to send the data back in.

Is there a limitation to how much data I can pass in as a string in this SendMessage() call? I'll likely want to put in hundreds of kilobytes in one go, representing things like a mesh, or a texture, that would be dynamically provisioned from some other site under my control.

I know how to secure the web player against maliciously injected content from rogue hosters, although it seems as if SendMessage() can be used to send arbitrary messages to arbitrary game objects, and thus every game object method would potentially need to worry about this kind of attack. I think it would be better if there was a narrower interface here... but that's beside the point in this question: How big a string can I cram into unityObject.SendMessage() and expect to get away with it?

Comment
Add comment · Show 3
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 yoyo · Jan 21, 2011 at 06:11 AM 0
Share

You say you want to "download content", but the rest of your message describes what sounds more like RPC. If it is just content download you need, have you considered the WWW interface?

avatar image yoyo · Jan 21, 2011 at 06:12 AM 0
Share

On a different note, you mention communication with "the enclosing web page", which is something I'm interested in but haven't looked into yet. Is it possible to communicate between, for example, the Unity game running in the webplayer and client-side javascript running in the browser page that hosts the web player? Tips appreciated.

avatar image user-1613 (google) · Jan 22, 2011 at 05:07 PM 0
Share

As I explained in the first sentence, I cannot use the built-in WWW code, because the content comes from a web site other than the site that hosts the game. The built-in WWW class enforces the same-origin principle for all requests. ($$anonymous$$ind-of pointless I$$anonymous$$O because there are no HTTP cookies to protect from within Unity, but whatever)

I discuss the RPC calls available in the Unity API because that is the mechanism that Unity3D plug-ins use to talk to the enclosing web browser JavaScript engine. From the enclosing browser, I can use JSONP to make cross-domain calls to download the content.

1 Reply

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

Answer by jonas-echterhoff · Jan 20, 2011 at 09:26 AM

As far as I can tell from a quick look, our code does not impose any limitations (other then a 32-bit size field on strings) on SendMessage, thus theoretically allowing up to 4GB of data to be sent this way. In practice, this will very likely also depend on browser and JavaScript engine limitations, and I may well have overlooked something - so the only way you can be somewhat sure of this is to go and test it across various browser and OS configurations.

Comment
Add comment · Show 1 · 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
avatar image user-1613 (google) · Jan 22, 2011 at 05:04 PM 0
Share

Thanks for the answer!

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

No one has followed this question yet.

Related Questions

Label not updating when text changed through javascript send message. 1 Answer

Web Player SendMessage Array Parameters 1 Answer

Problem with UnityObject2.SendMessage | communicating with the web player 0 Answers

Send a message to multiple scripts within an Array - Javascript 1 Answer

SendMessage Not Working: JavaScript 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