using System; using UnityEngine; using EvolutStudio.tinysAPI.BaseClasses; namespace EvolutStudio { namespace VRPortfolioWork { namespace SimpleMaterialChooserDemo { public class SimpleMaterialChooserDemoModel : BaseClassModel { #region Public Attributes // materials array public Material[] materials; // reference of the current selected material public Material selectedMaterial; // reference of the current tooltip state public bool currentTooltipState { get { return _currentTooltipState; } } #endregion #region Private Attributes // posible tooltip states (better readability) private static class TooltipState { public static bool show = true; public static bool hide = false; } // Index for the selected material in the material array private int selectedMaterialIndex = 0; // hidden reference for the current Tooltip state private bool _currentTooltipState = TooltipState.hide; #endregion #region Public Functions // implementation of validate public override bool Validate(string notification, UnityEngine.Object DataReference = null) { // check notification for validation if (notification.Equals(BaseClassNotification.POINTERCLICKEVENT)) { // Check if selectedMaterialIndex is below the materials array length, otherwise reset the index to zero if (selectedMaterialIndex < materials.Length - 1) { selectedMaterialIndex++; } else { selectedMaterialIndex = 0; } // set the seleted material acording to the selected material index selectedMaterial = materials[selectedMaterialIndex]; // hide the tooptip _currentTooltipState = TooltipState.hide; } else if (notification.Equals(BaseClassNotification.POINTERENTEREVENT)) { // set the current tooltip state to show _currentTooltipState = TooltipState.show; } else if (notification.Equals(BaseClassNotification.POINTEREXITEVENT)) { // set the current tooltip state to hide _currentTooltipState = TooltipState.hide; } // because there is no condition in this simple demo, return true return true; } #endregion #region Private Functions // Add your private functions #endregion #region Unity Events // Use this for initialization void Awake() { modulInstance.RegisterModel(this); // select a default material, if any are set if (materials.Length != 0) { selectedMaterial = materials[selectedMaterialIndex]; } } #endregion } } } }