ItemContainer.cs
This commit is contained in:
parent
f969277910
commit
6836367207
2 changed files with 23 additions and 1 deletions
|
|
@ -121,6 +121,6 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 4752245148499717901}
|
m_GameObject: {fileID: 4752245148499717901}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 99a22f4d69ce79542adc91bba6943f86, type: 3}
|
m_Script: {fileID: 11500000, guid: 3fd8bc1d313319d4f89f11548ccb1b6a, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
|
|
||||||
22
Assets/Scripts/ItemContainer.cs
Normal file
22
Assets/Scripts/ItemContainer.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ItemContainer : MonoBehaviour {
|
||||||
|
public Item[] allItems;
|
||||||
|
// Start is called before the first frame update
|
||||||
|
public Item GetItemByName(String name) {
|
||||||
|
for (int i = 0; i < allItems.Length; i++) {
|
||||||
|
if (allItems[i].displayName == name) {
|
||||||
|
return allItems[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetItemIdByName(String name) {
|
||||||
|
return GetItemByName(name).id;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue