일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- C#
- Unity
- 유니티
- 확장메서드
- ar
- 소규모프로젝트
- 깃허브
- github
- Quaternion
- ARProgect
- 1인개발
- 병맛게임
- 게임
- ExtensionMethod
- raycast
- 게임개발
- 리듬게임에디터
- 리듬게임
- AR게임
- callbyvalue
- callbyreference
- 레이캐스트
- 짐벌락
- 인터페이스
- Euler
- 로케트
- 게임제작
- AR세팅
- AR Foundation
- 델리게이트
- Today
- Total
Ssssong += Dev
[유니티] Shader.PropertyToID 본문
https://chulin28ho.tistory.com/622
Shader.PropertyToID
docs.unity3d.com/kr/530/ScriptReference/Shader.PropertyToID.html Unity - 스크립팅 API: Shader.PropertyToID 프로퍼티 식별자들을 사용하것은 모든 메터리얼 프로퍼티 함수에 문자열을 전달하는 것보다 더 효율적입니
chulin28ho.tistory.com
유니티 머테리얼에서 shader property에 접근하는 방법으로는
Material.SetColor("_Color", color) 이런 식으로 접근할 수 있다.
그러나 SetColor를 자주 호출하거나 MaterialPropertyBlock(같은 머테리얼 쓴 값이 약간씩 다른 여러 오브젝트 사용 시 쓰는 기능)을 사용 시 프로퍼티 식별자를 얻는 게 더 좋다.
이유는? Material.SetColor("_Color", color) 할 때
내부적으로는 이미 Material.SetColor(Shader.PropertyToID("_Color"), color); 이렇게 변환되어서 동작하고 있기 때문에
이 변환 과정을 생략하고 직접 사용하는 것이다.
Shader.PropertyToID(name) - Why is it more efficient and best practise to store multiple Id's?
I am working on optimising a game I'm working on and noticed in the docs that using shader property Id's rather than their names would be more...
forum.unity.com