using System;
using UnityEngine;
using EvolutStudio.tinysAPI.BaseClasses;

namespace EvolutStudio
{
    namespace VRPortfolioWork
    {
        namespace Components
        {
            public class SimpleMaterialChangeComponent : BaseClassComponent
            {
                #region Public Attributes

                // reference to the current selected material color
                public Material selectedMaterial;

                #endregion

                #region Private Attributes

                // private reference to the game object renderer instance
                private Renderer _renderer;

                #endregion

                #region Public Functions

                public override void ValidationFailed(string notification)
                {
                    throw new NotImplementedException();
                }

                public override void ValidationSucceeded(string notification)
                {
                    if (notification.Equals(BaseClassNotification.POINTERCLICKEVENT))
                    {
                        // update material from model
                        _renderer.material = selectedMaterial;
                    }
                }

                // Use this for initialization
                public override void Init()
                {
                    _ComponentsArrayIndex = modulInstance.View.RegisterComponent(this);

                    // save the reference
                    _renderer = GetComponent<Renderer>();

                    // update material from model
                    _renderer.material = selectedMaterial;
                }

                #endregion

                #region Private Functions

                // Add your private functions

                #endregion
            }
        }
    }
}