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 Patrick · May 26, 2010 at 07:26 AM · webplayersendmessagecommunication

Communication issue from Browser to Web Player

Hi all,

I'm currently trying to send information to a precompiled unity3d object from my html web page. What I did is the following.

I created a project with Unity3D and built it as a webplayer (not streamed). I tried to follow the tutorial on Unity page ( http://unity3d.com/support/documentation/Manual/Unity%20Web%20Player%20and%20browser%20communication.html ) but nothing happened with my GetUnity().SendMessage(...).

As debug-like solution, I tried to put document.write("...") around the SendMessage and I discovered that it cannot apply the SendMessage command (it only prints the "..." that is before the SendMessage call).

Do anyone have an idea on this issue? Notice that I can call an javascript alert from Unity object on the web page... But I cannot communicate in the other sense.

Cheers, -Patrick

Comment
Add comment · Show 2
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 Extrakun · May 26, 2010 at 08:06 AM 0
Share

Perhaps there's a syntax error? I recommend checking it out using Firefox plus the Firebug extension?

avatar image Cyclops · May 26, 2010 at 08:37 PM 0
Share

Can you list the HT$$anonymous$$L, and Unity code?

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by rpl oye · Jun 25, 2010 at 01:40 AM

I found another way to do it. in your unity3d script, make a function that call an external javascript that send data to unity3d.

so in unity3d.. on start() method

Application.ExternalCall("setUserID", 0);

on browser

function setUserID(Void)
{   
     GetUnity().SendMessage( "webConnect", "setSessionId", "<?php echo $session['session_id']; ?>" ); 
}

and then in unity3d, on the same script as the first call, create another function

void setSessionId(string sessionString)
{
    try
    {
        _user.setSessionId(sessionString);
        guitext.setSessionText();
    }
    catch { Debug.Log("null session"); } 
}

if you do this, the javascript call will only be called after the unity instance fully loaded

Comment
Add comment · Show 2 · 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 Gillissie · Mar 23, 2011 at 06:34 AM 0
Share

Thank you! This info should be in the documentation.

avatar image BerggreenDK · Oct 17, 2011 at 08:41 PM 0
Share

Have you tried to test on the level itself before calling??

http://unity3d.com/support/documentation/ScriptReference/Application.GetStreamProgressForLevel.html

avatar image
1

Answer by rpl oye · Jun 22, 2010 at 07:43 AM

this is because the web player have not fully loaded, and yet you call the sendmessage function. there is some tutorial somewhere, i also am looking for it while i am writing this post.

i will post the link if i find it.

Comment
Add comment · Show 2 · 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 Cyclops · Jun 25, 2010 at 02:25 AM 2
Share

@rpl, you could have edited this Answer to include the code, there's no reason to start two different Answers.

avatar image toan.tran.developer · Feb 02, 2015 at 06:13 AM 0
Share

I have problem with communication web browser with web player. I also used to same under code. But it didn't work. Can you help me?

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

2 People are following this question.

avatar image avatar image

Related Questions

Communicating between objects without any physical connection? 3 Answers

WebPlayer TCPClient connect C# TCPServer app in localhost, posible? 1 Answer

Trying to parse Facebook FQL response with String.Split in webplayer; no luck 1 Answer

How to load a local texture file to WebPlayer 3 Answers

Calling function with integer webpage communication 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