Author Topic: Collider on a Sprite with no Atlas  (Read 3380 times)

sarkahn

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 3
    • View Profile
Collider on a Sprite with no Atlas
« on: April 05, 2014, 11:36:45 PM »
Just a minor feature request I guess. I use sprites with no atlas assigned for the purpose of laying out child objects, since I want to use all the sizing functionality of the container object but have no visuals on it. The container lays out it's children and resizes itself to fit.

It works perfectly fine except when I added a collider to my container object I got a null reference error from line 599 of UISprite:
  1. Vector4 br = border * atlas.pixelSize;

A simple change to:
  1. Vector4 br = atlas ? border * atlas.pixelSize : Vector4.zero;

Fixes it. Not sure if this is a common use case but I figured I would request you add this to NGUI so I don't need to keep changing it when I update.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Collider on a Sprite with no Atlas
« Reply #1 on: April 06, 2014, 02:54:19 AM »
Why don't you use a widget? It's exactly like that -- an invisible rectangle. ALT+SHIFT+W is the shortcut.

sarkahn

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 3
    • View Profile
Re: Collider on a Sprite with no Atlas
« Reply #2 on: April 06, 2014, 08:05:43 AM »
Doh, I had considered that was an existing concept but for some reason I overlooked UIWidget and only saw UIRect. Works perfectly, thanks.