I'm wondering if there's a "better", more conventional way to do this. I'm trying to highlight NPCs when they are selected via ProximitySelector. Here's some code illustrating what I'm doing now:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HighlightSelectedUsable : MonoBehaviour {
private ProximitySelector selector;
// Use this for initialization
void Start () {
selector = GetComponent<ProximitySelector>();
selector.SelectedUsableObject += OnSelectedUsable;
selector.DeselectedUsableObject += OnDeselectedUsable;
}
void OnSelectedUsable(Usable usable) {
SpriteRenderer r = usable.gameObject.GetComponentInChildren<SpriteRenderer>();
r.color = Color.blue;
}
void OnDeselectedUsable(Usable usable)
{
SpriteRenderer r = usable.gameObject.GetComponentInChildren<SpriteRenderer>();
r.color = Color.white;
}
}
Thanks!