GameVsJam/3d Prototyp/Assets/Pickupable.cs

42 lines
896 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pickupable : MonoBehaviour
{
[SerializeField]
private Outline _outline;
[SerializeField]
private Color _selectedColor = Color.white;
[SerializeField]
private Color _highlightColor = Color.yellow;
[SerializeField]
private GameObject _model;
[SerializeField]
private string _name;
public GameObject Model => _model;
public string Name => _name;
public void Highlight(bool hightlight)
{
_outline.enabled = hightlight;
_outline.OutlineColor = _highlightColor;
_outline.OutlineWidth = 2;
}
public void SetSelected(bool isSelected)
{
Highlight(true);
if (isSelected)
{
_outline.OutlineColor = _selectedColor;
_outline.OutlineWidth = 4;
}
}
}