UnityBiz/Assets/scripts/Inventory/ItemWorld.cs
adamwi1000 b854205dcb test
2024-08-02 06:41:41 +02:00

38 lines
817 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemWorld : MonoBehaviour
{
public static ItemWorld SpawnItemWorld(Vector3 position, Item item)
{
Transform transform = Instantiate(ItemAssets.Instance.BluePotionPf, position, Quaternion.identity);
ItemWorld itemWorld = transform.GetComponent<ItemWorld>();
itemWorld.SetItem(item);
return itemWorld;
}
private Item item;
private SpriteRenderer spriteRenderer;
private void Awake()
{
spriteRenderer = GetComponent<SpriteRenderer>();
}
public void SetItem(Item item)
{
this.item = item;
}
public Item GetItem()
{
return item;
}
public void DestroySelf()
{
Destroy(gameObject);
}
}