81 lines
2.4 KiB
C#
81 lines
2.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using EvolutStudio.tinysAPI.BaseClasses;
|
|
|
|
namespace EvolutStudio
|
|
{
|
|
namespace VRPortfolioWork
|
|
{
|
|
namespace Components
|
|
{
|
|
public class VarnishMaterialChangeComponent : BaseClassComponent
|
|
{
|
|
#region Public Attributes
|
|
|
|
// reference to the current selected material color
|
|
public Material selectedMaterial;
|
|
|
|
// reference to the proxyObject to change the material on
|
|
public GameObject proxyObject;
|
|
|
|
#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))
|
|
{
|
|
// getting the materials array
|
|
Material[] proxyObjectMats = _renderer.materials;
|
|
|
|
// changing the old material with the new one
|
|
proxyObjectMats[3] = selectedMaterial;
|
|
|
|
// overwritting the materials array
|
|
_renderer.materials = proxyObjectMats;
|
|
}
|
|
}
|
|
|
|
// Use this for initialization
|
|
public override void Init()
|
|
{
|
|
_ComponentsArrayIndex = modulInstance.View.RegisterComponent(this);
|
|
|
|
// save the reference
|
|
_renderer = proxyObject.GetComponent<Renderer>();
|
|
|
|
// getting the materials array
|
|
Material[] proxyObjectMats = _renderer.materials;
|
|
|
|
// changing the old material with the new one
|
|
proxyObjectMats[3] = selectedMaterial;
|
|
|
|
// overwritting the materials array
|
|
_renderer.materials = proxyObjectMats;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Functions
|
|
|
|
// Add your private functions
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
}
|