using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; public class Interactable : MonoBehaviour { [SerializeField] protected new Collider collider; [SerializeField] protected List interactions; public List Interactions => interactions; public int ActiveInteractionsCount { get { int count = 0; foreach (Interaction interaction in interactions) { if (interaction.Active) count++; } return count; } } public void CreateInteractions() { int count = ActiveInteractionsCount; Bounds obj = collider.bounds; float sizeobj = 1f; float sizebtw = 0.2f; float width = count * sizeobj + (count - 1) * sizebtw; Vector3 point = new Vector3(obj.center.x - width / 2f + sizeobj / 2f, obj.center.y + obj.extents.y); foreach (Interaction interaction in interactions) { if (!interaction.Active) continue; interaction.InitializeButton(point); point.x += sizeobj + sizebtw; } } public void Destroy() { Destroy(gameObject); } }