Notifications
Clear all

Change CustomData of other users?  

(@langet16)
New Member Registered

Hello,

I was wondering, if you can change the customData of another User via script?

Thank you,

Tim

ReplyQuote
Topic starter Posted : 02/01/2016 1:01 am
(@skaredcreations)
Honorable Member Admin

Yes, you can call Update on any User class object even if it's not the local player.

If you haven't loaded a User class object (with User.Load or Random), you can just set the Id, for example:

User user = new User();
user.id = "123";
user.customData["Key"] = "Value";
user.Update(null);

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 02/01/2016 1:04 am
(@langet16)
New Member Registered

Thank you very much for that great and fast answer! smile

ReplyQuote
Topic starter Posted : 02/01/2016 2:26 pm
(@hsilva)
Eminent Member Registered
Posted by: @skaredcreations

Yes, you can call Update on any User class object even if it's not the local player.

If you haven't loaded a User class object (with User.Load or Random), you can just set the Id, for example:

User user = new User();
user.id = "123";
user.customData["Key"] = "Value";
user.Update(null);

Hi. I have a similar need (save custom data from another user). I try this code, but I get the error "user.id is read-only". Any ideas how to solve this? Thanks in advance.

 

ReplyQuote
Posted : 19/07/2020 3:13 am
(@skaredcreations)
Honorable Member Admin

Yes, the things changed in v3 to adhere to the Unity’s SocialPlatform system and interfaces, the safest way is to use User.Load passing the id (if you haven’t a User object already loaded) and then change the customData in its callback if it was successful.

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 19/07/2020 11:20 am
Share: