using NextMind.Examples.Steps; using NextMind.NeuroTags; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace NextMind.Examples.NeuroTagGallery { /// /// is the base class for the NeuroTag Gallery steps. /// public class NeuroTagGalleryStep : AbstractStep { [Header("NeuroTags")] /// /// List of the NeuroTags in the current scene. /// [SerializeField] private List neuroTags = new List(); /// /// The state applied to the step's NeuroTags at start. /// [SerializeField] protected bool neuroTagsEnabledAtStart = false; /// /// The current state (enabled or disabled) of the NeuroTags. /// protected bool neuroTagsEnabled = false; /// /// Animator for the toggle button to activate the NeuroTags. /// [SerializeField] protected Animator neuroTagsAnimator; protected virtual void Awake() { neuroTagsEnabled = neuroTagsEnabledAtStart; neuroTagsAnimator.SetBool("Toggled", neuroTagsEnabled); UpdateNeuroTags(); } public void ToggleNeuroTags() { neuroTagsEnabled = !neuroTagsEnabled; neuroTagsAnimator.SetBool("Toggled", neuroTagsEnabled); UpdateNeuroTags(); } private void UpdateNeuroTags() { neuroTags.ForEach(neuroTag => { neuroTag.enabled = neuroTagsEnabled; for (int rendererIndex = 0; rendererIndex < neuroTag.StimulationRenderers.Length; ++rendererIndex) { Renderer renderer = neuroTag.StimulationRenderers[rendererIndex].GetComponent(); if (renderer == null) { Image image = neuroTag.StimulationRenderers[rendererIndex].GetComponent(); if (image == null) { Debug.LogWarning("No image nor renderer"); } else { image.material.SetFloat("_Blend", 1f); } } else { renderer.material.SetFloat("_Blend", 1f); } } }); } private void Update() { UpdateAnimation(); } protected virtual void UpdateAnimation() { } } }