###わからないこと
持ち物画面を作成を作成しようとこちらを参考にしながら作っいますが、エラーが出てしまいます。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ItemDataBase : MonoBehaviour { private ItemData[] itemList = new ItemData[2]; void Start () { itemList[0] = new ItemData(Resources.Load("sword", Sprite), "懐中電灯", "あれば便利な辺りを照らすライト"); itemList[1] = new ItemData(Resources.Load("sword", Sprite), "ナイフ", "切れ味するどいナイフ"); } ItemData GetItemData (int num) { return itemList[num]; } int GetItemTotal () { return itemList.length; } }
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class ItemData { private Sprite itemObj; private String itemInformation; private String itemName; ItemData (Sprite item, String name, String information) { this.itemObj = item; this.itemName = name; this.itemInformation = information; } Sprite GetItemObj() { return this.itemObj; } String GetItemName() { return this.itemName; } String GetItemInformation() { return this.itemInformation; } }
エラー
・Assets/ItemDataBase.cs(10,54): error CS0118: `UnityEngine.Sprite' is a `type' but a `variable' was expected ・Assets/ItemDataBase.cs(10,54): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected ・Assets/ItemDataBase.cs(10,17): error CS0122: `ItemData.ItemData(UnityEngine.Sprite, string, string)' is inaccessible due to its protection level ・Assets/ItemDataBase.cs(11,54): error CS0118: `UnityEngine.Sprite' is a `type' but a `variable' was expected ・Assets/ItemDataBase.cs(11,54): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected ・Assets/ItemDataBase.cs(11,17): error CS0122: `ItemData.ItemData(UnityEngine.Sprite, string, string)' is inaccessible due to its protection level ・Assets/ItemDataBase.cs(16,3): error CS0127: `ItemDataBase.GetItemData(int)': A return keyword must not be followed by any expression when method returns void ・Assets/ItemDataBase.cs(21,19): error CS1061: Type `ItemData[]' does not contain a definition for `length' and no extension method `length' of type `ItemData[]' could be found. Are you missing an assembly reference?
ItemDataBaseは空のオブジェクトにくっつけてます。
Itemがうまくインスタンス化できてないみたいです・・
回答いただけるととても嬉しいです。
お願い致します。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。