Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active December 7, 2018 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/3d610a7c3ce259cd427db95f7704be3a to your computer and use it in GitHub Desktop.
Save baobao/3d610a7c3ce259cd427db95f7704be3a to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// カメラのZ値によってシェーダを切り替える
/// </summary>
public class ShaderLODTest : MonoBehaviour
{
[SerializeField]
private Renderer r;
[SerializeField]
private Transform _cameraTransform;
void Update()
{
// シェーダにLOD値を代入
r.sharedMaterial.shader.maximumLOD = (int) Mathf.Abs(_cameraTransform.localPosition.z);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment