CallbackIdentity.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // This file is provided under The MIT License as part of Steamworks.NET.
  2. // Copyright (c) 2013-2019 Riley Labrecque
  3. // Please see the included LICENSE.txt for additional information.
  4. // This file is automatically generated.
  5. // Changes to this file will be reverted when you update Steamworks.NET
  6. #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH
  7. #define DISABLESTEAMWORKS
  8. #endif
  9. #if !DISABLESTEAMWORKS
  10. namespace Steamworks {
  11. class CallbackIdentities {
  12. public static int GetCallbackIdentity(System.Type callbackStruct) {
  13. #if UNITY_EDITOR || UNITY_STANDALONE || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX
  14. foreach (CallbackIdentityAttribute attribute in callbackStruct.GetCustomAttributes(typeof(CallbackIdentityAttribute), false)) {
  15. return attribute.Identity;
  16. }
  17. #endif
  18. throw new System.Exception("Callback number not found for struct " + callbackStruct);
  19. }
  20. }
  21. [System.AttributeUsage(System.AttributeTargets.Struct, AllowMultiple = false)]
  22. internal class CallbackIdentityAttribute : System.Attribute {
  23. public int Identity { get; set; }
  24. public CallbackIdentityAttribute(int callbackNum) {
  25. Identity = callbackNum;
  26. }
  27. }
  28. }
  29. #endif // !DISABLESTEAMWORKS