19 lines
621 B
C#
19 lines
621 B
C#
using System;
|
|
using Actions;
|
|
using UnityEngine;
|
|
|
|
public class UnitSelectedVisual : MonoBehaviour {
|
|
[SerializeField] private Unit Unit;
|
|
private MeshRenderer meshRenderer;
|
|
|
|
private void Awake() => meshRenderer = GetComponent<MeshRenderer>();
|
|
|
|
private void Start() {
|
|
UnitActionSystem.Instance.OnSelectedUnitChanged += UnitActionSystem_OnSelectedUnitChanged;
|
|
UpdateVisual();
|
|
}
|
|
|
|
private void UnitActionSystem_OnSelectedUnitChanged(object sender, EventArgs e) => UpdateVisual();
|
|
|
|
private void UpdateVisual() => meshRenderer.enabled = UnitActionSystem.Instance.SelectedUnit == Unit;
|
|
} |