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 Jay 6 · May 16, 2011 at 06:45 AM · objectobjectssendmessageuser

Is it possible to send in custom objects defined in the Browser using SendMessage(), or are we limited to strings?

I want to send the custom object roomDetails to the Unity player. Is it allowed? If yes, is this the right syntax? If not is there any way to send this info without having to use a string and multiple delimiters,

In the browser

function someFunction(){

 var roomDetails = new Object(); 
 roomDetails.length = roomLength;
 roomDetails.width = roomWidth;
 roomDetails.roomID = roomID;
 roomDetails.XPos = roomX;
 roomDetails.ZPos = roomZ;
 roomDetails.doors = doors;
 roomDetails.from = facing;

 constructor.SendMessage("Avatar", "buildRoom", roomDetails);

}

In Unity attached to Avatar

function buildRoom (roomDetails : Object)
{
}

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · May 16, 2011 at 01:58 PM

As far as i know you can only pass one simple datatype like: int, float, String, .... The problem is that the class you've created "on-the-fly" is not known in .Net/Mono.

One way would be to use a JSON parser in JScript to serialize the object as string, but you have to deserialize and interpret it yourself in Unity.

I would go for the easiest way on the Unity side. A simple character-seperated-string will do in most cases. If you use an array in JScript you can simply use .Join to form a single string and in Unity String.Split

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 Jay 6 · May 17, 2011 at 12:23 AM 0
Share

Hmm, is there no way to define a class so it is available in both Unity and the browser?

avatar image Bunny83 · May 17, 2011 at 01:54 AM 0
Share

The browser's JScript and Unity's $$anonymous$$ono implementation are two seperated worlds so there is no direct way. You can create the class in both environments and give them both the ability to be serialized to or deserialized from a string. If you just want to transfer some simple data i would recommend to use some easy-to-use method like xml, CSV, .... I don't understand why you need this data in your website? It's better to handle such stuff completely in Unity. Also be careful, website JScript is executed on the client side and can be manipulated or observed very easily.

avatar image
0

Answer by CHPedersen · May 16, 2011 at 10:47 AM

Edit: Misunderstood question and deleted answer, my apologies. >_<

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

No one has followed this question yet.

Related Questions

How to get the size of an array of object? 2 Answers

What are GameTiles? 1 Answer

Multiple Terrain objects good practice? 1 Answer

I need a grid of objects at runtime, but the gameObject is instantiated later 0 Answers

Opening and closing drawers with start and end points 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