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 - LaserDinosaur

Pages: [1]
1
Support / What is Linked Sprite Collections used for?
« on: February 02, 2016, 04:52:50 pm »
Stupid question but, what exactly is the purpose of Linked Sprite Collections?
 
When I first read of the feature, I was hoping that I could take my two sprite collections and link them together into one atlas, reducing the amount of draw calls. However, it seems like it's maybe meant for linking to various types of the same image, like player.png and player_2x.png, without having to manually manage the files?

Basically I have my main sprite collection and a second sprite collection just for fonts. I'd like to have the main sprite collection link and pull in the data from the font collection, but I don't know if that is what this feature is meant to do. Is this not what it's for?


2
Support / Null error in tk2dTextGeomGen when calling .Commit() twice
« on: November 25, 2015, 01:59:58 pm »
Hi there

I'm using a tk2dTextMesh and calling Commit() because I need the bounds in the same frame.

However I seem to be getting an error in tk2dTextGeomGen.cs, method 'GetMeshDimensionsForString' in line 39:

'for (int i = 0; i < str.Length && target < data.maxChars; ++i)'


I get an object not defined (null) error in the str property. What's really strange about it is that the cause of it seems really unreliable. What I've found so far:

1) It only happens when Commit() is called twice on the same textmesh in the same frame.
2) Placing two Commit() calls right after each other works fine, it has to be an external class call
3) Not all external calls break it - it seems to happen more when being called through delegates, but not all the time.
4) I setup a blank project and can't seem to replicate the issue, which I realize makes answering this question a lot more difficult.

My only guess is that when Commit calls FlushQueues, perhaps the delegates are firing at the same time (as far as C# is concerned anyway), removing the text mesh in the wrong order and causing an issue. I'm not sure, it's very weird.

Any advice on what might cause this method to fall over? I'm using tk2d 2.5.4 and Unity 5.2.0f3.

3
Support / Enhanced Drag and Drop for 2d toolkit - looking for code feedback.
« on: September 11, 2015, 01:16:34 am »
Hi all

As part of the game I'm working on I needed a drag and drop system that worked closer to how Unity's canvas+event system works. 2d toolkit has a drag and drop system, but it's very simple and only maps a button to your mouse position.

I made up a small enhancement that lets you:
  • Hook into events using interfaces
  • Events include OnPointerEnter, OnPointerExit, OnDrop, OnBeginDrag, OnEndDrag and OnDrag.
  • Failure states that will automatically return your draggable back to its origin position when no dropzone is found.
  • Ability to have draggable snap to the pointer on move (the default in tk2d is to keep the distance relative).
  • Out-of-parent folder support. Usefull for when you are dragging an item which needs to disable the parent folder without affecting the draggable.
  • Public fail state trigger: If you drop an item in your inventory, you will get an "OnEndDragSucceeded" event because the draggable found a dropzone. Once you have the item you can then, for example, do a requirements check against the player attributes and if they don't have high enough stats, you can manually call "TriggerFailedDropEvent". This will call the method that is already implementing IOnEndDragHandler just as if it failed normally.
  • Deadzone support: Give the draggable a deadzone distance and the OnBegin handlers wont fire until its exceeded that distance. Very useful for when your draggables also have button click events where you dont want very small movements triggering the drag event.



Now with that, I was wondering if you guys could take a peek and let me know if you spot anything that could be improved. I'll eventually put a final version in the announcements forum with documentation, but I wanted to make sure it was following best practices first. For example, one possible point of contention is that on line 259 of tk2dUIDragItem_Custom.cs I'm using a .Where statement to filter out raycasts that are hitting themselves. Unikron seems to avoid using statements like this, probably to ensure iPhone support, but my alternatives always wound up being big cludgy messes of code. If anyone has any ways to replace that, do let me know.

Download via dropbox

tk2dUIDragItem_Custom.cs contains all the code to get the drag and drop to work (well, including tk2d of course). It's an extended version of the tk2dUIDragItem script so bits and pieces might look familiar. There are also two example files called "DragWithIcon" and "DropZOne".

If you want to get an idea of how it works, the code section of this video is basically how this extension works.

4
Support / Pixel perfect sprites and camera zoom values
« on: January 20, 2015, 02:13:15 am »
Hi there

I seem to have run into the same problem as this poster back in August.

I have my native resolution matching my preview resolution, I have the pixel-perfect override turned on. After playing about with a dither test on my own I eventually found that it seems to work fine as long as the camera zoom is a whole number. Setting it to 1, 2, 3 etc. means no pixels pulsating and swimming around the screen, but if I set it to 1.2 it goes all screwy. It seems that a half zoom (eg. 1.5) is the worst.

Looking at the preview video of the Pixel Perfect asset that the other poster linked too, it seems that it's zooming in using whole numbers as well - so possibly it has nothing to do with one system being better than the other and entirely to do with using whole numbers when zooming in.

Which leads me (finally) to my point - is there something inherently wrong in using fractional zoom values on a camera? Is there something going on in the background with rounding errors that means cameras (at least for pixel perfect) should always be whole numbers?

Thanks!

5
Support / Prefab sprite overriding tilemap sprite
« on: September 07, 2014, 06:07:09 pm »
I'm using a tilemap with some prefabs as per http://www.unikronsoftware.com/2dtoolkit/docs/latest/tilemap/tutorial.html.

I have a wall that has special properties which I turned it into a prefab so I can attach a script and set the collider as a trigger. The problem is because the sprite is now part of the prefab it overwrites the sprite used in the tilemap. That means if I placed the tile (through the tilemap editor) in a flipped-horizontal, flipped-vertical or rotated position, it's lost when the game starts.

Is there a way to use a prefab in a tilemap but let the tilemap sprite take priority?

Cheers!

6
Support / How do you move the entire tilemap?
« on: August 29, 2014, 03:16:57 pm »
I'm building out my level using a tilemap but realized that I needed to change the boundary size (I'm not sure what the exact term is, but the boundary size you can place tiles in which appears as a white square in the editor). I went into the tilemap properties and changed "Dimensions" to the recommended maximum of 1024, just so I don't have to worry about it again. However the layout size doesn't resize from the middle, it resizes from the top and the right. Now my level is stuck in the bottom left corner.

Is there a way to move the entire tilemap inside the layout boundaries? I tried moving the tilemap layers in the hierarchy but once I started the game it popped back to its old location. I also tried using the 'cut' command, but since I have several layers it quickly becomes messy trying to cut+paste them back into the correct locations (unless there is a way to cut all layers at once).

Is there any way to move the whole tilemap inside the layout boundaries?

7
Hi

I was building out a button using the sliced sprite component. I noticed though that the edges of the button are quite blurry.

I compared my sprite collection to the one in the tk2d UI demos and noticed that it's sprite collection is using Explicit size instead of pixels per meter. If I flip the UI demo over to pixels per meter (matching the pixels per meter of my camera) it has the same blurring effect.

Explicit:
https://dl.dropboxusercontent.com/u/20830426/tk2dExplicit.png

Pixels Per Meter:
https://dl.dropboxusercontent.com/u/20830426/tk2dPixelPer.png


For now I'm just using two separate sprite collections so it's not a huge deal, but I'm curious what the difference between the two are.

Thanks!

8
Support / Updating tk2dUILayout collider at runtime
« on: August 16, 2014, 01:10:42 am »
Hi

I have a popup window that has various amounts of content. The window has a tk2dUILayout component which contains a button called "Fit Layout To Geometry".

Clicking this works fine when in edit mode, but I also want to fire that same event at runtime after I've added content to my window.

Am I missing a very obvious method somewhere or is resizing the colliders at runtime more tricky than that?

Cheers!

9
Support / Tips on passing content to hover window?
« on: August 12, 2014, 04:58:24 am »
Hi all

I am using the OnHoverOverUIItem to initiate a new popup/tooltip window for my game (it's for hovering over items and skills and seeing the information). The popup window is a prefab with a blank content area.

I'm trying to figure out how I can pass content to the popup window. For now I have the popup window hardcoded to look at certain components in the 'tk2dUIItem' parameter that gets passed through. But since I want the popup window to be versatile I don't always know what components to look back to 'tk2dUIItem' for.

Does anyone have any advice on how to pass content to a window when using 'OnHoverOverUIItem'?

Cheers



10
Support / Is it possible to assign a clip to a class property?
« on: May 17, 2014, 09:58:08 pm »
Hi all

I have a script called "Health" which just does some general health tracking on the game object. It also has a method inside it called "Killed()", which fires when the health drops below 1. My plan was to have a class property which takes a Clip from the tk2d animator and then play it. The problem is there doesn't seem to be a property that allows me to just assign a Clip to a script.

I had a look at the Mole tutorial and it appears in there they have a game object which contains a tk2d sprite animator (for the dust animation), then they instantiate that game object whenever they need an animation. I guess this would work, but it seems a little redundant to have a collection of clips in my animation collection (ie. Running, Jumping, Dying), but then have to create a second set of prefabs also called Running, Jumping, Dying, which are instantiated as needed.

Can clips be chosen directly as class properties? If not, is creating a list of matching prefabs and animation clips the best way to go? Is there a cleaner way to do this?

Cheers!

11
Support / Managing UI Z-Index
« on: January 12, 2014, 08:14:31 pm »
Hi all

I'm building out the UI for my game uses a lot of windows and icons. Up until now I've been managing the sort-order by manually assigning the position-z, but as the UI gets more complex it's becoming hard to manage (especially since some of the position-z values cannot be known in advance).

In Unity there are some helper methods like "GUI.FocusWindow" and "GUI.BringWindowToFront" - Are there anything equivalent of this in tk2d?

Cheers!

12
Support / A few questions about mixing Unity2D with tk2d.
« on: November 23, 2013, 05:29:00 am »
Hi there!

I have a few questions about 2D toolkit before buying a copy if you don't mind :)

1) If I use a tk2D sprite, does that limit anything you can do in the Unity editor? For example, animations, sorting/managing layers etc.

2) If I use the built in Unity2D sprite, can I still use the sprites from a sprite collection?

3) Does a tk2D sprite work fine with other 2D components of Unity2D like RigidBody2D and/or Box Collider 2D?

For the most part I'd be fine using all of the tools tk2D provide over Unity2D, I just want to make sure I'm not going to paint myself into a corner where I find out 3 months from now that Unity's collision detection system only work with their sprites :)

Thanks!

Pages: [1]