Attributes.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using UnityEngine;
  3. namespace Mirror
  4. {
  5. /// <summary>
  6. /// SyncVars are used to synchronize a variable from the server to all clients automatically.
  7. /// <para>Value must be changed on server, not directly by clients. Hook parameter allows you to define a client-side method to be invoked when the client gets an update from the server.</para>
  8. /// </summary>
  9. [AttributeUsage(AttributeTargets.Field)]
  10. public class SyncVarAttribute : PropertyAttribute
  11. {
  12. public string hook;
  13. }
  14. /// <summary>
  15. /// Call this from a client to run this function on the server.
  16. /// <para>Make sure to validate input etc. It's not possible to call this from a server.</para>
  17. /// </summary>
  18. [AttributeUsage(AttributeTargets.Method)]
  19. public class CommandAttribute : Attribute
  20. {
  21. public int channel = Channels.Reliable;
  22. public bool requiresAuthority = true;
  23. }
  24. /// <summary>
  25. /// The server uses a Remote Procedure Call (RPC) to run this function on clients.
  26. /// </summary>
  27. [AttributeUsage(AttributeTargets.Method)]
  28. public class ClientRpcAttribute : Attribute
  29. {
  30. public int channel = Channels.Reliable;
  31. public bool includeOwner = true;
  32. }
  33. /// <summary>
  34. /// The server uses a Remote Procedure Call (RPC) to run this function on a specific client.
  35. /// </summary>
  36. [AttributeUsage(AttributeTargets.Method)]
  37. public class TargetRpcAttribute : Attribute
  38. {
  39. public int channel = Channels.Reliable;
  40. }
  41. /// <summary>
  42. /// Prevents clients from running this method.
  43. /// <para>Prints a warning if a client tries to execute this method.</para>
  44. /// </summary>
  45. [AttributeUsage(AttributeTargets.Method)]
  46. public class ServerAttribute : Attribute {}
  47. /// <summary>
  48. /// Prevents clients from running this method.
  49. /// <para>No warning is thrown.</para>
  50. /// </summary>
  51. [AttributeUsage(AttributeTargets.Method)]
  52. public class ServerCallbackAttribute : Attribute {}
  53. /// <summary>
  54. /// Prevents the server from running this method.
  55. /// <para>Prints a warning if the server tries to execute this method.</para>
  56. /// </summary>
  57. [AttributeUsage(AttributeTargets.Method)]
  58. public class ClientAttribute : Attribute {}
  59. /// <summary>
  60. /// Prevents the server from running this method.
  61. /// <para>No warning is printed.</para>
  62. /// </summary>
  63. [AttributeUsage(AttributeTargets.Method)]
  64. public class ClientCallbackAttribute : Attribute {}
  65. /// <summary>
  66. /// Converts a string property into a Scene property in the inspector
  67. /// </summary>
  68. public class SceneAttribute : PropertyAttribute {}
  69. /// <summary>
  70. /// Used to show private SyncList in the inspector,
  71. /// <para> Use instead of SerializeField for non Serializable types </para>
  72. /// </summary>
  73. [AttributeUsage(AttributeTargets.Field)]
  74. public class ShowInInspectorAttribute : Attribute {}
  75. }