private void Server_CreateCollection() { if (_isPlayerCollection) { var bridge = GetComponent <UNetActionsBridge>(); if (bridge == null) { _logger.Error($"Trying to sync collection to client, but no {nameof(UNetActionsBridge)} found on object!", this); return; } var guid = System.Guid.NewGuid(); collection = bridge.Server_AddCollectionToServerAndClient(new AddCollectionMessage() { owner = _identity, collectionName = _collectionName, collectionGuid = guid, slotCount = (ushort)slotCount, }); bridge.Server_SetCollectionPermissionOnServerAndClient(new SetCollectionPermissionMessage() { collectionGuid = guid, permission = _permission }); } else { collection = UNetCollectionUtility.CreateServerItemCollection(_slotCount, _collectionName, System.Guid.NewGuid(), _identity); } }
private void DrawCollection(IUNetCollection collection, NetworkIdentity identity) { if (collection == null) { return; } ReadWritePermission?permission = null; if (identity != null) { permission = UNetPermissionsRegistry.collections.GetPermission(collection, identity); } DrawCollection(collection, permission.GetValueOrDefault()); }
private void DrawCollection(IUNetCollection collection, ReadWritePermission permission, IEnumerable <NetworkIdentity> identities) { var col = collection as ICollection; if (collection == null || col == null) { return; } using (new VerticalLayoutBlock("box")) { EditorGUILayout.LabelField(new GUIContent("Collection Name"), new GUIContent(collection.collectionName), UnityEditor.EditorStyles.boldLabel); EditorGUILayout.LabelField(new GUIContent("GUID"), new GUIContent(collection.ID.ToString())); EditorGUILayout.LabelField(new GUIContent("Permissions"), new GUIContent(permission.ToString())); EditorGUILayout.LabelField(new GUIContent("Type"), new GUIContent(GetFriendlyName(collection.GetType()))); EditorGUILayout.LabelField(new GUIContent("Slot count"), new GUIContent(col.slotCount.ToString())); EditorGUILayout.LabelField(new GUIContent("Owner NetID"), new GUIContent(collection.owner.netId.ToString())); if (identities.Any()) { using (new VerticalLayoutBlock("box")) { EditorGUILayout.LabelField(new GUIContent("All identities with access")); foreach (var identity in identities) { if (identity == null) { EditorGUILayout.LabelField("<NULL RECORD>"); continue; } EditorGUILayout.BeginHorizontal(); if (identity == collection.owner) { GUI.color = Color.green; } EditorGUILayout.LabelField(new GUIContent(identity.name), GUILayout.Width(150f)); EditorGUILayout.LabelField(new GUIContent("NetID: " + identity.netId), GUILayout.Width(80f)); EditorGUILayout.LabelField(new GUIContent(UNetPermissionsRegistry.collections.GetPermission(collection, identity).ToString()), GUILayout.Width(100)); if (GUILayout.Button("Select", "minibutton")) { Selection.activeObject = identity.gameObject; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); } } } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Select")) { Selection.activeGameObject = collection.owner?.gameObject; } if (GUILayout.Button("Inspect")) { CollectionInspectorEditor.ShowWindow(); CollectionInspectorEditor.collectionNameOrGuid = collection.ID.ToString(); } EditorGUILayout.EndHorizontal(); } }
private void DrawCollection(IUNetCollection collection, ReadWritePermission permission) { DrawCollection(collection, permission, new List <NetworkIdentity>()); }
public void Server_SetCollectionPermissionOnServer(IUNetCollection collection, ReadWritePermission permission) { UNetPermissionsRegistry.collections.SetPermission(collection, identity, permission); logger.Log($"[Server] Set client's permission to {permission} for collection {collection.collectionName} and guid {collection.ID} on netID: {netId}", this); }