• 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 TomaszL · Dec 24, 2009 at 01:23 PM · browserwebpage-javascript

Unity communication with browser problem

Hello,

I'm trying to communicate with browser via unity. My scene contains a camera with a moving script attached. What i want to send is a simple communicate "true" to disable moving camera.

//Move2.js var speed = 5.0; var stopMe = "false"; function Update () { if(this.stopMe =="false"){ var x = Input.GetAxis("Horizontal") Time.deltaTime speed; var z = Input.GetAxis("Vertical") Time.deltaTime speed; transform.Translate(x, 0, z); } } function setStop(stop2 : String) { this.stopMe = stop2; }

So one setter called when i push button in html. GetUnity().SendMessage("Main Camera", "setStop", "true"); But nothing happening. Same thing when i'm trying to call javascript from application by putting ExternalCall at the begining of my Move2.js.

Comment
Add comment · Show 1
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 TomaszL · Dec 24, 2009 at 08:35 PM 0
Share

I've solve it. There was probably problem with initializing GameObject because of javascript Error.

3 Replies

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

Answer by Ashkan_gc · Dec 25, 2009 at 11:12 AM

the application class methods can be called everywhere just like other static and none static methods. there should be another problem. for example maybe you changed the "jump" key input settings of your built application. also i think it can be a bug if you use IE8 on windows. first check if there is any error in your code. then put another statement inside the if's body to see the result. maybe for some reason the body of your if never executes. maybe there is an error in your javascript code inside the HTML file. put a document.write in it to see if it's called or not.

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
avatar image
0

Answer by TomaszL · Dec 24, 2009 at 10:29 PM

I still have a problem with Application.ExternalCall. I have written a script that if spacebar is pressed it is sending a message to the browser, and it is not working. Seems that my webapp after build has a problem with Application class. When i'm using any Application functions they are not working. It works only in Unity development IDE. Can someone tell me where should i use Application static functions? Now i'm calling it in Update(). My Code: function Update(){ if (Input.GetButtonDown("Jump")) Application.ExternalCall ("MyFunction1"); } }

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
avatar image
0

Answer by TomaszL · Dec 25, 2009 at 11:25 AM

Thank you for interest :). Yes, you are right there was some another probem with the scene or my project workspace, but again i don't know what it was. I've found a unity chat example and it works great even when i added some stuff. In the old workspace i've checked the unity console and it looks ok. I don't know how to debug the webplayer build so i really can't tell why it wasn't working. Anyway i've created new workspace and there everything is fine. New plane, new cube with javascript component function onMouseDown attacheted. It works. Thanks again.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How would I go about getting the results of a javascript variable to a string inside script? 3 Answers

Embed Web Browser into unity 4 Answers

Best Practices, GUI and Browser Zoom, Scaling 0 Answers

Best method; Multiplayer server browser/lobby? 1 Answer

Would it be possible to make an in-browser game? 2 Answers


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