// Use this for initialization void Start() { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); while (counter < amountOfLoot) { counter++; int randomNumber = Random.Range(1, inventoryItemList.itemList.Count - 1); Terrain terrain = Terrain.activeTerrain; float x = Random.Range(5, terrain.terrainData.size.x - 5); float z = Random.Range(5, terrain.terrainData.size.z - 5); if (inventoryItemList.itemList[randomNumber].itemModel == null) counter--; else { GameObject randomLootItem = (GameObject)Instantiate(inventoryItemList.itemList[randomNumber].itemModel); PickUpItem item = randomLootItem.AddComponent<PickUpItem>(); item.item = inventoryItemList.itemList[randomNumber]; randomLootItem.transform.localPosition = new Vector3(x, 0, z); } } }
static void Init() { EditorWindow.GetWindow(typeof(IM_Manager)); headTexture = Resources.Load<Texture>("EditorWindowTextures/headTexture"); skypeTexture = Resources.Load<Texture>("EditorWindowTextures/skype-icon"); emailTexture = Resources.Load<Texture>("EditorWindowTextures/email-icon"); folderIcon = Resources.Load<Texture>("EditorWindowTextures/folder-icon"); Object itemDatabase = Resources.Load("ItemDatabase"); if (itemDatabase == null) inventoryItemList = CreateItemDatabase.createItemDatabase(); else inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); Object attributeDatabase = Resources.Load("AttributeDatabase"); if (attributeDatabase == null) itemAttributeList = CreateAttributeDatabase.createItemAttributeDatabase(); else itemAttributeList = (ItemAttributeList)Resources.Load("AttributeDatabase"); Object inputManager = Resources.Load("InputManager"); if (inputManager == null) inputManagerDatabase = CreateInputManager.createInputManager(); else inputManagerDatabase = (InputManager)Resources.Load("InputManager"); }
public static ItemDataBaseList createItemDatabase() { asset = ScriptableObject.CreateInstance<ItemDataBaseList>(); AssetDatabase.CreateAsset(asset, "Assets/InventoryMaster/Resources/ItemDatabase.asset"); AssetDatabase.SaveAssets(); asset.itemList.Add(new Item()); return asset; }
public static ItemDataBaseList asset; //The List of all Items #if UNITY_EDITOR public static ItemDataBaseList createItemDatabase() //creates a new ItemDatabase(new instance) { asset = ScriptableObject.CreateInstance<ItemDataBaseList>(); //of the ScriptableObject InventoryItemList AssetDatabase.CreateAsset(asset, "Assets/InventoryMaster/Resources/ItemDatabase.asset"); //in the Folder Assets/Resources/ItemDatabase.asset AssetDatabase.SaveAssets(); //and than saves it there asset.itemList.Add(new Item()); return asset; }
void itDestroy() { for (int i = 0; i < theObjects.Length; i++) { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); GameObject randomLootItem = (GameObject)Instantiate(theObjects[i],objectSpawnner.position,Quaternion.identity ); PickUpItem item = randomLootItem.AddComponent<PickUpItem>(); item.item = inventoryItemList.getItemByID(idItem); } soundObject.GetComponent<AudioSource> ().PlayOneShot (breakSound); Destroy (gameObject); }
// Use this for initialization void Start() { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); while (counter < amountOfChest) { counter++; creatingItemsForChest = 0; int itemAmountForChest = Random.Range(minItemInChest, maxItemInChest); List<Item> itemsForChest = new List<Item>(); while (creatingItemsForChest < itemAmountForChest) { randomItemNumber = Random.Range(1, inventoryItemList.itemList.Count - 1); int raffle = Random.Range(1, 100); if (raffle <= inventoryItemList.itemList[randomItemNumber].rarity) { itemsForChest.Add(inventoryItemList.itemList[randomItemNumber].getCopy()); creatingItemsForChest++; } } Terrain terrain = Terrain.activeTerrain; float x = Random.Range(5, terrain.terrainData.size.x - 5); float z = Random.Range(5, terrain.terrainData.size.z - 5); float height = terrain.terrainData.GetHeight((int)x, (int)z); GameObject chest = (GameObject)Instantiate(storageBox); StorageInventory sI = chest.GetComponent<StorageInventory>(); sI.inventory = GameObject.FindGameObjectWithTag("Storage"); for (int i = 0; i < itemsForChest.Count; i++) { sI.storageItems.Add(inventoryItemList.getItemByID(itemsForChest[i].itemID)); int randomValue = Random.Range(1, sI.storageItems[sI.storageItems.Count - 1].maxStack); sI.storageItems[sI.storageItems.Count - 1].itemValue = randomValue; } chest.transform.localPosition = new Vector3(x, height + 2, z); } }
static void Init() { GetWindow(typeof(ItemManager)); Object itemDatabase = Resources.Load("ItemDatabase"); if (itemDatabase == null) inventoryItemList = CreateItemDatabase.createItemDatabase(); else inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); Object attributeDatabase = Resources.Load("AttributeDatabase"); if (attributeDatabase == null) itemAttributeList = CreateAttributeDatabase.createItemAttributeDatabase(); else itemAttributeList = (ItemAttributeList)Resources.Load("AttributeDatabase"); Object inputManager = Resources.Load("InputManager"); if (inputManager == null) inputManagerDatabase = CreateInputManager.createInputManager(); else inputManagerDatabase = (InputManager)Resources.Load("InputManager"); }
// Use this for initialization void Start() { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); }
void ItemDataBase() { EditorGUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, GUILayout.Width(position.width - 18)); //creating a toolbar(tabs) to navigate what you wanna do GUILayout.EndHorizontal(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); GUILayout.Space(10); if (toolbarInt == 0) //if equal 0 than it is "Create Item" { GUI.color = Color.green; if (GUILayout.Button("Add Item", GUILayout.Width(position.width - 23))) { addItem(); showItem = true; } if (showItem) { GUI.color = Color.white; GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23)); try { inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemName, GUILayout.Width(position.width - 30)); //textfield for the itemname which you wanna create inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemID = inventoryItemList.itemList.Count - 1; //itemID getting set automaticly ...its unique...better do not change it :D GUILayout.BeginHorizontal(); GUILayout.Label("Item Description"); //label ItemDescription GUILayout.Space(47); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemDesc, GUILayout.Width(position.width - 180), GUILayout.Height(70)); //Text area for the itemDesc GUILayout.EndHorizontal(); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 33)); //objectfield for the itemicon for your new item inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 33)); //objectfield for the itemmodel for your new item inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemType, GUILayout.Width(position.width - 33)); //the itemtype which you want to have can be selected with the enumpopup inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].maxStack = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].maxStack, GUILayout.Width(position.width - 33)); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].rarity = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].rarity, 0, 100); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 33)); showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes"); if (showItemAttributes) { GUILayout.BeginHorizontal(); addAttributeName = EditorGUILayout.TextField("Name", addAttributeName); GUI.color = Color.green; if (GUILayout.Button("Add")) addAttribute(); GUILayout.EndHorizontal(); GUILayout.Space(10); GUI.color = Color.white; EditorGUI.BeginChangeCheck(); attributeAmount = EditorGUILayout.IntSlider("Amount", attributeAmount, 0, 50); if (EditorGUI.EndChangeCheck()) { attributeName = new int[attributeAmount]; attributeValue = new int[attributeAmount]; } string[] attributes = new string[itemAttributeList.itemAttributeList.Count]; for (int i = 1; i < attributes.Length; i++) { attributes[i] = itemAttributeList.itemAttributeList[i].attributeName; } for (int k = 0; k < attributeAmount; k++) { EditorGUILayout.BeginHorizontal(); attributeName[k] = EditorGUILayout.Popup("Attribute " + (k + 1), attributeName[k], attributes, EditorStyles.popup); attributeValue[k] = EditorGUILayout.IntField("Value", attributeValue[k]); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Save")) { List<ItemAttribute> iA = new List<ItemAttribute>(); for (int i = 0; i < attributeAmount; i++) { iA.Add(new ItemAttribute(attributes[attributeName[i]], attributeValue[i])); } inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemAttributes = iA; showItem = false; } } GUILayout.EndVertical(); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].indexItemInList = 999; } catch { } GUILayout.EndVertical(); } } if (toolbarInt == 1) //if toolbar equals 1...manage items...alle items are editable here { if (inventoryItemList == null) inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); if (inventoryItemList.itemList.Count == 1) //if there is no item in the database you get this...yes it is right to have == 1 { GUILayout.Label("There is no Item in the Database!"); //information that you do not have one } else { GUILayout.BeginVertical(); for (int i = 1; i < inventoryItemList.itemList.Count; i++) //get through all items which are there in the itemdatabase { try { manageItem.Add(false); //foldout is closed at default GUILayout.BeginVertical("Box"); manageItem[i] = EditorGUILayout.Foldout(manageItem[i], "" + inventoryItemList.itemList[i].itemName); //create for every item which you have in the itemdatabase a foldout if (manageItem[i]) //if you press on it you get this { EditorUtility.SetDirty(inventoryItemList); //message the scriptableobject that you change something now GUI.color = Color.red; //all upcoming GUIelements get changed to red if (GUILayout.Button("Delete Item")) //create button that deletes the item { inventoryItemList.itemList.RemoveAt(i); //remove the item out of the itemdatabase EditorUtility.SetDirty(inventoryItemList); //and message the database again that you changed something } GUI.color = Color.white; //next GUIElements will be white inventoryItemList.itemList[i].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[i].itemName, GUILayout.Width(position.width - 45)); //textfield for the itemname which you wanna create inventoryItemList.itemList[i].itemID = i; //itemID getting set automaticly ...its unique...better do not change it :D GUILayout.BeginHorizontal(); GUILayout.Label("Item ID"); GUILayout.Label("" + i); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Item Description"); //label ItemDescription GUILayout.Space(47); inventoryItemList.itemList[i].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[i].itemDesc, GUILayout.Width(position.width - 195), GUILayout.Height(70)); //Text area for the itemDesc GUILayout.EndHorizontal(); inventoryItemList.itemList[i].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[i].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 45)); //objectfield for the itemicon for your new item inventoryItemList.itemList[i].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[i].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 45)); //objectfield for the itemmodel for your new item inventoryItemList.itemList[i].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[i].itemType, GUILayout.Width(position.width - 45)); //the itemtype which you want to have can be selected with the enumpopup inventoryItemList.itemList[i].maxStack = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[i].maxStack, GUILayout.Width(position.width - 45)); inventoryItemList.itemList[i].rarity = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[i].rarity, 0, 100); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 45)); showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes"); if (showItemAttributes) { string[] attributes = new string[itemAttributeList.itemAttributeList.Count]; for (int t = 1; t < attributes.Length; t++) { attributes[t] = itemAttributeList.itemAttributeList[t].attributeName; } if (inventoryItemList.itemList[i].itemAttributes.Count != 0) { for (int t = 0; t < inventoryItemList.itemList[i].itemAttributes.Count; t++) { for (int z = 1; z < attributes.Length; z++) { if (inventoryItemList.itemList[i].itemAttributes[t].attributeName == attributes[z]) { attributeNamesManage[t] = z; attributeValueManage[t] = inventoryItemList.itemList[i].itemAttributes[t].attributeValue; break; } } } } for (int z = 0; z < inventoryItemList.itemList[i].itemAttributes.Count; z++) { EditorGUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("-")) inventoryItemList.itemList[i].itemAttributes.RemoveAt(z); GUI.color = Color.white; attributeNamesManage[z] = EditorGUILayout.Popup(attributeNamesManage[z], attributes, EditorStyles.popup); inventoryItemList.itemList[i].itemAttributes[z].attributeValue = EditorGUILayout.IntField("Value", inventoryItemList.itemList[i].itemAttributes[z].attributeValue); EditorGUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("+")) inventoryItemList.itemList[i].itemAttributes.Add(new ItemAttribute()); GUI.color = Color.white; if (GUILayout.Button("Save")) { List<ItemAttribute> iA = new List<ItemAttribute>(); for (int k = 0; k < inventoryItemList.itemList[i].itemAttributes.Count; k++) { iA.Add(new ItemAttribute(attributes[attributeNamesManage[k]], attributeValueManage[k])); } inventoryItemList.itemList[i].itemAttributes = iA; GameObject[] items = GameObject.FindGameObjectsWithTag("Item"); for (int z = 0; z < items.Length; z++) { ItemOnObject item = items[z].GetComponent<ItemOnObject>(); if (item.item.itemID == inventoryItemList.itemList[i].itemID) { int value = item.item.itemValue; item.item = inventoryItemList.itemList[i]; item.item.itemValue = value; } } manageItem[i] = false; } } GUILayout.EndVertical(); EditorUtility.SetDirty(inventoryItemList); //message scriptable object that you have changed something } GUILayout.EndVertical(); } catch { } } GUILayout.EndVertical(); } } if (inventoryItemList == null) inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
void BluePrintDataBase() { EditorGUILayout.BeginVertical("Box"); if (inventoryItemList == null) inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); if (bluePrintDatabase == null) bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); GUILayout.BeginHorizontal(); toolbarInt1 = GUILayout.Toolbar(toolbarInt1, toolbarStrings1, GUILayout.Width(position.width - 20)); //creating a toolbar(tabs) to navigate what you wanna do GUILayout.EndHorizontal(); scrollPosition1 = EditorGUILayout.BeginScrollView(scrollPosition1); GUILayout.Space(10); if (toolbarInt1 == 0) //if equal 0 than it is "Create Item" { GUI.color = Color.white; try { GUILayout.BeginVertical("Box"); string[] items = new string[inventoryItemList.itemList.Count]; //create a string array in length of the itemcount for (int i = 1; i < items.Length; i++) //go through the item array { items[i] = inventoryItemList.itemList[i].itemName; //and paste all names into the array } EditorGUILayout.BeginHorizontal(); finalItemID = EditorGUILayout.Popup("Final Item", finalItemID, items, EditorStyles.popup); amountOfFinalItem = EditorGUILayout.IntField("Value", amountOfFinalItem); EditorGUILayout.EndHorizontal(); //timeToCraft = EditorGUILayout.FloatField("Time to craft", timeToCraft); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); amountofingredients = EditorGUILayout.IntSlider("Ingredients", amountofingredients, 1, 50, GUILayout.Width(position.width - 38)); if (EditorGUI.EndChangeCheck()) { ingredients = new int[amountofingredients]; amount = new int[amountofingredients]; } for (int i = 0; i < amountofingredients; i++) { EditorGUILayout.BeginHorizontal(); ingredients[i] = EditorGUILayout.Popup("Ingredient " + i, ingredients[i], items, EditorStyles.popup, GUILayout.Width((position.width / 2) - 20)); amount[i] = EditorGUILayout.IntField("Value", amount[i], GUILayout.Width((position.width / 2) - 20)); EditorGUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("Add Blueprint", GUILayout.Width(position.width - 35), GUILayout.Height(50))) addBlueprint(); GUILayout.EndVertical(); } catch { } } if (toolbarInt1 == 1) { if (bluePrintDatabase == null) { bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); if (bluePrintDatabase == null) { bluePrintDatabase = CreateBlueprintDatabase.createBlueprintDatabase(); bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); } } if (bluePrintDatabase.blueprints.Count == 1) { GUILayout.Label("There is no Blueprint in the Database!"); } else { GUILayout.BeginVertical(); for (int i = 1; i < bluePrintDatabase.blueprints.Count; i++) { try { manageItem1.Add(false); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23)); manageItem1[i] = EditorGUILayout.Foldout(manageItem1[i], "" + bluePrintDatabase.blueprints[i].finalItem.itemName); //create for every item which you have in the itemdatabase a foldout if (manageItem1[i]) //if you press on it you get this { EditorGUI.indentLevel++; EditorUtility.SetDirty(bluePrintDatabase); //message the scriptableobject that you change something now GUI.color = Color.red; //all upcoming GUIelements get changed to red if (GUILayout.Button("Delete Blueprint", GUILayout.Width(position.width - 38))) //create button that deletes the item { bluePrintDatabase.blueprints.RemoveAt(i); //remove the item out of the itemdatabase EditorUtility.SetDirty(bluePrintDatabase); //and message the database again that you changed something } GUI.color = Color.white; EditorUtility.SetDirty(bluePrintDatabase); bluePrintDatabase.blueprints[i].amountOfFinalItem = EditorGUILayout.IntField("Amount of final items", bluePrintDatabase.blueprints[i].amountOfFinalItem, GUILayout.Width(position.width - 35)); //bluePrintDatabase.blueprints[i].timeToCraft = EditorGUILayout.FloatField("Time to craft", bluePrintDatabase.blueprints[i].timeToCraft); EditorUtility.SetDirty(bluePrintDatabase); string[] items = new string[inventoryItemList.itemList.Count]; //create a string array in length of the itemcount for (int z = 1; z < items.Length; z++) //go through the item array { items[z] = inventoryItemList.itemList[z].itemName; //and paste all names into the array } GUILayout.Label("Ingredients"); for (int k = 0; k < bluePrintDatabase.blueprints[i].ingredients.Count; k++) { GUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("-")) bluePrintDatabase.blueprints[i].ingredients.RemoveAt(k); GUI.color = Color.white; bluePrintDatabase.blueprints[i].ingredients[k] = EditorGUILayout.Popup("Ingredient " + (k + 1), bluePrintDatabase.blueprints[i].ingredients[k], items, EditorStyles.popup); bluePrintDatabase.blueprints[i].amount[k] = EditorGUILayout.IntField("Value", bluePrintDatabase.blueprints[i].amount[k]); GUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("+")) { bluePrintDatabase.blueprints[i].ingredients.Add(0); bluePrintDatabase.blueprints[i].amount.Add(0); } GUI.color = Color.white; EditorGUI.indentLevel--; EditorUtility.SetDirty(bluePrintDatabase); //message scriptable object that you have changed something } GUILayout.EndVertical(); } catch { } } GUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public void setImportantVariables() { if (itemDatabase == null) itemDatabase = (ItemDataBaseList)Resources.Load("ItemDatabase"); }
void loaded(Scene arg0, LoadSceneMode arg1) { itemDatabase = (ItemDataBaseList)Resources.Load("ItemDatabase"); GameObject p = GameObject.FindGameObjectWithTag("Player"); pi = p.GetComponent <PlayerInventory> (); for (int i = 0; i < inv.Count; i++) { pi.inventory.SetActive(true); pi.inventory.GetComponent <Inventory> ().addItemToInventory(inv [i]); //pi.inventory.SetActive (false); } print(equip.Count); for (int i = 0; i < equip.Count; i++) { pi.characterSystem.SetActive(true); ItemType[] listp = pi.characterSystem.GetComponent <EquipmentSystem> ().itemTypeOfSlots; GameObject item = (GameObject)Instantiate(pi.inventory.GetComponent <Inventory>().getPrefab()); item.GetComponent <ItemOnObject>().item = itemDatabase.getItemByID(equip[i]); print("add"); //for (int i2 = 0; i2 < pi.characterSystem.transform.GetChild (1).transform.childCount; i2++) //{ //if (pi.characterSystem.transform.GetChild (1).transform.GetChild(i2).childCount == 0) //{ for (int j = 0; j < listp.Length; j++) { if (listp [j] == item.GetComponent <ItemOnObject> ().item.itemType) { item.transform.SetParent(pi.characterSystem.transform.GetChild(1).transform.GetChild(j)); item.GetComponent <RectTransform> ().localPosition = Vector3.zero; item.transform.GetChild(0).GetComponent <Image> ().sprite = item.GetComponent <ItemOnObject> ().item.itemIcon; item.GetComponent <ItemOnObject> ().item.indexItemInList = pi.characterSystem.GetComponent <Inventory> ().ItemsInInventory.Count - 1; break; } } //} //} //pi.characterSystem.SetActive (false); } Inventory pii = pi.characterSystem.GetComponent <Inventory> (); //for (int k = 0; k < pii.ItemsInInventory.Count; k++) //{ for (int i = 0; i < pii.transform.childCount; i++) { if (pi.characterSystem.transform.GetChild(1).transform.GetChild(i).childCount != 0) { pi.characterSystem.transform.GetChild(1).transform.GetChild(i).GetChild(0).GetComponent <ConsumeItem> ().item = pi.characterSystem.transform.GetChild(1).transform.GetChild(i).GetChild(0).GetComponent <ItemOnObject> ().item; pi.characterSystem.transform.GetChild(1).transform.GetChild(i).GetChild(0).GetComponent <ConsumeItem> ().consumeIt(); pi.OnGearItem(pi.characterSystem.transform.GetChild(1).transform.GetChild(i).GetChild(0).GetComponent <ConsumeItem> ().item); } } //} pi.maxHealth = maxHP; pi.maxMana = maxMP; pi.maxDamage = maxDmg; pi.maxArmor = maxArm; }
public void getPrefabs() { if (prefabCanvasWithPanel == null) prefabCanvasWithPanel = Resources.Load("Prefabs/Canvas - Inventory") as GameObject; if (prefabSlot == null) prefabSlot = Resources.Load("Prefabs/Slot - Inventory") as GameObject; if (prefabSlotContainer == null) prefabSlotContainer = Resources.Load("Prefabs/Slots - Inventory") as GameObject; if (prefabItem == null) prefabItem = Resources.Load("Prefabs/Item") as GameObject; if (itemDatabase == null) itemDatabase = (ItemDataBaseList)Resources.Load("ItemDatabase"); if (prefabDraggingItemContainer == null) prefabDraggingItemContainer = Resources.Load("Prefabs/DraggingItem") as GameObject; if (prefabPanel == null) prefabPanel = Resources.Load("Prefabs/Panel - Inventory") as GameObject; setImportantVariables(); setDefaultSettings(); adjustInventorySize(); updateSlotAmount(width, height); updateSlotSize(); updatePadding(paddingBetweenX, paddingBetweenY); }
// Use this for initialization void Start() { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); numeroAleatorio = Random.Range(1, inventoryItemList.itemList.Count - 1); }
void ItemDataBase() { EditorGUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, GUILayout.Width(position.width - 18)); //creating a toolbar(tabs) to navigate what you wanna do GUILayout.EndHorizontal(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); GUILayout.Space(10); if (toolbarInt == 0) //if equal 0 than it is "Create Item" { GUI.color = Color.green; if (GUILayout.Button("Add Item", GUILayout.Width(position.width - 23))) { addItem(); showItem = true; } if (showItem) { GUI.color = Color.white; GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23)); try { inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemName, GUILayout.Width(position.width - 30)); //textfield for the itemname which you wanna create inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemID = inventoryItemList.itemList.Count - 1; //itemID getting set automaticly ...its unique...better do not change it :D GUILayout.BeginHorizontal(); GUILayout.Label("Item Description"); //label ItemDescription GUILayout.Space(47); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemDesc, GUILayout.Width(position.width - 180), GUILayout.Height(70)); //Text area for the itemDesc GUILayout.EndHorizontal(); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 33)); //objectfield for the itemicon for your new item inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 33)); //objectfield for the itemmodel for your new item inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemType, GUILayout.Width(position.width - 33)); //the itemtype which you want to have can be selected with the enumpopup inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].maxStack = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].maxStack, GUILayout.Width(position.width - 33)); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].rarity = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].rarity, 0, 1000); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 33)); showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes"); if (showItemAttributes) { GUILayout.BeginHorizontal(); addAttributeName = EditorGUILayout.TextField("Name", addAttributeName); GUI.color = Color.green; if (GUILayout.Button("Add")) { addAttribute(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUI.color = Color.white; EditorGUI.BeginChangeCheck(); attributeAmount = EditorGUILayout.IntSlider("Amount", attributeAmount, 0, 50); if (EditorGUI.EndChangeCheck()) { attributeName = new int[attributeAmount]; attributeValue = new int[attributeAmount]; } string[] attributes = new string[itemAttributeList.itemAttributeList.Count]; for (int i = 1; i < attributes.Length; i++) { attributes[i] = itemAttributeList.itemAttributeList[i].attributeName; } for (int k = 0; k < attributeAmount; k++) { EditorGUILayout.BeginHorizontal(); attributeName[k] = EditorGUILayout.Popup("Attribute " + (k + 1), attributeName[k], attributes, EditorStyles.popup); attributeValue[k] = EditorGUILayout.IntField("Value", attributeValue[k]); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Save")) { List <ItemAttribute> iA = new List <ItemAttribute>(); for (int i = 0; i < attributeAmount; i++) { iA.Add(new ItemAttribute(attributes[attributeName[i]], attributeValue[i])); } inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemAttributes = iA; showItem = false; } } GUILayout.EndVertical(); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].indexItemInList = 999; } catch { } GUILayout.EndVertical(); } } if (toolbarInt == 1) //if toolbar equals 1...manage items...alle items are editable here { if (inventoryItemList == null) { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); } if (inventoryItemList.itemList.Count == 1) //if there is no item in the database you get this...yes it is right to have == 1 { GUILayout.Label("There is no Item in the Database!"); //information that you do not have one } else { GUILayout.BeginVertical(); for (int i = 1; i < inventoryItemList.itemList.Count; i++) //get through all items which are there in the itemdatabase { try { manageItem.Add(false); //foldout is closed at default GUILayout.BeginVertical("Box"); manageItem[i] = EditorGUILayout.Foldout(manageItem[i], "" + inventoryItemList.itemList[i].itemName); //create for every item which you have in the itemdatabase a foldout if (manageItem[i]) //if you press on it you get this { EditorUtility.SetDirty(inventoryItemList); //message the scriptableobject that you change something now GUI.color = Color.red; //all upcoming GUIelements get changed to red if (GUILayout.Button("Delete Item")) //create button that deletes the item { inventoryItemList.itemList.RemoveAt(i); //remove the item out of the itemdatabase EditorUtility.SetDirty(inventoryItemList); //and message the database again that you changed something } GUI.color = Color.white; //next GUIElements will be white inventoryItemList.itemList[i].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[i].itemName, GUILayout.Width(position.width - 45)); //textfield for the itemname which you wanna create inventoryItemList.itemList[i].itemID = i; //itemID getting set automaticly ...its unique...better do not change it :D GUILayout.BeginHorizontal(); GUILayout.Label("Item ID"); GUILayout.Label("" + i); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Item Description"); //label ItemDescription GUILayout.Space(47); inventoryItemList.itemList[i].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[i].itemDesc, GUILayout.Width(position.width - 195), GUILayout.Height(70)); //Text area for the itemDesc GUILayout.EndHorizontal(); inventoryItemList.itemList[i].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[i].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 45)); //objectfield for the itemicon for your new item inventoryItemList.itemList[i].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[i].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 45)); //objectfield for the itemmodel for your new item inventoryItemList.itemList[i].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[i].itemType, GUILayout.Width(position.width - 45)); //the itemtype which you want to have can be selected with the enumpopup inventoryItemList.itemList[i].maxStack = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[i].maxStack, GUILayout.Width(position.width - 45)); inventoryItemList.itemList[i].rarity = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[i].rarity, 0, 1000); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 45)); showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes"); if (showItemAttributes) { string[] attributes = new string[itemAttributeList.itemAttributeList.Count]; for (int t = 1; t < attributes.Length; t++) { attributes[t] = itemAttributeList.itemAttributeList[t].attributeName; } if (inventoryItemList.itemList[i].itemAttributes.Count != 0) { for (int t = 0; t < inventoryItemList.itemList[i].itemAttributes.Count; t++) { for (int z = 1; z < attributes.Length; z++) { if (inventoryItemList.itemList[i].itemAttributes[t].attributeName == attributes[z]) { attributeNamesManage[t] = z; attributeValueManage[t] = inventoryItemList.itemList[i].itemAttributes[t].attributeValue; break; } } } } for (int z = 0; z < inventoryItemList.itemList[i].itemAttributes.Count; z++) { EditorGUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("-")) { inventoryItemList.itemList[i].itemAttributes.RemoveAt(z); } GUI.color = Color.white; attributeNamesManage[z] = EditorGUILayout.Popup(attributeNamesManage[z], attributes, EditorStyles.popup); inventoryItemList.itemList[i].itemAttributes[z].attributeValue = EditorGUILayout.IntField("Value", inventoryItemList.itemList[i].itemAttributes[z].attributeValue); EditorGUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("+")) { inventoryItemList.itemList[i].itemAttributes.Add(new ItemAttribute()); } GUI.color = Color.white; if (GUILayout.Button("Save")) { List <ItemAttribute> iA = new List <ItemAttribute>(); for (int k = 0; k < inventoryItemList.itemList[i].itemAttributes.Count; k++) { iA.Add(new ItemAttribute(attributes[attributeNamesManage[k]], attributeValueManage[k])); } inventoryItemList.itemList[i].itemAttributes = iA; GameObject[] items = GameObject.FindGameObjectsWithTag("Item"); for (int z = 0; z < items.Length; z++) { ItemOnObject item = items[z].GetComponent <ItemOnObject>(); if (item.item.itemID == inventoryItemList.itemList[i].itemID) { int value = item.item.itemValue; item.item = inventoryItemList.itemList[i]; item.item.itemValue = value; } } manageItem[i] = false; } } GUILayout.EndVertical(); EditorUtility.SetDirty(inventoryItemList); //message scriptable object that you have changed something } GUILayout.EndVertical(); } catch { } } GUILayout.EndVertical(); } } if (inventoryItemList == null) { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
void Start() { itemDatabase = (ItemDataBaseList)Resources.Load("ItemDatabase"); }
void ItemDataBase() { EditorGUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, GUILayout.Width(position.width - 18)); } GUILayout.EndHorizontal(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); { GUILayout.Space(10); if (toolbarInt == 0) //Create Item { GUI.color = Color.green; ///https://docs.unity3d.com/ScriptReference/GUILayout.Width.html if (GUILayout.Button("Add Item", GUILayout.Width(position.width - 23))) //position.width : the width of the rectangle, measured from the X position { AddItem(); showItem = true; } if (showItem) { GUI.color = Color.white; GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23)); try { itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemName = EditorGUILayout.TextField("Item Name", itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemName, GUILayout.Width(position.width - 30)); itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemID = itemDatabaseList.itemList.Count - 1; GUILayout.BeginHorizontal(); { GUILayout.Label("Item Description"); GUILayout.Space(47); itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemDesc = EditorGUILayout.TextArea(itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemDesc, GUILayout.Width(position.width - 180), GUILayout.Height(70)); } GUILayout.EndHorizontal(); itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 33)); itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemPrefab = (GameObject)EditorGUILayout.ObjectField("Item Prefab", itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemPrefab, typeof(GameObject), false, GUILayout.Width(position.width - 33)); itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemType, GUILayout.Width(position.width - 33)); itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].rarity = EditorGUILayout.IntSlider("Rarity", itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].rarity, 0, 100); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 33)); { showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes"); if (showItemAttributes) { GUILayout.BeginHorizontal(); { addAttributeName = EditorGUILayout.TextField("Name", addAttributeName); GUI.color = Color.green; if (GUILayout.Button("Add")) { AddAttribute(); } } GUILayout.EndHorizontal(); GUILayout.Space(10); GUI.color = Color.white; { EditorGUI.BeginChangeCheck(); attributeAmount = EditorGUILayout.IntSlider("Amount", attributeAmount, 0, 50); if (EditorGUI.EndChangeCheck()) { attributeName = new int[attributeAmount]; attributeValue = new int[attributeAmount]; } } string[] attributes = new string[itemAttributeList.itemAttributeList.Count]; for (int i = 0; i < attributes.Length; i++) { attributes[i] = itemAttributeList.itemAttributeList[i].attributeName; } for (int k = 0; k < attributeAmount; k++) { EditorGUILayout.BeginHorizontal(); attributeName[k] = EditorGUILayout.Popup("Attribute " + (k + 1), attributeName[k], attributes, EditorStyles.popup); attributeValue[k] = EditorGUILayout.IntField("Value", attributeValue[k]); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Save")) { List <ItemAttribute> iA = new List <ItemAttribute>(); for (int i = 0; i < attributeAmount; i++) { iA.Add(new ItemAttribute(attributes[attributeName[i]], attributeValue[i])); } itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].itemAttributes = iA; } } } GUILayout.EndVertical(); itemDatabaseList.itemList[itemDatabaseList.itemList.Count - 1].indexItemInList = 999; } catch {} GUILayout.EndVertical(); } } if (toolbarInt == 1) //manage Item { if (itemDatabaseList == null) { itemDatabaseList = (ItemDataBaseList)Resources.Load("ItemDatabase"); } if (itemDatabaseList.itemList.Count < 1) { GUILayout.Label("There is no Item in the Database!"); } else { GUILayout.BeginVertical(); { for (int i = 0; i < itemDatabaseList.itemList.Count; i++) { try { manageItem.Add(false); GUILayout.BeginVertical("Box"); { manageItem[i] = EditorGUILayout.Foldout(manageItem[i], "" + itemDatabaseList.itemList[i].itemName); if (manageItem[i]) { EditorUtility.SetDirty(itemDatabaseList); GUI.color = Color.red; if (GUILayout.Button("Delete Item")) { itemDatabaseList.itemList.RemoveAt(i); EditorUtility.SetDirty(itemDatabaseList); } GUI.color = Color.white; itemDatabaseList.itemList[i].itemName = EditorGUILayout.TextField("Item Name", itemDatabaseList.itemList[i].itemName, GUILayout.Width(position.width - 45)); itemDatabaseList.itemList[i].itemID = i; GUILayout.BeginHorizontal(); { GUILayout.Label("Item ID"); GUILayout.Label(" " + i); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Item Description"); GUILayout.Space(47); itemDatabaseList.itemList[i].itemDesc = EditorGUILayout.TextArea(itemDatabaseList.itemList[i].itemDesc, GUILayout.Width(position.width - 195), GUILayout.Height(70)); } GUILayout.EndHorizontal(); itemDatabaseList.itemList[i].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", itemDatabaseList.itemList[i].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 45)); itemDatabaseList.itemList[i].itemPrefab = (GameObject)EditorGUILayout.ObjectField("Item Model", itemDatabaseList.itemList[i].itemPrefab, typeof(GameObject), false, GUILayout.Width(position.width - 45)); itemDatabaseList.itemList[i].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", itemDatabaseList.itemList[i].itemType, GUILayout.Width(position.width - 45)); itemDatabaseList.itemList[i].rarity = EditorGUILayout.IntSlider("Rarity", itemDatabaseList.itemList[i].rarity, 0, 100); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 45)); { showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item Attributes"); if (showItemAttributes) { int iaCount = itemDatabaseList.itemList[i].itemAttributes.Count; string[] attributes = new string[iaCount]; string[] allAtributes = new string[itemAttributeList.itemAttributeList.Count]; for (int ii = 0; ii < itemAttributeList.itemAttributeList.Count; ii++) { allAtributes[ii] = itemAttributeList.itemAttributeList[ii].attributeName; } for (int t = 0; t < attributes.Length; t++) { attributes[t] = itemDatabaseList.itemList[i].itemAttributes[t].attributeName; attributeNamesManage[t] = t; attributeValueManage[t] = itemDatabaseList.itemList[i].itemAttributes[t].attributeValue; } for (int z = 0; z < iaCount; z++) { EditorGUILayout.BeginHorizontal(); { GUI.color = Color.red; if (GUILayout.Button("-")) { itemDatabaseList.itemList[i].itemAttributes.RemoveAt(z); } GUI.color = Color.white; attributeNamesManage[z] = EditorGUILayout.Popup(attributeNamesManage[z], attributes, EditorStyles.popup); itemDatabaseList.itemList[i].itemAttributes[z].attributeValue = EditorGUILayout.IntField("Value", itemDatabaseList.itemList[i].itemAttributes[z].attributeValue); } EditorGUILayout.EndHorizontal(); } newAttributeIndex = EditorGUILayout.Popup(newAttributeIndex, allAtributes, EditorStyles.popup); newAttributeValue = EditorGUILayout.IntField("Value:", newAttributeValue); GUI.color = Color.green; if (GUILayout.Button("+")) { string newAttributeName = itemAttributeList.itemAttributeList[newAttributeIndex].attributeName; itemDatabaseList.itemList[i].itemAttributes.Add(new ItemAttribute(newAttributeName, newAttributeValue)); } GUI.color = Color.white; if (GUILayout.Button("Save")) { List <ItemAttribute> iA = new List <ItemAttribute>(); for (int k = 0; k < itemDatabaseList.itemList[i].itemAttributes.Count; k++) { iA.Add(new ItemAttribute(attributes[attributeNamesManage[k]], attributeValueManage[k])); } itemDatabaseList.itemList[i].itemAttributes = iA; GameObject[] items = GameObject.FindGameObjectsWithTag("Item"); for (int z = 0; z < items.Length; z++) { ItemHandleOnGUI itemhandle = items[z].GetComponent <ItemHandleOnGUI>(); if (itemhandle.item.itemID == itemDatabaseList.itemList[i].itemID) { itemhandle.item = itemDatabaseList.itemList[i]; Debug.Log("Reset"); } } manageItem[i] = false; } } } GUILayout.EndVertical(); EditorUtility.SetDirty(itemDatabaseList); } } GUILayout.EndVertical(); } catch { } } } GUILayout.EndVertical(); } } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
void BluePrintDataBase() { EditorGUILayout.BeginVertical("Box"); if (inventoryItemList == null) { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); } if (bluePrintDatabase == null) { bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); } GUILayout.BeginHorizontal(); toolbarInt1 = GUILayout.Toolbar(toolbarInt1, toolbarStrings1, GUILayout.Width(position.width - 20)); //creating a toolbar(tabs) to navigate what you wanna do GUILayout.EndHorizontal(); scrollPosition1 = EditorGUILayout.BeginScrollView(scrollPosition1); GUILayout.Space(10); if (toolbarInt1 == 0) //if equal 0 than it is "Create Item" { GUI.color = Color.white; try { GUILayout.BeginVertical("Box"); string[] items = new string[inventoryItemList.itemList.Count]; //create a string array in length of the itemcount for (int i = 1; i < items.Length; i++) //go through the item array { items[i] = inventoryItemList.itemList[i].itemName; //and paste all names into the array } EditorGUILayout.BeginHorizontal(); finalItemID = EditorGUILayout.Popup("Final Item", finalItemID, items, EditorStyles.popup); amountOfFinalItem = EditorGUILayout.IntField("Value", amountOfFinalItem); EditorGUILayout.EndHorizontal(); //timeToCraft = EditorGUILayout.FloatField("Time to craft", timeToCraft); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); amountofingredients = EditorGUILayout.IntSlider("Ingredients", amountofingredients, 1, 50, GUILayout.Width(position.width - 38)); if (EditorGUI.EndChangeCheck()) { ingredients = new int[amountofingredients]; amount = new int[amountofingredients]; } for (int i = 0; i < amountofingredients; i++) { EditorGUILayout.BeginHorizontal(); ingredients[i] = EditorGUILayout.Popup("Ingredient " + i, ingredients[i], items, EditorStyles.popup, GUILayout.Width((position.width / 2) - 20)); amount[i] = EditorGUILayout.IntField("Value", amount[i], GUILayout.Width((position.width / 2) - 20)); EditorGUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("Add Blueprint", GUILayout.Width(position.width - 35), GUILayout.Height(50))) { addBlueprint(); } GUILayout.EndVertical(); } catch { } } if (toolbarInt1 == 1) { if (bluePrintDatabase == null) { bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); if (bluePrintDatabase == null) { bluePrintDatabase = CreateBlueprintDatabase.createBlueprintDatabase(); bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); } } if (bluePrintDatabase.blueprints.Count == 1) { GUILayout.Label("There is no Blueprint in the Database!"); } else { GUILayout.BeginVertical(); for (int i = 1; i < bluePrintDatabase.blueprints.Count; i++) { try { manageItem1.Add(false); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23)); manageItem1[i] = EditorGUILayout.Foldout(manageItem1[i], "" + bluePrintDatabase.blueprints[i].finalItem.itemName); //create for every item which you have in the itemdatabase a foldout if (manageItem1[i]) //if you press on it you get this { EditorGUI.indentLevel++; EditorUtility.SetDirty(bluePrintDatabase); //message the scriptableobject that you change something now GUI.color = Color.red; //all upcoming GUIelements get changed to red if (GUILayout.Button("Delete Blueprint", GUILayout.Width(position.width - 38))) //create button that deletes the item { bluePrintDatabase.blueprints.RemoveAt(i); //remove the item out of the itemdatabase EditorUtility.SetDirty(bluePrintDatabase); //and message the database again that you changed something } GUI.color = Color.white; EditorUtility.SetDirty(bluePrintDatabase); bluePrintDatabase.blueprints[i].amountOfFinalItem = EditorGUILayout.IntField("Amount of final items", bluePrintDatabase.blueprints[i].amountOfFinalItem, GUILayout.Width(position.width - 35)); //bluePrintDatabase.blueprints[i].timeToCraft = EditorGUILayout.FloatField("Time to craft", bluePrintDatabase.blueprints[i].timeToCraft); EditorUtility.SetDirty(bluePrintDatabase); string[] items = new string[inventoryItemList.itemList.Count]; //create a string array in length of the itemcount for (int z = 1; z < items.Length; z++) //go through the item array { items[z] = inventoryItemList.itemList[z].itemName; //and paste all names into the array } GUILayout.Label("Ingredients"); for (int k = 0; k < bluePrintDatabase.blueprints[i].ingredients.Count; k++) { GUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("-")) { bluePrintDatabase.blueprints[i].ingredients.RemoveAt(k); } GUI.color = Color.white; bluePrintDatabase.blueprints[i].ingredients[k] = EditorGUILayout.Popup("Ingredient " + (k + 1), bluePrintDatabase.blueprints[i].ingredients[k], items, EditorStyles.popup); bluePrintDatabase.blueprints[i].amount[k] = EditorGUILayout.IntField("Value", bluePrintDatabase.blueprints[i].amount[k]); GUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("+")) { bluePrintDatabase.blueprints[i].ingredients.Add(0); bluePrintDatabase.blueprints[i].amount.Add(0); } GUI.color = Color.white; EditorGUI.indentLevel--; EditorUtility.SetDirty(bluePrintDatabase); //message scriptable object that you have changed something } GUILayout.EndVertical(); } catch { } } GUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }