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
// シェーダのマクロショートコード | |
Shader "MacroTest" | |
{ | |
Properties | |
{ | |
} | |
SubShader | |
{ | |
CGINCLUDE | |
#include "UnityCG.cginc" | |
#ifdef SHIBUYA24 | |
#define TEST_MACRO(abc) abc.x = 0; | |
#else | |
#define TEST_MACRO(abc) abc.z = 0; | |
#endif | |
fixed4 frag (v2f_img i) : SV_Target | |
{ | |
fixed4 col = fixed4(1,1,1,1); | |
// マクロ適用 | |
TEST_MACRO(col); | |
return col; | |
} | |
ENDCG | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert_img | |
#pragma fragment frag | |
// 下記のように書いてしまうとSHIBUYA24が存在しないShaderがコンパイルされない | |
// #pragma multi_compile SHIBUYA24 | |
#pragma multi_compile _ SHIBUYA24 | |
ENDCG | |
} | |
} | |
} |
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 UnityEngine; | |
public class MacroTest : MonoBehaviour | |
{ | |
public Material mat; | |
bool m_enableShibuya24; | |
void OnGUI () | |
{ | |
if (GUILayout.Button("Change")) | |
{ | |
if(m_enableShibuya24) | |
mat.DisableKeyword("SHIBUYA24"); | |
else | |
mat.EnableKeyword("SHIBUYA24"); | |
m_enableShibuya24 = !m_enableShibuya24; | |
} | |
GUILayout.Label("m_enableMacro : " + m_enableShibuya24); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment