46 lines
1001 B
C#
Executable File
46 lines
1001 B
C#
Executable File
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class HumanInteractor : MonoBehaviour
|
|
{
|
|
public GameObject[] showingObjects;
|
|
public UnityEvent OnInteraction;
|
|
public UnityEvent OnClose;
|
|
private bool showing;
|
|
[SerializeField]
|
|
public bool Showing => showing;
|
|
void Start()
|
|
{
|
|
Selector.OnSelectedChanged.AddListener(OnSelectionChanged);
|
|
Refresh();
|
|
}
|
|
|
|
void OnSelectionChanged(){
|
|
Toggle(Selector.selectedHuman==this);
|
|
}
|
|
|
|
public void Toggle(){
|
|
showing = !showing;
|
|
Refresh();
|
|
}
|
|
|
|
public void Toggle(bool value){
|
|
showing = value;
|
|
Refresh();
|
|
}
|
|
|
|
|
|
public void Refresh(){
|
|
foreach(GameObject go in showingObjects){
|
|
go.SetActive(showing);
|
|
}
|
|
if(!showing){
|
|
OnClose.Invoke();
|
|
}else{
|
|
OnInteraction.Invoke();
|
|
}
|
|
}
|
|
}
|