回答編集履歴

1

追記しました

2019/03/07 00:43

投稿

bochan2
bochan2

スコア2050

test CHANGED
@@ -1 +1,59 @@
1
1
  itemDataBaseがinspectorで設定されていないので設定してください。
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ ItemDatabaseを以下のようにして
12
+
13
+ CreateSlotScriptのOnEnable内でitemDataBase=new ItemDataBase();をやってください。
14
+
15
+ ```C#
16
+
17
+ using System.Collections;
18
+
19
+ using System.Collections.Generic;
20
+
21
+ using UnityEngine;
22
+
23
+
24
+
25
+ public class ItemDataBase
26
+
27
+ {
28
+
29
+ ItemData[] itemlists = new ItemData[2];
30
+
31
+
32
+
33
+ public ItemDataBase()
34
+
35
+ {
36
+
37
+ itemlists [0] = new ItemData (Resources.Load ("prefab name", typeof(Sprite))as Sprite, "namae",MyItem.Item.FlashLight, "info");
38
+
39
+ itemlists [1] = new ItemData (Resources.Load ("prefab name2", typeof(Sprite))as Sprite, "nam",MyItem.Item.FlashLight, "info");
40
+
41
+
42
+
43
+ }
44
+
45
+ public ItemData[] GetItemData() {
46
+
47
+ return itemlists;
48
+
49
+ }
50
+
51
+ public int GetItemTotal() {
52
+
53
+ return itemlists.Length;
54
+
55
+ }
56
+
57
+ }
58
+
59
+ ```