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
1
Question by gregzo · Jun 22, 2012 at 03:47 PM · stringrpcempty

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

Hi to all!

I'm sending a string(2-7 chars long) as an RPC param. Works like a charm for the first connected player, but for the second, debug shows on the server side sentString.length = 4, and on the client side receivedString.length = 0 !!! The function is called, the player is connected.

Server side :

 Debug.Log(stringToSend.length); //Debugs 4
 networkView.RPC("ReceiveString",Network.connections[1],stringToSend);

Client side(player 1) :

     @RPC
     function ReceiveString(str : String)
     {
          Debug.Log(str.length); //Debugs 0
     }

Am networking an iPad 1, an iPad 3 and an iMac. Whoever is the server, same result. Always the second player to connect receiving an empty string. Receives previous initialization RPCs fine, though...

Any ideas???

Thanks!

Edit for precision's sake : networking through wifi. Tried strings of various lengths with the same result.

Edit2 : got it to work in a minimal scene, but not in my actual set up. Here's my exact code: Server side

 if(GUI.Button (new Rect(310,40,80,30),"SendNotes"))
 {
     var stringToSend :  String = StaticFunctions.NotesToString(notes);
     //notes is a List of enum Notes
     print("sending string of length "+stringToSend.Length);
     //The above debugs 4

     networkView.RPC("ReceiveNotes_RPC",Network.connections[players.selectedPlayer],stringToSend);
  }

client side:

 @RPC
   
  function ReceiveNotes_RPC(str:String)
     {
         Debug.Log("received notes : "+str.length);
             //the above debugs 0
         pattern.notes = StaticFunctions.StringToNotes(str);
         
         pattern.CreateClipFromNotes();
     }
Comment
Add comment · Show 4
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 gregzo · Jun 22, 2012 at 08:55 PM 0
Share

Out of despair, I went the simpler route: sending multiple RPCs containing an int each, ins$$anonymous$$d of converting List. to String and back. Works fine, but still no idea why my previous, maybe more efficient(?) solution wasn't working out...

avatar image whydoidoit · Jun 22, 2012 at 09:06 PM 0
Share

No I've no idea - just looks like it should work doesn't it :(

avatar image Benproductions1 · Feb 19, 2013 at 01:35 AM 0
Share

If you want to send a $$anonymous$$essage to all connected players you need to pass RPC$$anonymous$$ode.Others as the second argument of the RPC call. This may be what your looking for :)

avatar image gooncorp · Nov 29, 2013 at 12:03 AM 0
Share

i dont think anyone has figured this out yet, im on the same page as you and im supprised this has been overlooked

0 Replies

· Add your reply
  • Sort: 

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

6 People are following this question.

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

Default string value... empty? (C#) 2 Answers

Can RPCS safely send STRINGS? 4 Answers

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

String - Replace Letters With Numbers 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