neongm

Device platform example

Aug 21st, 2023
1,068
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. public enum DevicePlatform { Desktop, PCVR, AndroidVR, AndroidMobile };
  2. // ^ This goes in your namespace. Not in your UdonSharpBehaviour class! ^
  3.  
  4. public DevicePlatform GetLocalPlayerPlatform()
  5. {
  6.     if (!Utilities.IsValid(Networking.LocalPlayer)) return DevicePlatform.Desktop;    
  7.  
  8.     #if UNITY_ANDROID
  9.     if (Networking.LocalPlayer.IsUserInVR()) return DevicePlatform.AndroidVR;
  10.     else return DevicePlatform.AndroidMobile;
  11.     #endif
  12.  
  13.     if (Networking.LocalPlayer.IsUserInVR()) return DevicePlatform.PCVR;
  14.     else return DevicePlatform.Desktop;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment