Looking for tutorials for my inventory program, i have followed this and it sort for gives me what i want, but it seems abit unfinished e.g how to get items in world, image/model of items etc.
This video should be approiate
Please note i’d rather not use a free/payed unity asset, how am i going to learn?
Current results
Editor Dropdown items
I want to make all weapons a drop down to, the way hes done it is by creating a variable for each drop-down. i plan to add tons of items in future. Also i fear it will make all items dropdown and i only want to see 1 item that i may want to edit.
Search bar
A search bar to search all items of all category’s would be very helpful
Drag drop into world
I would like to drag and drop my items into the world to be ready for the player to pickup when in game.
Item Image
I would like to add a texture to the image (its a 2D game) for the ingame world (im looking into that now, but some help would be cool)
In-game world picking items up and storing them
I want to player to pick up the item and able to press a button if he/she wants to pick it up. i know how to do that, but i dont know to add the item to the inverotry.
Like i said this is what ive got, ive done everything in the tutorial series.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
[CustomEditor(typeof(ItemManager))]
internal class ItemManagerInspector : Editor {
bool showingWeapons = false;
bool showingArmor = false;
bool showingConsumable = false;
public override void OnInspectorGUI()
{
ItemManager im = target as ItemManager;
List<Weapon> weapons = new List<Weapon>();
List<Armor> armors = new List<Armor>();
List<Consumable> consumables = new List<Consumable>();
for (int i = 0; i < im.itemList.Count; i++)
{
if(im.itemList[i].GetType() == typeof(Weapon))
{
weapons.Add((Weapon)im.itemList[i]);
}
if(im.itemList[i].GetType() == typeof(Armor))
{
armors.Add((Armor)im.itemList[i]);
}
if(im.itemList[i].GetType() == typeof(Consumable))
{
consumables.Add((Consumable)im.itemList[i]);
}
}
//-----------------------------------Number of ALL items----------------------------
EditorGUILayout.LabelField ("Total Items:" + im.itemList.Count.ToString ());
//------------------------------>>>>>>>>WEAPONS<<<<<<<<------------------------
//-----------------------------------Number of ALL weapons----------------------------
showingWeapons = EditorGUILayout.Foldout(showingWeapons, "weapons: " + weapons.Count.ToString());
if(showingWeapons == true)
{
//-----------------------------------Add new weapons----------------------------
if(GUILayout.Button("Add new Weapon"))
{
Weapon newWeapon = (Weapon)ScriptableObject.CreateInstance<Weapon>();
newWeapon.name = "NEW WEAPON";
newWeapon.description = "";
newWeapon.cost = 0;
newWeapon.damage = 0;
im.itemList.Add(newWeapon);
}
//----------------------Displays weapons weapon properties----------------------------
EditorGUI.indentLevel = 2;
//Displays all weapons in database
for (int i = 0; i <weapons.Count; i++)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(weapons[i].name);
if(GUILayout.Button("-"))
{
im.itemList.Remove(weapons[i]);
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel += 1;
weapons[i].name = EditorGUILayout.TextField("Name: ", weapons[i].name);
weapons[i].description = EditorGUILayout.TextField("Description: ", weapons[i].description);
weapons[i].cost = int.Parse(EditorGUILayout.TextField("Cost: ", weapons[i].cost.ToString()));
weapons[i].damage = int.Parse(EditorGUILayout.TextField("Damage: ", weapons[i].damage.ToString()));
EditorGUI.indentLevel -= 1;
EditorGUILayout.Space();
}
EditorGUI.indentLevel = 0;
}
//--------------------------------->>>>>>>>ARMOUR<<<<<<<<---------------------------
//--------------------------------Number of ALL armour-------------------------------
showingArmor = EditorGUILayout.Foldout(showingArmor, "armors: " + armors.Count.ToString());
if(showingArmor == true)
//----------------------Displays armour armour properties----------------------------
{
EditorGUI.indentLevel = 2;
//Displays all armours in database
for (int i = 0; i <armors.Count; i++)
{
EditorGUILayout.LabelField(armors[i].name);
}
EditorGUI.indentLevel = 0;
}
showingConsumable = EditorGUILayout.Foldout(showingConsumable, "consumables: " + consumables.Count.ToString());
if(showingConsumable == true)
{
EditorGUI.indentLevel = 2;
//Displays all consumables in database
for (int i = 0; i <consumables.Count; i++)
{
EditorGUILayout.LabelField(consumables[i].name);
}
EditorGUI.indentLevel = 0;
}
Item
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Item : ScriptableObject{
public int cost = 0;
public string name = "";
public string description = "";
}
Weapon
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Weapon : Item {
public int damage = 0;
}