Shader "Unlit/Test" {
Properties {
_Color ( "Main Color" , Color) = (1,1,1,0.5)
_MainTex ( "Base (RGB)" , 2D) = "white" { }
}
SubShader {
LOD 600
Pass {
Material { Diffuse (0,1,0,1)}
Lighting On
SetTexture [_MainTex] {Combine texture * primary double }
}
}
SubShader {
LOD 500
Pass {
Material {Diffuse (1,1,0,1)}
Lighting On
}
}
SubShader {
LOD 400
Pass {
color(1,0,0,1)
}
}
}
|
using UnityEngine;
using System.Collections;
public class ChangeShaderLOD : MonoBehaviour {
public Shader myShader;
void OnGUI()
{
if (GUI.Button( new Rect(10,20,200,50), "shader 600" ))
{
myShader.maximumLOD = 600;
}
if (GUI.Button( new Rect(215, 20, 200, 50), "shader 500" ))
{
myShader.maximumLOD = 500;
}
if (GUI.Button( new Rect(420, 20, 200, 50), "shader 400" ))
{
myShader.maximumLOD = 400;
}
if (GUI.Button( new Rect(625, 20, 200, 50), "shader 300" ))
{
myShader.maximumLOD = 300;
}
}
}
|
using UnityEngine;
using System.Collections;
public class ChangeShaderLOD : MonoBehaviour {
public Shader myShader;
void OnGUI()
{
if (GUI.Button( new Rect(10,20,200,50), "shader 600" ))
{
myShader.maximumLOD = 600;
}
if (GUI.Button( new Rect(215, 20, 200, 50), "shader 500" ))
{
myShader.maximumLOD = 500;
}
if (GUI.Button( new Rect(420, 20, 200, 50), "shader 400" ))
{
myShader.maximumLOD = 400;
}
if (GUI.Button( new Rect(625, 20, 200, 50), "shader 300" ))
{
myShader.maximumLOD = 300;
}
if (GUI.Button( new Rect(10, 80, 200, 50), "global 600" ))
{
//myShader.maximumLOD = -1;
Shader.globalMaximumLOD = 600;
}
if (GUI.Button( new Rect(215, 80, 200, 50), "global 500" ))
{
//myShader.maximumLOD = -1;
Shader.globalMaximumLOD = 500;
}
if (GUI.Button( new Rect(420, 80 , 200, 50), "global 400" ))
{
//myShader.maximumLOD = -1;
Shader.globalMaximumLOD = 400;
}
if (GUI.Button( new Rect(625, 80, 200, 50), "global 300" ))
{
// myShader.maximumLOD = -1;
Shader.globalMaximumLOD = 300;
}
}
}
|