Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: sarkahn on April 05, 2014, 11:36:45 PM

Title: Collider on a Sprite with no Atlas
Post by: sarkahn 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.
Title: Re: Collider on a Sprite with no Atlas
Post by: ArenMook 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.
Title: Re: Collider on a Sprite with no Atlas
Post by: sarkahn 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.