• 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 mrbunyrabit · May 21, 2012 at 12:13 PM · c#java

Can you send Variables from C# to Unity?

Hi there. Is it possible to send a variable form C# to Unity?

Details About my question

1 - Dont worry about the server, i already wrote it in c# so i have 2 console apps running, one server that listens to my mike, takes a word i say and creates the string i just said. then another console app that listens for that word the whole time gets that word and displays it as i say it.

2 - now that word i get with my one console app in real time, i need to get that sting (for example "jump" "walk" "action") as words / string to unity.

3 - once it is in unity, i can use those words to make my character do the things i say.

so is there a way to get that string from my console app to unity in real time? (if real time is the right word im using)

  • in the image i just counted randomly as an example. Now i have to get those results to unity

alt text

alt text

capture.png (45.9 kB)
capture.png (91.7 kB)
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 Bunny83 · Sep 15, 2012 at 03:18 PM 0
Share

Well, you updated your question, but it's still not clear what kind of server you talk about. From the console screenshot we can see at least that it's probably using the IP protocol. Is it a TCP or UDP server? A TCP client can't listen for a server, it just have to connect to the server. Once connected you can send information in both directions.

An UDP socket always sends information "blind" to a specific IP / port. In this case the client will "listen" on a port if there's any data.

Either way .NET sockets can be used in Unity the same way as in any other C# / .NET application. Even in the webplayer but keep in $$anonymous$$d that you need an additional security policy server

If your "server" just uses a common .NET / managed speech-recognition library you might want to use it directly in Unity ins$$anonymous$$d of having another application run in the background.

$$anonymous$$eep in $$anonymous$$d that you can also use Threads in Unity, just make sure you synchronize them since all Unity related stuff is not thread-safe so it can only be used from the Unity main thread.

I'm still not sure what exactly you expect from us as answer. The question is still not that "clear".

avatar image mrbunyrabit · Sep 15, 2012 at 05:11 PM 0
Share

Its a TCP client

|What i would like to know is How im going to get that client in unity. When i try and put it in, i get this error, which i guess my dll somewhere isnt compatible or who knows. (image at top)

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · May 21, 2012 at 12:17 PM

What do you mean by "server"? A simple TCP socket? LAN and / or WAN?

Basically yes. You can use the .NET socket class to connect to any kind of server.

Short question, short answer ;)

Comment
Add comment · Show 5 · 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 Bunny83 · May 21, 2012 at 01:16 PM 0
Share

Why do you post your whole server here as answer? It isn't really relevant for the question and doesn't answer the question. Edit your question or post it as comment, but actually it has no relevance for the question. It's just a big (annoying) post of code.

The socket classes work almost the same on all platforms. If you wrote this server yourself, you should have no problems to write the client part in C# in Unity.

avatar image mrbunyrabit · Sep 15, 2012 at 10:15 AM 0
Share

okay, yea you are right, i should have made this answer more clear, and not just puke code onto here. sorry about that I have a console app that receives strings from the server. so now in this console app, with this string, how can i get that string into unity?

avatar image DesiQ · Sep 15, 2012 at 11:04 AM 0
Share

Parse it? Split it? The approach is up to you. Have a look at C#'s built-in methods for dealing with the string type.

avatar image Bunny83 · Sep 15, 2012 at 11:14 AM 0
Share

It's still not clear who's the "server" (the Unity app or your console app) and what kind of "server" you are actually using?

Feel free to edit your question and add more information to it.

It's funny, i guess this is the first time i see a 4 month old abandoned question to be revived by the OP ;) If you're still looking for an answer, improve the question.

avatar image mrbunyrabit · Sep 15, 2012 at 12:51 PM 0
Share

haha yea i really didnt structure my question very well.. And i still need an answer for this. (hate leaving questions open like this too)

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

7 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Sending bytes over network 0 Answers

Basic C# Public Variable Help 3 Answers

[ANDROID]Set Java Plugin on Unity 0 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