|
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
(comments are locked)
|
|
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 ;) 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.
May 21 '12 at 01:16 PM
Bunny83
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?
Sep 15 '12 at 10:15 AM
mrbunyrabit
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.
Sep 15 '12 at 11:04 AM
DesiQ
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.
Sep 15 '12 at 11:14 AM
Bunny83
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)
Sep 15 '12 at 12:51 PM
mrbunyrabit
(comments are locked)
|



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 mind 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 instead of having another application run in the background.
Keep in mind 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".
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)