mirror of
https://github.com/DerTyp7/example-top-down-unity.git
synced 2025-10-30 04:47:09 +01:00
Added TMP
This commit is contained in:
20
Assets/Scripts/Interactable.cs
Normal file
20
Assets/Scripts/Interactable.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Interactable : MonoBehaviour
|
||||
{
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void interact()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Interactable.cs.meta
Normal file
11
Assets/Scripts/Interactable.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59a114e9b82af2e49a1e22aab16fd0d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -22,6 +22,8 @@ public class Inventory : MonoBehaviour
|
||||
/// </summary>
|
||||
|
||||
|
||||
public delegate void OnItemChanged();
|
||||
public OnItemChanged onItemChangedCallback; //
|
||||
|
||||
List<Slot> inventory = new List<Slot>();
|
||||
|
||||
@@ -36,7 +38,8 @@ public class Inventory : MonoBehaviour
|
||||
{
|
||||
inventory.Add(new Slot(maxSpaceOfSlots));
|
||||
}
|
||||
|
||||
if (onItemChangedCallback != null)
|
||||
onItemChangedCallback.Invoke();
|
||||
}
|
||||
public void addInventorySlots(int numberOfSlots, int maxSpaceOfSlots = 10)
|
||||
{
|
||||
@@ -46,7 +49,8 @@ public class Inventory : MonoBehaviour
|
||||
{
|
||||
inventory.Add(new Slot(maxSpaceOfSlots));
|
||||
}
|
||||
|
||||
if (onItemChangedCallback != null)
|
||||
onItemChangedCallback.Invoke();
|
||||
}
|
||||
public int addItemAt(int index, Item itemType,int count)
|
||||
{
|
||||
@@ -65,16 +69,23 @@ public class Inventory : MonoBehaviour
|
||||
|
||||
if (inventory[index].MaxItems == inventory[index].Count)
|
||||
{
|
||||
|
||||
if (onItemChangedCallback != null)
|
||||
onItemChangedCallback.Invoke();
|
||||
return count; // Can't add any items if the slot is full.
|
||||
}
|
||||
else if (inventory[index].MaxItems >= inventory[index].Count + count)
|
||||
{
|
||||
inventory[index].addItem(count); // Adds all items if there is enought space.
|
||||
if(onItemChangedCallback != null)
|
||||
onItemChangedCallback.Invoke();
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
int rest = count - inventory[index].MaxItems - inventory[index].Count;
|
||||
inventory[index].addItem(inventory[index].MaxItems - inventory[index].Count); // Adds the number of items until the slot is full and returns the number of items that didn't fit.
|
||||
if (onItemChangedCallback != null)
|
||||
onItemChangedCallback.Invoke();
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,19 @@ public class InventoryController : MonoBehaviour
|
||||
private void Awake()
|
||||
{
|
||||
inventory = transform.GetComponent<Inventory>();
|
||||
inventory.createEmptyInventory(5,10);
|
||||
inventory.createEmptyInventory(8,10);
|
||||
|
||||
inventory.addItemAt(0, item1, 8);
|
||||
inventory.addItemAt(0, item1, 1);
|
||||
inventory.addItemAt(3, item2, 15);
|
||||
inventory.addItemAt(4, item1, 3);
|
||||
|
||||
/*
|
||||
Debug.Log(inventory.addItemAt(0, item2, 15));
|
||||
Debug.Log(inventory.getInventory[0].Count);
|
||||
Debug.Log(inventory.removeItemAt(0, 10));
|
||||
Debug.Log(inventory.getInventory[0].Count);
|
||||
*/
|
||||
*/
|
||||
uiInventory.setInventory(inventory);
|
||||
}
|
||||
void Start()
|
||||
|
||||
237
Assets/Scripts/Inventory/Items/ContainerTemplate.prefab
Normal file
237
Assets/Scripts/Inventory/Items/ContainerTemplate.prefab
Normal file
@@ -0,0 +1,237 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1031884711933943707
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2917703646420147887}
|
||||
- component: {fileID: 9007524712572810876}
|
||||
- component: {fileID: 5255690316907466923}
|
||||
- component: {fileID: 2310262034725730047}
|
||||
m_Layer: 0
|
||||
m_Name: Button
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2917703646420147887
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1031884711933943707}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 4215392545672552190}
|
||||
m_Father: {fileID: 4215392545969358082}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -0, y: 0}
|
||||
m_SizeDelta: {x: 85, y: 85}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &9007524712572810876
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1031884711933943707}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &5255690316907466923
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1031884711933943707}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 0543fd6b654bedd4fa82b563887c0609, type: 3}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &2310262034725730047
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1031884711933943707}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 0
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.4811321, g: 0.4811321, b: 0.4811321, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 5255690316907466923}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &4215392545672552185
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4215392545672552190}
|
||||
- component: {fileID: 4215392545672552188}
|
||||
- component: {fileID: 4215392545672552191}
|
||||
m_Layer: 0
|
||||
m_Name: Icon
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &4215392545672552190
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4215392545672552185}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2917703646420147887}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 70, y: 70}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &4215392545672552188
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4215392545672552185}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &4215392545672552191
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4215392545672552185}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 475f050511847c0499c1ca4f47fcaefa, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &4215392545969358109
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4215392545969358082}
|
||||
m_Layer: 0
|
||||
m_Name: ContainerTemplate
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &4215392545969358082
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4215392545969358109}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 2917703646420147887}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -443, y: 131.1}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac29b266608f92b419b28a16d8ee7c1b
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Scripts/Inventory/Items/Lumber.asset
Normal file
18
Assets/Scripts/Inventory/Items/Lumber.asset
Normal file
@@ -0,0 +1,18 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: de55e2e3081d4ee4a9d0737e718a5b3b, type: 3}
|
||||
m_Name: Lumber
|
||||
m_EditorClassIdentifier:
|
||||
name: Lumber
|
||||
id: 3
|
||||
isStackable: 1
|
||||
sprite: {fileID: 21300000, guid: 636c61591a702914dadb6abf17d92f6f, type: 3}
|
||||
8
Assets/Scripts/Inventory/Items/Lumber.asset.meta
Normal file
8
Assets/Scripts/Inventory/Items/Lumber.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90fd8b1738596514f860a4ce5adaba88
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Scripts/Inventory/Items/Wood.asset
Normal file
18
Assets/Scripts/Inventory/Items/Wood.asset
Normal file
@@ -0,0 +1,18 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: de55e2e3081d4ee4a9d0737e718a5b3b, type: 3}
|
||||
m_Name: Wood
|
||||
m_EditorClassIdentifier:
|
||||
name: Wood
|
||||
id: 2
|
||||
isStackable: 1
|
||||
sprite: {fileID: 21300000, guid: 30728ae26107dfe438d180ab175fdaca, type: 3}
|
||||
8
Assets/Scripts/Inventory/Items/Wood.asset.meta
Normal file
8
Assets/Scripts/Inventory/Items/Wood.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ac3fa2505f8292498c5c20cf4fea84d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,29 +4,37 @@ using UnityEngine;
|
||||
|
||||
public class Slot
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Holds an itemType the number of items and the number of maxItems
|
||||
/// this has no logic so everything has to be done from the outside
|
||||
/// [Get/Set]
|
||||
/// ItemType
|
||||
/// Count
|
||||
/// MaxItems
|
||||
/// [Methods]
|
||||
/// void addItem(int count = 1)
|
||||
/// void removeItem(int count = 1)
|
||||
/// </summary>
|
||||
|
||||
Item item;
|
||||
int maxItems;
|
||||
int count;
|
||||
public Slot(int maxItems)
|
||||
{
|
||||
item = null;
|
||||
this.maxItems = maxItems;
|
||||
count = 0;
|
||||
|
||||
}
|
||||
public bool removeItem(int count = 1)
|
||||
{
|
||||
this.count -= count;
|
||||
return true;
|
||||
}
|
||||
public bool addItem(int count = 1)
|
||||
{
|
||||
this.count += count;
|
||||
return true;
|
||||
|
||||
}
|
||||
int maxItems = 1;
|
||||
int count = 0;
|
||||
public Item ItemType { get => item; set => item = value; }
|
||||
public int Count { get => count; set => count = value; }
|
||||
public int MaxItems { get => maxItems; set => maxItems = value; }
|
||||
public Slot(int maxItems = 1)
|
||||
{
|
||||
item = null;
|
||||
this.maxItems = maxItems;
|
||||
}
|
||||
public void addItem(int count = 1)
|
||||
{
|
||||
// adds any number of items to the slot will also go over the max items
|
||||
this.count += count;
|
||||
}
|
||||
public void removeItem(int count = 1)
|
||||
{
|
||||
// removes any number of items from the slot will also go negative
|
||||
this.count -= count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,26 +12,37 @@ public class UI_Inventory : MonoBehaviour
|
||||
{
|
||||
//itemSlotTemplate = inventoryContainer.Find("containerTemplate");
|
||||
}
|
||||
public void buttonEvent(int index)
|
||||
{
|
||||
Debug.Log("yeet");
|
||||
}
|
||||
public void setInventory(Inventory inventory)
|
||||
{
|
||||
playerInventory = inventory;
|
||||
inventory.onItemChangedCallback += updateInventory;
|
||||
updateInventory();
|
||||
}
|
||||
private void updateInventory()
|
||||
{
|
||||
|
||||
int rows = 2;
|
||||
int columns = 4;
|
||||
float slotSize = 95;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
float slotSize = 100;
|
||||
int index = 0;
|
||||
//inventoryContainer.GetComponent<RectTransform>().
|
||||
foreach (Slot slot in playerInventory.getInventory)
|
||||
{
|
||||
|
||||
RectTransform itemSlotRectTransform = Instantiate(itemSlotTemplate, inventoryContainer).GetComponent<RectTransform>();
|
||||
itemSlotRectTransform.anchoredPosition = new Vector2(x* slotSize,y * slotSize);
|
||||
itemSlotRectTransform.anchoredPosition = new Vector2(x* slotSize + slotSize * 0.5f,y * slotSize - slotSize * 0.5f );
|
||||
itemSlotRectTransform.gameObject.SetActive(true);
|
||||
|
||||
itemSlotRectTransform.gameObject.name = "ItemSlot" + index;
|
||||
|
||||
if (slot.ItemType != null)
|
||||
{
|
||||
Transform Item = itemSlotRectTransform.Find("ItemTemplate");
|
||||
Transform Item = itemSlotRectTransform.GetChild(0).Find("Icon");
|
||||
Item.gameObject.SetActive(true);
|
||||
Item.GetComponent<Image>().sprite = slot.ItemType.sprite;
|
||||
}
|
||||
@@ -41,6 +52,7 @@ public class UI_Inventory : MonoBehaviour
|
||||
x = 0;
|
||||
y--;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user