Q.
직접 작성한 쉐이더를 캐릭터에 적용했습니다.
C# 스크립트로 쉐이더의 프로퍼티 값을 게임 중에 조절하는 함수가 있나요?
I applied a shader I wrote myself to my character.
Is there a function to adjust the shader’s properties during the game using a C# script?
A.
메시의 재질들을 제어하는 스크립트 함수들은 다음의 메뉴얼에서 볼 수 있습니다.
https://rainyrizzle.github.io/kr/Script/SC_Mesh.html
예를 들어서, “apPortrait portrait”라는 객체의 “_CustomColor”라는 색상 프로퍼티의 값을 “붉은색”으로 변경하고 싶다면 다음과 같이 작성하시면 됩니다.
portrait.SetMeshCustomColorAll(Color.red, “_CustomColor”);
만약 특정 메시의 재질만 바꾸고 싶다면, 아래와 같이 작성하면 됩니다.
portrait.SetMeshCustomColor(portrait.GetOptTransform(“메시 이름”), Color.red, “_CustomColor”);
또는 특정 이미지를 가진 모든 메시들을 대상으로 일괄적으로 변경하고자 한다면 아래와 같이 작성하면 됩니다.
portrait.SetMeshCustomColorAll(“이미지 이름”, Color.red, “_CustomColor”);
주의할 점은, 재질의 프로퍼티의 값을 스크립트로 변경하면 드로우콜이 증가할 수 있습니다.
이와 관련된 설명은 다음의 메뉴얼에서 볼 수 있습니다.
https://rainyrizzle.github.io/kr/AdvancedManual/AD_ReduceDrawCalls.html
Script functions that control the materials of the mesh can be found in the following manual.
https://rainyrizzle.github.io/en/Script/SC_Mesh.html
For example, if you want to change the value of the color property “_CustomColor” of the object “apPortrait portrait” to “red”, you can write it as follows:
portrait.SetMeshCustomColorAll(Color.red, “_CustomColor”);
If you only want to change the material of a specific mesh, you can write it as follows.
portrait.SetMeshCustomColor(portrait.GetOptTransform(“Mesh Name”), Color.red, “_CustomColor”);
Or, if you want to change all meshes with a specific image at once, you can write it as follows.
portrait.SetMeshCustomColorAll(“Image Name”, Color.red, “_CustomColor”);
Note that changing the value of a material property via script may increase draw calls.
You can find more information about this in the following manual:
https://rainyrizzle.github.io/en/AdvancedManual/AD_ReduceDrawCalls.html