示例#1
0
    public override void OnInspectorGUI()
    {
        if (database)
        {
            EditorGUILayout.BeginHorizontal("Box");
            GUILayout.Label("Items in Database: " + database.items.Count);
            EditorGUILayout.EndHorizontal();
            if (database.items.Count > 0)
            {
                EditorGUILayout.BeginHorizontal("Box");
                GUILayout.Label("Search: ");
                searchString = GUILayout.TextField(searchString);
                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add Item"))
            {
                Debug.Log("Abrir Ventana");
                ItemWindow.ShowEmptyWindow(database);
            }


            if (System.String.IsNullOrEmpty(searchString))
            {
                shouldSearch = false;
            }
            else
            {
                shouldSearch = true;
            }

            foreach (Item item in database.items)
            {
                //dibujar la representacion del item

                if (shouldSearch)
                {
                    if (item.name == searchString || item.name.Contains(searchString) || item.id.ToString() == searchString)
                    {
                        DisplayItem(item);
                    }
                }
                else
                {
                    DisplayItem(item);
                }
            }

            if (deletedItem != null)
            {
                database.items.Remove(deletedItem);
            }
        }
    }