Warning: Undefined array key "REMOTE_USER" in /kieuns/www/lib/plugins/googleanalytics/action.php on line 61 SpriteCollection 의 매트리얼 동적 교체 [GINS WIKI 긴스 위키] Warning: Undefined array key "stylesheets" in /kieuns/www/inc/StyleUtils.php on line 102

사용자 도구

사이트 도구


사이드바

카테고리

language:unity:tk2dtoolkit
Warning: Undefined array key "fperm" in /kieuns/www/inc/io.php on line 255 Warning: Undefined array key "fperm" in /kieuns/www/inc/io.php on line 255

SpriteCollection 의 매트리얼 동적 교체

tk2dSprite 에서 매트리얼이 변경 되면, 원래의 매트리얼로 바꿔버리는 바람에 오브젝트 인스턴스마다 다른 매트리얼(색상 변경이라든지)을 적용할 수가 없는데…

정식으로 지원 되는 방법은 없고,

tk2dSprite 클래스를 고치는 방법 밖에 없다.

public class tk2dSprite : tk2dBaseSprite {
  //...
  static bool ignoreMaterialChange = true;
  //... 원래 코드 ...
  protected override void UpdateMaterial()
  {
    if( ignoreMaterialChange )
    {
      if( renderer.sharedMaterial == null )
        renderer.material = collectionInst.spriteDefinitions[spriteId].material;
    }
    else
    {
      if( renderer.sharedMaterial != collectionInst.spriteDefinitions[spriteId].material )
        renderer.material = collectionInst.spriteDefinitions[spriteId].material;
    }
  }
}
language/unity/tk2dtoolkit.txt · 마지막으로 수정됨: 2024/04/23 22:44 (바깥 편집)