Some checks failed
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Successful in 5m54s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Successful in 5m43s
Build project / Publish to itch.io (StandaloneLinux64) (push) Successful in 11s
Build project / Publish to itch.io (StandaloneWindows64) (push) Successful in 9s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (pull_request) Has been cancelled
Build project / Publish to itch.io (StandaloneLinux64) (pull_request) Has been cancelled
Build project / Publish to itch.io (StandaloneWindows64) (pull_request) Has been cancelled
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (pull_request) Has been cancelled
51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class ChangeColor : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
void OnEnable ()
|
|
{
|
|
}
|
|
|
|
public void SetRed(float value)
|
|
{
|
|
OnValueChanged(value, 0);
|
|
}
|
|
|
|
public void SetGreen(float value)
|
|
{
|
|
OnValueChanged(value, 1);
|
|
}
|
|
|
|
public void SetBlue(float value)
|
|
{
|
|
OnValueChanged(value, 2);
|
|
}
|
|
|
|
public void OnValueChanged(float value, int channel)
|
|
{
|
|
Color c = Color.white;
|
|
|
|
if (GetComponent<Renderer>() != null)
|
|
c = GetComponent<Renderer>().material.color;
|
|
else if (GetComponent<Light>() != null)
|
|
c = GetComponent<Light>().color;
|
|
|
|
c[channel] = value;
|
|
|
|
if (GetComponent<Renderer>() != null)
|
|
GetComponent<Renderer>().material.color = c;
|
|
else if (GetComponent<Light>() != null)
|
|
GetComponent<Light>().color = c;
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData data)
|
|
{
|
|
if (GetComponent<Renderer>() != null)
|
|
GetComponent<Renderer>().material.color = new Color(Random.value, Random.value, Random.value, 1.0f);
|
|
else if (GetComponent<Light>() != null)
|
|
GetComponent<Light>().color = new Color(Random.value, Random.value, Random.value, 1.0f);
|
|
}
|
|
}
|