53-Mirror__Network Observer-NewNetworkObserver.cs.txt 1.3 KB

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. using Mirror;
  3. using System.Collections.Generic;
  4. /*
  5. Visibility Guide: https://mirror-networking.gitbook.io/docs/guides/legacy-interest-management
  6. API Reference: https://mirror-networking.com/docs/api/Mirror.NetworkVisibility.html
  7. */
  8. public class #SCRIPTNAME# : NetworkVisibility
  9. {
  10. /// <summary>
  11. /// Callback used by the visibility system to determine if an observer (player) can see this object.
  12. /// <para>If this function returns true, the network connection will be added as an observer.</para>
  13. /// </summary>
  14. /// <param name="conn">Network connection of a player.</param>
  15. /// <returns>True if the player can see this object.</returns>
  16. public override bool OnCheckObserver(NetworkConnection conn)
  17. {
  18. return true;
  19. }
  20. /// <summary>
  21. /// Callback used by the visibility system to (re)construct the set of observers that can see this object.
  22. /// <para>Implementations of this callback should add network connections of players that can see this object to the observers set.</para>
  23. /// </summary>
  24. /// <param name="observers">The new set of observers for this object.</param>
  25. /// <param name="initialize">True if the set of observers is being built for the first time.</param>
  26. public override void OnRebuildObservers(HashSet<NetworkConnection> observers, bool initialize) { }
  27. }