After I update my player data by PlayerData.SetXxx, OnPlayerDataUpdated is called every frame.
The minimum U# code I can reproduce it:
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Persistence;
using VRC.SDKBase;
public class SimpleStorageRegistererTest : UdonSharpBehaviour
{
private const string Key = "RespawnCount";
public override void OnPlayerDataUpdated(VRCPlayerApi player, PlayerData.Info[] infos)
{
Debug.Log($"PlayerData updated for player[{player.playerId}]");
for (var i = 0; i < infos.Length; i++)
{
var info = infos[i];
Debug.Log($"Player[{player.playerId}] Key=[{info.Key}] State={info.State}");
}
}
public override void OnPlayerRespawn(VRCPlayerApi player)
{
if (player.isLocal)
{
if (!PlayerData.TryGetInt(player, Key, out int currentCount))
{
currentCount = 0;
}
PlayerData.SetInt(Key, currentCount + 1);
}
}
}
Place a GameObject with SimpleStorageRegistererTest and PlayerObject components, as well as the minimum objects & components (VRCSceneDescriptor, PipelineManager, and BoxCollider for the floor). (See embed image)
After I respawn, the log spam starts. Logs read
* "PlayerData updated for player[1]"
* "Player[1] Key=[RespawnCount] State=Added"
Note: This doesn't occur in ClientSim.