Add metadata files for LeanTween assets and update existing prefab references
This commit is contained in:
@@ -1,16 +1,40 @@
|
||||
using System;
|
||||
using KBCore.Refs;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Infrastructure.Unity
|
||||
{
|
||||
public class OrbViewAdapter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private ParticleSystem pickupVfx;
|
||||
[Self][SerializeField] private MeshRenderer meshRenderer;
|
||||
|
||||
public event Action OnCollected;
|
||||
|
||||
private MaterialPropertyBlock _propBlock;
|
||||
private static readonly int ColorProperty = Shader.PropertyToID("_BaseColor");
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_propBlock = new MaterialPropertyBlock();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.TryGetComponent<PlayerController>(out var player))
|
||||
{
|
||||
if (pickupVfx)
|
||||
{
|
||||
var vfx = Instantiate(pickupVfx, transform.position, Quaternion.identity);
|
||||
var main = vfx.main;
|
||||
|
||||
meshRenderer.GetPropertyBlock(_propBlock);
|
||||
var currentColor = _propBlock.GetColor(ColorProperty);
|
||||
main.startColor = currentColor;
|
||||
|
||||
Destroy(vfx.gameObject, 2f);
|
||||
}
|
||||
|
||||
OnCollected?.Invoke();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user