Change CustomData o...
 
Notifications
Clear all

Change CustomData of other users?

5 Posts
3 Users
0 Reactions
978 Views
(@langet16)
Posts: 2
New Member
Topic starter
 

Hello,

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

Thank you,

Tim

 
Posted : 02/01/2016 1:01 am
(@skaredcreations)
Posts: 805
Prominent 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

 
Posted : 02/01/2016 1:04 am
(@langet16)
Posts: 2
New Member
Topic starter
 

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

 
Posted : 02/01/2016 2:26 pm
(@hsilva)
Posts: 22
Eminent Member
 
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.

 

 
Posted : 19/07/2020 2:13 am
(@skaredcreations)
Posts: 805
Prominent 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

 
Posted : 19/07/2020 10:20 am
Share: