Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - David Kalina

Pages: [1]
1
Support / Sprite Collection Mystery Junk
« on: June 23, 2015, 10:58:46 pm »
Hello Unikron,

Having a mysterious problem.

Our build machine -- which grabs a pristine version of our game from SVN and builds target players from scratch -- is producing builds where a specific (very important) Sprite Collection is rendering with a bunch of mystery junk visible.  This is true in both in our iOS and Steam builds.  If I pull a fresh check-out from SVN and run the game in the editor, the problem is there too.

I don't know how better to describe this, so please have a look at the attached image.

As you can see:

- The image in the generated SC atlas PNG is pristine.
- It does not appear to be indexing out of bounds, it's just drawing garbage of no origin along with the correct artwork.

I can "fix" this by rebuilding the SpriteCollection.  It has NO effect on the SpriteCollection PNG data or the material.  It DOES, however, touch one line in the SpriteCollectionData prefab (also shown in the attached image).

Umm, so what the heck IS a buildKey anyway, and why would it change, and why would it have anything to do with this problem?

Now, the one bit of potentially useful information I have for you is that this particular SpriteCollection recently went through a change.  It was previously a PNG Atlas, and I changed it to a Unity Atlas (for the half-second of load-time increase that might grant us in our iOS build).  The TextureImporter associated with the Texture2D is setup properly.  There is no compression enabled or anything of the sort.

I have briefly noticed this in other, similar SCs -- rebuilding generally has "made the problem go away."  We're < 2 weeks from ship and I don't like mystery problems this close to the end.  Any ideas?  Any way to make this NOT happen again?

Thanks in advance for the support!
David


2
Support / Fastest way to load PNG assets?
« on: May 27, 2015, 04:55:25 am »
Hello,

Our load times on older mobile devices (e.g. iPad2) are dismal.  We load quite a bit of 2D art, all of which is stored in PNG Atlas style sprite collections.

Anyway, after doing some research on the interwebs, I discovered that the standard 2DToolkit method for loading PNGs (calling LoadImage on a TextAsset's bytes followed by Apply) is quite a bit slower than loading the asset using Resources.Load.

I hacked together a test -- put one of my 1024x2048 .png assets into Resources and loaded it both ways on an iPad 2 -- and lo and behold, the LoadImage / Apply method timed at about ~0.75 seconds vs ~0.13 seconds for using Resources.Load.

I'm curious if there's some reason I shouldn't just be spitting built sprite collection .PNGs into /Resources with unique names, saving those names in the tk2dSpriteCollectionData, and then loading them via Resources.Load instead. 

Additionally, this isn't accounting for the benefit of not having to load those PNG TextAssets just to create the actual Texture2Ds, which Unity automagically does if the Sprite Collection is referenced in a level anywhere.  It certainly seems like it warrants a further experiment on my end, unless there is some clear reason this won't work that I am missing. 

So is there some clear reason this won't work that I'm missing?  :)

Thanks in advance!
David

3
Support / Shader can't be changed on PNG Atlas Sprite
« on: March 03, 2014, 06:38:33 pm »
Repro case:

1.  Build a sprite collection with Atlas Format = PNG.
2.  Add sprite to level.
3.  Change sprite's shader to anything else.
4.  Run the game.  Sprite shader will reset to its default, which is undesired behavior.

Workaround:  change sprite collection to Unity Texture format, rebuild, change atlas material, change sprite collection back to PNG atlas.

4
Support / Sorting Order automatically set on activation?
« on: February 11, 2014, 01:49:07 am »
Upgraded to 4.3 and noticed some sort order issues.

Apparently if an object doesn't have an Order in Layer specified, it will automatically have one assigned.  For example, I have a loading screen background sprite which suddenly sees its Order in Layer go from 0 to 1001 once the parent GameObject is activated in-game, and I have no idea why. 

I tried placing a breakpoint inside the setter for SortingOrder but it doesn't get hit.

Is this some weird Unity thing?  It seems like if I set the order value myself, it won't be overridden at runtime.

5
Support / PNG Atlas vs Not-PNG Atlas?
« on: January 31, 2014, 12:09:33 am »
What exactly is the difference between a "PNG Atlas" and the format of texture atlases in the past?

We just noticed that our build size is ballooning like mad (oh hi 700MB for 1/6 of the final game), and it appears that texture atlases are entirely uncompressed....?  They still show up as PNGs (atlas0.png) so I'm a bit confused as to why these would be uncompressed...  like, isn't the point of a PNG that it is a lossless compression format? 

It sounds like "PNG Atlases" are the solution here, I'm just curious what the actual feature is since there doesn't seem to be any detail on it in the docs.

Thanks,
David

6
Support / Add a sprite picker to another component in the inspector?
« on: November 08, 2013, 11:58:22 pm »
I want to write a class that refers to a tk2dSprite by collection and name, and ideally I'd like it to show up in the editor with the same picker utility that exists for the tk2dSprite class. 

I could just point my class at instances of tk2dSprite GameObjects but I'm looking for the more fancy editor solution.  I also don't really want to create a ton of GameObjects in the hierarchy specifically so I can draw lines to them -- I'd rather my data structure show the thing it refers to immediately in the inspector.

Is there a fast and easy way to do this?  I started trying to pick apart the tk2dSpriteEditor code but it's late Friday afternoon and I'm not super engaged at the moment :)

Thanks, have a great weekend!

7
Support / positioning a mouse cursor
« on: October 28, 2013, 10:49:35 pm »
I'm trying to position my own mouse cursor on the screen.  For some reason, the results are not what I expect when the preview resolution != native resolution.

I am using a tk2dUICamera with a native resolution of 960X640, orthographic projection, 1 pixel per 'meter'.  The Unity preview resolution is 1280x800.

In the example image (attached), you can see how I can manually set the position of the sprite to x=0 and it is drawn well inside the camera's left boundary.  I would expect that an object positioned exactly at x=0 would be exactly on the left border of the camera.

The assumption I've been operating under is that I can position things "on screen" by setting their world position to a screen pixel resolution.  Not sure where I'm going wrong.  I am guessing that I am failing to understand something about how native resolution works.  When preview == native, everything is exactly where I expect it to be.

Thanks in advance!
David

8
Support / Renaming atlas0.png
« on: October 22, 2013, 01:08:26 am »
It would be helpful for us if every generated texture atlas didn't have the exact same filename (so, for example, we could more easily identify loaded textures in a crowded scene and clean up dependencies). 

So, in tk2dSpriteCollectionBuilder.cs, I'm changing the line that sets the name to this:

Code: [Select]
string texturePath = gen.atlasTextures[atlasIndex]?AssetDatabase.GetAssetPath(gen.atlasTextures[atlasIndex]):(dataDirName + gen.name + "_atlas" + atlasIndex + ".png");
Which turns an atlas0.png into my_collection_atlas0.png (where my_collection is the full name of the sprite collection)

I basically just wanted to sanity check and make sure this was an OK thing to do and wouldn't cause unexpected problems!  Seems safe but I don't mess with the tk2d internals any more than I have to.

9
Support / questions about 'use tk2dcamera'
« on: July 18, 2013, 06:57:10 pm »
OK, so we've decided that it'll be easiest for our (now) 2D game to have sprites instantiated at pixel size.

This way, a 256x128 texture added to a sprite collection will be instantiated at world unit size 256x128.

I've checked "use tk2dcamera" in order to accomplish this... even though I am not using a tk2dcamera to render my game world.  Are there any side effects of that checkbox that I need to be aware of?

Also, is there a single call I can make into a tk2dsprite to get its size in world coordinates (accounting for hierarchy scale, tk2dsprite scale, and source sprite size)?  The aforementioned sprite will have a transform.scale=1,1,1 and a tk2dsprite.scale=1,1,1... so how do I know it's actually 256x128?

Thanks!
David

10
I set up my in-game UI using 2D Toolkit UI.  These are 2D icons and text that are positioned using anchors relative to a tk2dCamera, all in the corners of my screen.

My intent is to use a single sprite sheet that is authored at retina pixel density.  I want to layout / size my UI elements once and have the appearance of the icons and text be the same physical size across all devices and platforms.  I'm only using 2DToolkit for UI in this particular project, and the UI is very simple, so I'm not interested in authoring resolution-specific variants for every piece of 2D art.  I want to use a single sprite sheet for all targets.

In other words, an icon that occupies 96x96 pixels on an iPhone 4 screen (or iPad Retina screen) would be drawn in 48x48 pixel space on an iPhone 3GS, or an iPad 2, or a PC. 

I'm still quite a bit confused about "native resolution" and "overrides" and so forth, so would greatly appreciate a straightforward explanation of how I can do what I'm trying to do.

Thanks!


11
Support / help setting up UI on top of 3D world
« on: June 11, 2013, 03:50:25 pm »
Hey there -- I'm trying to figure out the best way to approach UI implementation using 2DToolkitUI and could use some guidance.

Let's start by saying that I'm building a 3D game (the standard camera is perspective) that targets mobile + PC -- variable screen size, aspect ratio, and pixel density all need to be accounted for, though for now I'll be happy to just use hi-res/hi-DPI assets for all targets. 

I am looking to implement my always-on-screen UI using 2DToolkitUI.  I figure the best way to do this is have a separate, ortho camera that only shows UI elements in screen space, and that it draws after the game camera draws the 3D world.

I dropped a tk2dcamera into my scene, set its Clear Flags to "don't clear", and am using the Culling Mask to draw only things in a new layer called "2DToolkitUI".  Set the camera depth to 1 so that it draws after my standard perspective camera.

I then drop a BasicButton prefab into the scene, put it in my "2DToolkitUI" layer.  Takes me some time to figure out where to position the button but I finally figure out how to get it on screen.  This is where I start to get confused.

1.  The button doesn't respond to clicks in game.  It renders on top of the 3D world as intended but clicks are not received.  Note that if I do this same work in a new, empty project, clicks are received just fine, so it must have something to do with my project's settings.  Any idea where to look?

2.  What's the best way to resize UI elements when placing them in the editor?  I can resize the button graphic's "dimensions" in "pixel units" but these numbers don't seem to have any correlation with what I see on screen.  I currently set this field 128x128 with a transform.scale on the BasicButton of 1x1 ... and the button is completely invisible.  If I set the transform.scale up to 128x128, the button now appears to occupy 48x48 pixels in my 1024x768 window.  Huh?  I feel like I'm just randomly trying things here, what's the correct method?

3.  I'm going to start with our HUD -- on-screen indicators for score, resource count, and a menu button.  All of these elements want to be laid out relative to the corners of the screen.  Is there a way to properly author this in-editor?  Or do I need to perform the layout tasks in code? 

Thanks in advance for your time and guidance!

Cheers,
David

Pages: [1]