void Awake()
    {
#if UNITY_EDITOR
        if (TakenGuids.Contains(Id) || Id == null || Id.Equals(Guid.Empty))
        {
            Debug.Log("Creating new id for " + GetInstanceID());
            Id = Guid.RandomGuid();
        }
        TakenGuids.Add(Id);
#endif

        if (Id == null || Id.Equals(Guid.Empty))
        {
            Debug.LogError("Failed to initialize network id for object " + gameObject.name);
        }
    }
 public static void WriteTo(this Guid guid, NetBuffer writer)
 {
     writer.Write(guid.Value);
 }
        public ReplicatedObject ReplicateExistingInstance(ObjectRole role, ConnectionId hostConnectionId,
                                                          GameObject instance, ObjectId objectId, Guid globalId)
        {
            var replicatedObject = _replicationDecorator(instance, this);

            AddReplicatedInstance(new UnmanagedObject <ReplicatedObject>(replicatedObject), null, role, objectId, hostConnectionId);
            replicatedObject.IsPreExisting = true;
            replicatedObject.GlobalObjectId.CopyFrom(globalId);
            return(replicatedObject);
        }
 public static void ReadFrom(this Guid guid, NetBuffer reader)
 {
     reader.ReadBytes(guid.Value, 0, guid.Length);
 }