Last active
December 7, 2018 02:50
-
-
Save baobao/3d610a7c3ce259cd427db95f7704be3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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