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.


Messages - David Kalina

Pages: 1 [2]
16
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

17
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!

18
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

19
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.

20
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

21
OK, I played with native resolution + overrides yesterday and I don't think it's quite what I'm looking for, or I still don't have it setup properly.

Let's just say I'm talking about a simple menu button in the corner of the screen.  I author for native resolution of the iPhone 4 and set my overrides to Match All / Pixel Perfect Fit / Center.

Yes, the scaling is consistent for retina vs non-retina displays.  So my iPhone 5 and iPhone 3GS look the same (the button occupies the same amount of physical, real-world space). 

But the iPad and iPad Retina the button is larger by a factor of (whatever the screen size difference is).  A button that is laid out to look appropriately button-sized on the iPhone is now relatively gigantic on the iPad.  On a PC screen, it's enormous.

I want the buttons and text to occupy the same "meat space" across all platforms.  They should appear to be *the same size* in physical space.  Any tips?

Thanks much!
David

22
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!


23
Support / Re: help setting up UI on top of 3D world
« on: June 11, 2013, 05:02:50 pm »
1.  Got it working by re-enabling Raycast Hit Triggers and then had to fix up properties on tk2dUIManager.  Thanks!

2.  I'll go over the documentation carefully, but I'm not sure how I wouldn't mess with scales at all, if, for example, I was creating menu buttons using sliced sprites and text.  My intent (hope?) is to layout my main menu entirely in the editor, similarly to how you lay out your menu in the UI Demo. 

3.  I'm not sure what you're suggesting.  I should use the script you include?  How do I layout UI elements relative to screen size today?  Just looking for best practices.

Thanks,
David


24
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 [2]