Class PlayerUtils
The utility class forVRCPlayerApi.
Inheritance
System.Object
PlayerUtils
Namespace: black.kit.toybox
Assembly: cs.temp.dll.dll
Syntax
public static class PlayerUtils
Methods
GetPlayerName(VRCPlayerApi, String)
Get the player name.
Declaration
public static string GetPlayerName(this VRCPlayerApi player, string fallback = null)
Parameters
Type | Name | Description |
---|---|---|
VRCPlayerApi | player | Player instance. |
System.String | fallback | Fallback name. |
Returns
Type | Description |
---|---|
System.String | player name |
Examples
VRCPlayerApi player = VRCPlayerApi.GetPlayerById(1);
player.GetPlayerName(); // "PlayerName"
player.GetPlayerName("Fallback"); // "PlayerName"
player = null;
player.GetPlayerName(); // null
player.GetPlayerName("Fallback"); // "Fallback"
GetSafePlayerName(VRCPlayerApi, String, String)
Get the safety player name.
Declaration
public static string GetSafePlayerName(this VRCPlayerApi player, string safeCharset, string fallback = null)
Parameters
Type | Name | Description |
---|---|---|
VRCPlayerApi | player | Player instance. |
System.String | safeCharset | String containing characters to be checked. |
System.String | fallback | Fallback name when the player name is invalid or unsafe. |
Returns
Type | Description |
---|---|
System.String | player name |
Remarks
⚠️ The fallback string returns WITHOUT validation.
Examples
VRCPlayerApi player = VRCPlayerApi.GetPlayerById(1);
player.displayName = "bcd";
player.GetSafePlayerName("abcde"); // "bcd"
player.GetSafePlayerName("bcd"); // "bcd"
player.GetSafePlayerName("def"); // null
player.GetSafePlayerName("abcde", "Fallback"); // "Fallback"