コード例 #1
0
        private void DrawItemInfo(IItemInstance item)
        {
            if (item == null)
            {
                EditorGUILayout.LabelField("Collection not found...");
                return;
            }

            var col = item as IUnityItemInstance;

            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.LabelField("Item: " + item, UnityEditor.EditorStyles.boldLabel);
            EditorGUILayout.LabelField("Guid: " + item.ID);
            EditorGUILayout.LabelField("Definition: " + item.itemDefinition.ID);
            EditorGUILayout.LabelField("Type: " + item.GetType().Name);

            if (col?.collectionEntry != null)
            {
                EditorGUILayout.LabelField("Amount: " + col.collectionEntry.amount + "/" + col.itemDefinition.maxStackSize);

                var unetCol = col.collectionEntry.collection as IUNetCollection;
                if (unetCol != null)
                {
                    EditorGUILayout.LabelField("Collection: " + unetCol.collectionName, UnityEditor.EditorStyles.boldLabel);

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Guid: " + unetCol.ID);

                    if (GUILayout.Button("Inspect collection", "minibutton", GUILayout.Width(130f)))
                    {
                        CollectionInspectorEditor.ShowWindow();
                        CollectionInspectorEditor.collectionNameOrGuid = unetCol.ID.ToString();
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.EndVertical();
        }
コード例 #2
0
 public static void ShowWindow()
 {
     _window      = GetWindow <CollectionInspectorEditor>();
     _window.name = "Collection inspector";
     _window.Show();
 }
コード例 #3
0
        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();
            }
        }