fnwinter.github.io blog

Unity Bug

Unity Bug

  • 생각보다 유니티 버그가 많다. 특히 버전이 바뀌면 당연히 있던 버그가 수정이 되는데, 문제는 없던 버그도 생겨난다. 어쩔 때는 너무 기본적인 기능이라서 QA나, DevOps가 있나, Regression Test를 진행하나 의구심이 들 때도 있다.

  • 아래의 코드는 GLTFast 라이브러리를 import 하고 GLTF 파일 하나를 로드하는 코드이다.
      gltf = gameObject.AddComponent<GLTFast.GltfAsset>();
      gltf.Url = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF/Duck.gltf";
    
  • 이 GLTF 파일의 Bounding box의 center를 구하는 코드를 추가해 보자.
      var child = this.transform.GetChild(0).gameObject;
      var c_child = child?.transform.GetChild(0).gameObject;
    
      var _components = child.GetComponentsInChildren<Renderer>();
      Bounds _bound = new Bounds();
      foreach(var _component in _components)
      {
          _bound.Encapsulate(_component.bounds);
      }
    
      if (gizmo == null)
      {
          gizmo = GameObject.CreatePrimitive(PrimitiveType.Sphere);
          gizmo.transform.position = _bound.center;
          gizmo.transform.parent = child.transform;
      }
    
  • 어떤 버전에서는 이게 안된다.

  • Unity Issue Tracker Link link
comments powered by Disqus