45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
![]() |
using System;
|
||
|
using Sirenix.OdinInspector;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
// ReSharper disable once CheckNamespace
|
||
|
namespace BlueWaterProject
|
||
|
{
|
||
|
public class ItemLootUi : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private RectTransform rectTransform;
|
||
|
[SerializeField] private Image border;
|
||
|
[SerializeField] private Image icon;
|
||
|
[SerializeField] private RectTransform line;
|
||
|
|
||
|
[SerializeField] private bool useAutoDestroy = true;
|
||
|
[ShowIf("@useAutoDestroy")]
|
||
|
[SerializeField] private float autoDestroyTime = 10f;
|
||
|
|
||
|
private Vector3 lootWorldPos;
|
||
|
|
||
|
public void Init(Vector3 value, Sprite sprite = null)
|
||
|
{
|
||
|
lootWorldPos = value;
|
||
|
if (sprite)
|
||
|
{
|
||
|
icon.sprite = sprite;
|
||
|
}
|
||
|
gameObject.SetActive(true);
|
||
|
}
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
if (useAutoDestroy)
|
||
|
{
|
||
|
Destroy(gameObject, autoDestroyTime);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void Update()
|
||
|
{
|
||
|
rectTransform.position = CameraManager.Inst.MainCam.WorldToScreenPoint(lootWorldPos);
|
||
|
}
|
||
|
}
|
||
|
}
|