「Unity/Shader/skybox/徐々に変更/色」の版間の差分
提供: 初心者エンジニアの簡易メモ
| 行39: | 行39: | ||
} | } | ||
</pre> | </pre> | ||
| + | |||
| + | 参考:https://adarapata.hatenablog.com/entry/2015/08/04/024143 | ||
2022年12月7日 (水) 13:56時点における版
色が暗くなったり、明るくなったりするサンプル
Shaderを作成し、Skybox/Procedualを設定
using UnityEngine;
public class SkyboxColorScene : MonoBehaviour
{
[SerializeField] Material skyboxMaterial;
[SerializeField] bool orderFlag = true;
[SerializeField] Color color;
void Start()
{
RenderSettings.skybox = skyboxMaterial;
// Skybox/Procedualを使う
skyboxMaterial.SetColor("_SkyTint", Color.white);
}
void Update()
{
color = skyboxMaterial.GetColor("_SkyTint");
Debug.Log("color.r=" + color.r);
if (color.r > 1)
{
orderFlag = true;
}
else if (color.r < 0)
{
orderFlag = false;
}
if (orderFlag)
{
color -= new Color(0.01f, 0.01f, 0.01f);
}
else
{
color += new Color(0.01f, 0.01f, 0.01f);
}
skyboxMaterial.SetColor("_SkyTint", color);
}
}
