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

Pages: [1]
1
Support / Re: Event Bubbling Functionality in tk2d using UIItem Parent
« on: October 30, 2013, 01:19:44 pm »
I'm still curious of your thought from my previous question, but I've at least found one solution that seems to work well so far. Raycast :)

2
Support / Event Bubbling Functionality in tk2d using UIItem Parent
« on: October 30, 2013, 12:38:24 pm »
In AS3 and JS (not UnityScript) I'm accustom to the concept of Event Bubbling. In essence, if I have a container with say 20 buttons, it is better to have a listener on the container as opposed to each button (1 listener vs. 20). The container is able to determine which child button was clicked via event bubbling.

I'm curious if something similar can be achieved in tk2d? I have a container GameObject with a tk2dUIItem attached. Within this container I have 20 buttons who currently each have tk2dUIItem components. I have the container capturing events via the Register Events From Children checkbox. My question is, is it possible for a container object (parent) to determine the child that was clicked within? If so, what part of the tk2d API do I need to be using (or look into more). Is there another way to achieve this?

3
1) Yes, both work as mentioned but I'd like only one to gain focus at a given time.
2) I meant just the actual scroll functionality, so I could still listen for the touch events from the backgroundUIItem

It looks as though there is nothing built in currently that would handle this (this is what I was trying to find out). I'm also trying to limit/prevent modifications to the source tk2dUIScrollableArea file if possible (prevent updating issues). I have a few ideas for a next step but I would like to know if an idea sticks out as a bad solution based on your knowledge of tk2dToolkit. I'm obviously open to any suggestions you have. Here are my current ideas:

A) Modify tk2dUIScrollableArea source by increasing the SWIPE_SCROLLING_FIRST_SCROLL_THRESHOLD value and dispatching a delegate containing the touch data until just before the SWIPE_SCROLLING_FIRST_SCROLL_THRESHOLD value is reached. From here I could determine if the swipe direction is more vertical vs horizontal or vice versa. From here I could enable/disable the proper scroll areas. My concern here is that there may be an easier way and I'd like to stay away from modifying the source unless there is no other way.

B) Disable both my horizontal and vertical scroll areas and place a tk2dUIItem in front of both so touches can be tracked on it temporarily. From this temporary tracking I can determine whether the finger movement traveled more vertical vs. horizontal or vice versa. From here I could enable the proper scroll area and disable the overlaying tk2dUIItem. My concern here is that there may be an easier way and that I may have trouble translating the tk2dUIItem touch properly to the scroll area that I enable.

If you have no recommendation I guess I'll begin modifying the source. Thanks in advance for any insight.

4
I have a vertical tk2dUIScrollableArea (page) inside a horizontal tk2dUIScrollableArea (holding numerous pages) and it works as you would expect given the API. Currently, if I try to scroll my vertical tk2dUIScrollableArea instance but also move my finger horizontally both tk2dUIScrollableArea instances scroll (vertical and horizontal). I'd like to only scroll one of them but I don't know the best way to achieve this with the current API.  I was wondering a few things:

1) Is it possible to delay the initial scrolling of an tk2dUIScrollableArea instance to determine if the backgroundUIItem.Touch.position has occurred more vertical than horizontal and vice versa? This could be handy for my use case mentioned, but it could also be helpful in determining a user's scroll direction intent. By determining the user's intent a developer may be able trigger something in response.

2) Is it possible to disable just the scroll functionality and re-enable it at a later time?

5
Support / Re: Font Size Issue in tk2dTextMesh
« on: October 26, 2013, 02:20:24 pm »
I do in fact have a tk2dCamera in the scene, but I also have a normal camera. Is the tk2dtoolkit code just checking for the first camera in the scene graph? If so I'd imagine that is an easy update if others ever run into a similar issue.

Quote
If it can't detect the camera / resolution it will simply create at 20 pixels per meter.

Where exactly can I change this '20px per meter' setting?

Love the tk2dToolkit support btw

6
Support / Font Size Issue in tk2dTextMesh
« on: October 25, 2013, 01:31:27 pm »
I'm using BMFont and followed both the Preparing a font and Creating and using a text mesh tutorials but I feel I may have missed something. Basically, I'm able to get my font to show up, this issue is the size. When first setup my tk2dTextMesh instance's scale is 1 but the font showing up in the Scene View and Game View is massive compared to what it should be for proper display. I can set the scale of my tk2dTextMesh instance to .05 (for x,y,z) and then it displays as expected.

My question is, is it bad practice to scale the tk2dTextMesh instance? Did I miss a setting on BMFont export? How do I properly control the font size from BMFont export so it maps well to the size(s) I want the font to be within Unity? Thanks in advance for any thoughts pointing me in the right direction.

7
Support / Re: Paged Scrolling with a ScrollableArea
« on: October 07, 2013, 02:28:43 pm »
Don’t have the source in front of me, but are you suggesting to edit tk2dUIScrollableArea source to provide a publically accessible way to listen for tk2dUIScrollableArea.BackgroundOverUpdate? From what I recall there was no built in way to listen for BackgroundOverUpdate.

@reefG I've currently implemented this paging behavior listening for the backgroundUIItem.OnUpUIItem dispatch. It works but is inconsistent in the sense that the event may fire but the momentum of the swipe gesture continues the native scrolling behavior vs my implemented snap to position behavior.

8
That was the trick, thanks! I'm nesting prefabs and my root button prefab had that checked where my higher parent prefab which utilized instances of it did not. Not quite sure how that happened, but I think I just came to understand the "nested prefabs" issue I've heard people pissed about. I'm newish to Unity and am bummed that prefabs don't work as you'd expect. Coming from Flash this is a bummer from a reusable asset and workflow standpoint. Prefab != MovieClip :(

9
I searched the forums and found this: http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1564.msg7658.html#msg7658. But when I went to reply it stated it was over 120 days and to consider starting a new topic so here it is.

I have a tk2dUIScrollableArea which has UI BasicButton instances in it. When I touch over a button and try to swipe the content, it doesn't scroll as expected. Instead the button captures the touch. This is repeatable by simply dragging out a ScrollableArea_Horizontal and offsetting a few UI BasicButton instances in the ScrollableArea's content GameObject. The buttons are considered interacted with when the intention is to swipe (and thus scroll the view).

I've ran the 5 - ScrollableArea demo, looked at the controller script, but can't figure out how it works in the demo. The Add More and Next buttons work as I want, if swiping begins after first interaction it transitions to scroll as expected. I feel like this is a simple fix but I've been banging my head against the wall on this one. How is this achieved?

10
Support / UI Grid Creation at Runtime (tk2dUI AddLayout at runtime)
« on: September 30, 2013, 03:47:49 pm »
I'm trying to create a grid using BasicButton with a tk2dUILayout attached. I also have a containerUI GameObject in my scene that has a tk2dUILayoutContainerSizer script attached. When iterating through a for loop I can instantiate my BasicButton prefabs as expected and add them to the tk2dUILayoutContainerSizer instance and all works as expected (vertical only):

Code: [Select]
//layout  add
myLayout = Instantiate(prefabItem) as tk2dUILayout;
foreach (tk2dUILayoutItem item in myLayout.layoutItems)
layoutSizer.AddLayout(myLayout, item);

What I'd like to do is create a ContainerRow prefab that has its own tk2dUILayoutContainerSizer (horizontal) and instantiate a few of these and add each row to my main containerUI GameObject (which has its own tk2dUILayoutContainerSizer) that is set to vertical. This would create a grid.

I've tried this:

Code: [Select]
for(int i = 0; i < 5; i++)
{
myRowLayout = Instantiate(prefabRowToInstantiate) as GameObject;
layoutRowSizer = myRowLayout.GetComponent<tk2dUILayoutContainerSizer>() as tk2dUILayoutContainerSizer;

for(int j = 0; j < 4; j++)
{
//layout  add
myLayout = Instantiate(prefabItem) as tk2dUILayout;
foreach (tk2dUILayoutItem item in myLayout.layoutItems)
layoutRowSizer.AddLayout(myLayout, item);

ctr++;
}

//TODO add each row to my main layoutSizer
}

But where my TODO comment is I haven't been able to successfully add my instantiated Row to the main layoutSizer. How do I accomplish this?

Or for that matter how can you dynamically insert nested tk2dUI layout prefabs at runtime and still have the layout container properly arrange them?

11
Support / TK2D Button Reloading Scenes while Reusing GameObjects
« on: June 27, 2012, 06:25:59 am »
I've got a TK2D button working in a mobile testing environment. The button triggers the reloading of 1 of 2 scenes that I've included in the build (Build Settings > Scenes In Build). What I'm trying to achieve is to (in the most efficient way as my target is mobile) load new scenes/levels but reuse ALL the objects in the previous scene only to position them differently (and not display some of them). I'm aware of "DontDestroyOnLoad" for objects but how does the next scene know to use these objects that were marked "DontDestroyOnLoad"?

I'm thinking it may be better to instantiate all my objects in pools and simply reposition them based on an external file when a new scene/level is "loaded"/selected. I just don't want to go that route if the same thing can be achieved using the built in Application.LoadLevel functionality. Any thoughts on the best way to achieve this?

12
Support / Re: Collider
« on: June 27, 2012, 06:06:46 am »
So what is the best practice for 2D physics mobile games when using tk2d? Is it to use two cameras in the scene: 1 tk2d camera for rendering UI and then 1 ortho camera set similarly to the tk2d_demo - Polygon Colliders demo - to render a physics scene?

Are there any "penalties" or performance issues I should be aware of if I simply want to use the tk2d camera for both my UI and for rendering my physics scenes?

If done this way what is the preferred setting for Edit > Project Settings > Physics > Gravity (say for a 800x480 target resolution)?

Thanks to anyone who can drop some tk2D knowledge, I just purchased it last night :)

Pages: [1]