public void TearDown() { _inventory = null; _lookup = null; _scriptable = null; _reserve = null; }
public override void OnInspectorGUI() { serializedObject.Update(); SerializedProperty list = serializedObject.FindProperty("ItemDatabase"); for (int i = 0; i < list.arraySize; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), true); if (GUILayout.Button(new GUIContent("-", "Delete"), EditorStyles.miniButton, GUILayout.Width(20))) { InventoryScriptable database = target as InventoryScriptable; database.RemoveAtReseed(i); } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button(new GUIContent("+", "Add"), EditorStyles.miniButton, GUILayout.Height(20))) { InventoryScriptable database = target as InventoryScriptable; database.Add(new InventoryScriptable.ItemMapper { Title = "New Item" }); } serializedObject.ApplyModifiedProperties(); }
private void UpdateIgnoreList(InventoryScriptable inventoryScriptable) { var products = ProductLookup.Instance.GetProducts() .Where(i => inventoryScriptable.ProductsToIgnore.Contains(i.Category)); _productsToIgnore.Clear(); _productsToIgnore.AddRange(products.Select(i => i.Category).ToList()); }
private void OnEnable() { database = target as InventoryScriptable; list = serializedObject.FindProperty("ItemDatabase"); re_list = new ReorderableList(list); re_list.onAddCallback += delegate { OnAdd(); }; re_list.onRemoveCallback += delegate { OnRemove(re_list.Selected); }; re_list.onReorderCallback += delegate { ReorderEvent(); }; }
public void BindToInventory(Inventory inventory, InventoryScriptable inventoryScriptable, PlaceablesLookup placeablesLookup, InventoryReserve inventoryReserve) { _inventory = inventory; _inventory.OnProductsChanged += UpdateProductEntry; _placeablesLookup = placeablesLookup; _inventoryReserve = inventoryReserve; InitializePlacer(); UpdateIgnoreList(inventoryScriptable); BindToUI(); }
public void SetUp() { var go = new GameObject(string.Format("TestObject-{0}", DateTime.Now.Millisecond)); _inventory = go.AddComponent <Inventory>(); _lookup = go.AddComponent <MockProductLookup>(); _lookup.AddProduct(new Product { Category = ProductCategory.Raw, ID = ProductId, Name = ProductName }); _scriptable = ScriptableObject.CreateInstance <InventoryScriptable>(); _scriptable.Products = new List <ProductEntryInfo>(); _scriptable.Placeables = new List <string>(); _scriptable.ProductMaxAmount = MaxAmount; }
public void SetUp() { var go = new GameObject(string.Format("TestObject-{0}", DateTime.Now.Millisecond)); _inventory = go.AddComponent <Inventory>(); _lookup = go.AddComponent <MockProductLookup>(); _lookup.AddProduct(new Product { Category = ProductCategory.Raw, ID = ProductId, Name = ProductName }); _scriptable = ScriptableObject.CreateInstance <InventoryScriptable>(); _scriptable.Products = new List <ProductEntryInfo>(); _scriptable.Placeables = new List <string>(); _scriptable.ProductMaxAmount = MaxAmount; _inventory.BindToScriptable(_scriptable, _lookup); _reserve = new InventoryReserve(); _reserve.Initialize(_inventory); _reserve.AddReservation(ProductId, 0, false, false); }