Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- using System.IO;
- public class CreateItemData
- {
- [MenuItem("Assets/Create/Item Data")]
- public static void MakeItemData()
- {
- string name = "ItemData";
- ItemData asset = ScriptableObject.CreateInstance<ItemData>();
- AssetDatabase.CreateAsset(asset, string.Format("Assets/ScriptableObjects/{0}.asset", name));
- AssetDatabase.SaveAssets();
- EditorUtility.FocusProjectWindow();
- Selection.activeObject = asset;
- }
- }
- using UnityEngine;
- [System.Serializable]
- public class Item
- {
- public string Name;
- public ItemType ItemType;
- public Sprite Sprite;
- public GameObject Prefab;
- public int level;
- public float Damage
- {
- get
- {
- return level * 5;
- }
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ItemGenerator : MonoBehaviour
- {
- public ItemData itemData;
- public Transform[] positions;
- private void Start()
- {
- for (int i = 0; i < positions.Length; i++)
- {
- GameObject item = Instantiate(itemData.ItemOfType((ItemType) i).Prefab, positions[i]);
- item.transform.localPosition = Vector3.zero;
- }
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ItemsUIDisplayController : MonoBehaviour
- {
- public ItemData itemData;
- public Image[] itemDisplays;
- private void Start()
- {
- for (int i = 0; i < itemDisplays.Length; i++)
- {
- itemDisplays[i].sprite = itemData.ItemOfType((ItemType) i).Sprite;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement