예제 #1
0
        private void Server_CreateCollection()
        {
            if (!PhotonNetwork.LocalPlayer.IsMasterClient)
            {
                return;
            }

            _logger.Log($"UNetItemCollectionCreator - Server_CreateCollection viewId: {this.photonView.ViewID}, _isPlayerCollection: {_isPlayerCollection}", this);

            if (_isPlayerCollection)
            {
                var bridge = GetComponent <PUN2ActionsBridge>();
                if (bridge == null)
                {
                    _logger.Error($"Trying to sync collection to client, but no {nameof(PUN2ActionsBridge)} found on object!", this);
                    return;
                }

                var guid = System.Guid.NewGuid();

                collection = bridge.Server_AddCollectionToServerAndClient(collectionName: _collectionName, collectionGuid: guid, slotCount: slotCount);
                bridge.Server_SetCollectionPermissionOnServerAndClient(collectionGuid: guid, permission: _permission);
            }
            else
            {
                collection = PUN2CollectionUtility.CreateServerItemCollection(_slotCount, _collectionName, System.Guid.NewGuid(), this.photonView);
            }
        }
예제 #2
0
        public void Server_SetCollectionPermissionOnServer(IPUN2Collection collection, ReadWritePermission permission)
        {
            if (!PhotonNetwork.LocalPlayer.IsMasterClient)
            {
                return;
            }

            logger.Log($"[Server][ViewId: {this.photonView.ViewID}] {nameof(Server_SetCollectionPermissionOnServer)}(collection: ({collection.collectionName}, {collection.ID}), permission: {permission})", this);

            PUN2PermissionsRegistry.collections.SetPermission(collection, this.photonView, permission);
        }
        private void DrawCollection(IPUN2Collection collection, PhotonView identity)
        {
            if (collection == null)
            {
                return;
            }

            ReadWritePermission?permission = null;

            if (identity != null)
            {
                permission = PUN2PermissionsRegistry.collections.GetPermission(collection, identity);
            }

            DrawCollection(collection, permission.GetValueOrDefault());
        }
        private void DrawCollection(IPUN2Collection collection, ReadWritePermission permission, IEnumerable <PhotonView> 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 ViewID"), new GUIContent(collection.owner?.ViewID.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("ViewID: " + identity.ViewID), GUILayout.Width(80f));
                            EditorGUILayout.LabelField(new GUIContent(PUN2PermissionsRegistry.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(IPUN2Collection collection, ReadWritePermission permission)
 {
     DrawCollection(collection, permission, new List <PhotonView>());
 }