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 gooncorp · Nov 29, 2013 at 12:07 AM · stringrpc

Can RPCS safely send STRINGS?

Can Strings be safely sent in an RPC, or is there more coding required? DEBUGGING INFORMATION INCLUDED..

I send string, int, and float across network to clients via rpc call to all. They only recieve the values for float and int not the string value. I have confirmed this with numerous tests, rewrites and debug routines.

I can post my code but since what I'm doing is very simple I think this should suffice for now. All I am doing is using a RPC call to all and sending a string, float, and int, then reading it back from the client in a debug routine. Its important to note that the string that is sent is used to overwrite a string variable on all clients.

In the picture, server is on the right and client on the left - server typed a message to itself and client. Client reads the float and int, but not the String.

If you choose to answer please try to test this out by writing a simple RPC to send strings, then read back the change to the string variable from the client in a debug routine similar to what I have done. If you do not debug this it is going to be hard to solve.

alt text

debugginstring4.jpg (217.0 kB)
debugginstring3.jpg (338.5 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 asafsitner · Nov 29, 2013 at 07:02 AM 0
Share

RPCs are perfectly safe for sending any of the supported data types.

Have you tried simply printing the values to console with Debug.Log()?

avatar image gooncorp · Nov 30, 2013 at 03:34 AM 0
Share

Asafsitner no i havent tried that. I will give it a shot and let you know. Also going to try to send an string inside of an array and see if that works.

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Nov 30, 2013 at 10:22 AM

RPC functions send/receive string parameters just fine for me. Per the docs, you can send only the following datatypes as RPC function parameters:

  • int

  • float

  • string

  • NetworkPlayer

  • NetworkViewID

  • Vector3

  • Quaternion

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 gooncorp · Nov 30, 2013 at 08:57 PM

Sending strings kind of works, if i send a string variable and rewrite a variable on the clients machine it does NOT work. just sending a string however does. Its funny ive been writing all of my own network code and i have never had this problem, im still having a really hard time with this guys...

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 gooncorp · Nov 30, 2013 at 07:19 PM

I do not want to use sendmessage. My RPC looks like this:

         if (Event.current.type == EventType.KeyDown && Event.current.character == '\n' && GUI.GetNameOfFocusedControl () == "Text1" ) {
 
 textFieldOpen = false;
 
 var sendString = (realPlayerName + " : " + stringToEdit) as String;
 
 networkView.RPC ("chat", RPCMode.AllBuffered, "GENERIC TEST STRING = " + " TEST248 " + "SEND STRING = " + sendString, Time.time, Mathf.FloorToInt(Random.value * 20));
 
 if (DEBUG) {
 print ("chat rpc called" );}
 
 }


////////////////////

@RPC function chat ( text : String , flVal : float, inVal : int) {

//if (levelNameString.Length > 280) { //levelNameString = ""; //}

debuggingFloat = flVal; debuggingInt = inVal; Debug.Log("RPC FUNCTION CHAT TEXT IS " + text); Debug.Log("RPC FUNCTION CHAT TEXT IS " + text.Length); chatMessages[4] = chatMessages[3]; chatMessages[3] = chatMessages[2]; chatMessages[2] = chatMessages[1]; chatMessages[1] = chatMessages[0]; chatMessages[0] = text;

}

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 gooncorp · Nov 30, 2013 at 07:18 PM

 @RPC function chat ( text : String , flVal : float, inVal : int) {
 
 //if (levelNameString.Length > 280) {
 //levelNameString = "";
 //}
 
 debuggingFloat = flVal;
 debuggingInt = inVal;
 Debug.Log("RPC FUNCTION CHAT TEXT IS " + text);
 Debug.Log("RPC FUNCTION CHAT TEXT IS " + text.Length);
 chatMessages[4] = chatMessages[3];
 chatMessages[3] = chatMessages[2];
 chatMessages[2] = chatMessages[1];
 chatMessages[1] = chatMessages[0];
 chatMessages[0] = text;
 
 
 
 }
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

18 People are following this question.

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

Related Questions

RPC , string parameter is sent, but length is 0 1 Answer

RPC with a string argument - working for 1st connected player only... 0 Answers

Making a GUI Label carrying a variable update when changed to all clients on network 0 Answers

GameObject to Variable to GameObject and add string? 1 Answer

Autocomplete, Monodevelop, and String/string 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