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

Pages: [1] 2
1
Support / Detecting when mouse is over any UI object
« on: February 19, 2014, 12:54:11 am »
I'm trying to figure out the best way to detect when the mouse is over any UI object. My current thinking is to create a layer for UI bounding boxes and test if the mouse if a linecast at the mouse's position is colliding with anything that has that layer, but before I look into that I wanted to see if there's a built in way to test for this.

2
Support / Re: tk2dUIItem .OnHoverOut activated during click
« on: January 26, 2014, 05:30:06 pm »
That's understandable, you have quite a few users at this point!

In case anyone needs this in the future, I think I got it changed correctly in the tk2dUIManager script under the "checkForHovers" section. I changed this...

Code: [Select]
if (!isPrimaryTouchFound && !isSecondaryTouchFound && hitUIItem == null && !Input.GetMouseButton(0)) //if raycast for a button has not yet been done
{
   hitUIItem = RaycastForUIItem( Input.mousePosition );
}
   else if (Input.GetMouseButton(0)) //if mouse button is down clear it
{
   hitUIItem = null;
}

...to this...

Code: [Select]
if (!isPrimaryTouchFound && !isSecondaryTouchFound && hitUIItem == null && !Input.GetMouseButton(0)) //if raycast for a button has not yet been done
{
   hitUIItem = RaycastForUIItem( Input.mousePosition );
}

If this isn't right please feel free to correct me. Everything seems to be working though :)

3
Support / tk2dUIItem .OnHoverOut activated during click
« on: January 25, 2014, 05:30:38 pm »
I've noticed that .OnHoverOut is activated when a button is clicked. This is causing problems since I need .OnClick to be called before .OnHoverOut. I don't understand why it's doing this since the button is still being hovered over when someone clicks it; shouldn't .OnHoverOut only be called when someone actually moves their mouse out of the button's collider?

4
Support / Position menu at world position
« on: January 20, 2014, 03:15:35 am »
I'm using two cameras, the first to render the world and a second to render the UI elements. I have a menu that is rendered by the second camera that I want to lock to a specific world position/object. The idea is that you can select an object to highlight it and then move the first camera around so you scroll along the world but still have the menu stay at the position of the object.

I thought using "secondCamera.WorldToScreenPoint (worldPosition)" would do the trick, but it gives me a value that's wildly off. Maybe something else?

5
Support / Re: Calculating correct dimension for Sliced Sprite
« on: January 16, 2014, 04:54:14 pm »
Wonderful, thank you. I've got the main bit working, but it looks like I'm also going to need to calculate the size of the sliced sprite minus the bottom border (or the world position of the top of the bottom border; it's to ensure the symbol on the left is within the sliced sprite). I know there's .borderBottom, but I'm not sure what that value actually means. It only changes when I alter the size of the bottom border, not when the size of the sliced sprite itself is changed.

6
Support / Calculating correct dimension for Sliced Sprite
« on: January 16, 2014, 04:44:56 am »
I'm using a sliced sprite as the background image for a menu that has content of varying sizes at any given time. Because of this I need to resize the sliced sprite so it is the same height as the content using dimensions. Here's a picture of the menu: http://imgur.com/Ol6fYDB The see through trapezoid is the sliced sprite, and it would need to be the same height as everything from the top of the large "Test" with the symbols next to it to the very bottom "Test Test Test".

I'm at a loss as to how this would be done. I'm using Renderer.bounds to position everything, but the size it gives me for the content (the combined bounds for everything from the big "Test" to the bottom "Test Test Test") is so far off of what the pixel dimensions are for the sliced sprite. For example, the y size of the content in the picture linked is 0.2991996, but the y pixel size of the sliced sprite is 280.

I have my UI camera set up as Orthographic with a size of 1, and the sprite collection size is set at Explicit with the default ortho size of 1 and target height of 640. Perhaps using a different combination would make this easier?

7
Support / Re: Problem caching sprite IDs
« on: December 29, 2013, 03:59:21 pm »
Just to be sure there's closer with this "issue," I wanted to update that this ended up being a problem with the user :D I'll spare you the details haha.

Thanks for your time!

8
Support / Re: Problem caching sprite IDs
« on: December 17, 2013, 05:09:10 pm »
Don't have time to email it today, but I wanted to add that the Mesh Filter seems to change to "[none]" when I drag the tile from the Hierarchy to the project assets, which is where I normally store the parent tiles so they don't have to be in the scene directly. When I move it back to the Hierarchy it goes back to normal. Am I not supposed to store "parent" objects as assets like this?

9
Support / Re: Problem caching sprite IDs
« on: December 15, 2013, 04:19:05 am »
Sorry, should have included that in the original post. Here's a screenshot: http://i.imgur.com/b3pyZGK.png

10
Support / Problem caching sprite IDs
« on: December 13, 2013, 12:42:46 am »
The current script I'm working on is going to be used to swap out sprites for my terrain objects during runtime, but I've run into a problem with retrieving the sprite IDs. My goal is to have a single script do the swapping for all of my terrain objects so I don't have to have a script attached to each of them individually. From what I've read in the documentation it should be as easy  as doing the following:

Code: [Select]
public GameObject ParentTile;
private tk2dSprite sprite;
private int spriteID;

sprite = ParentTile.GetComponent<tk2dSprite>();

spriteID = sprite.GetSpriteIdByName("RoomFloor0");

ParentTile is an object I add to the script in the editor that has a sprite with the correct sprite collection selected. Everything looks like it should work, but when I run the program I get the following error at the line with "spriteID = ..."

"NullReferenceException: Object reference not set to an instance of an object."

It seems like whatever is getting saved as "sprite" isn't what the program wants, but I'm at a loss as to what it's looking for.

11
Support / Re: OnClick event
« on: December 09, 2013, 06:36:44 pm »
I'm using the Tk 2d UIItem script for the OnClick event, which seems to be more geared toward telling whether or not a button was clicked rather than just if the mouse was clicked (not taking into consideration what was clicked). I didn't know it was possible to set the script order, but I tried it and it fixed my problem. Thanks again for your help :D

12
Support / OnClick event
« on: December 07, 2013, 09:33:03 pm »
I have a button that when clicked should activate another game object using the OnClick event. Along with this, I have another event system that keeps track of left clicks (the mouse being released from the down position) for the rest of the game. When the button is activated this second event system is set to disable the button. This means that there are two different event systems keeping track of left mouse button clicks. The problem this creates is that the button is deactivated before it has a chance to run its own event to enable the other game object. Essentially the button is disabling itself while enabling another game object.

What would be the best way to ensure that the other game object is enabled before the button gets disabled?

13
Support / Re: Positioning Custom Mouse Cursor
« on: December 06, 2013, 11:29:04 pm »
Thanks for the fast reply, works perfectly! In case anyone needs this in the future here's what I have:

Code: [Select]
public Camera guiCamera;
public Vector2 screenPosition;

screenPosition = guiCamera.ScreenToWorldPoint (Input.mousePosition);

Make sure to drag the camera you're using to display the GUI into guiCamera in the editor.

14
Support / Positioning Custom Mouse Cursor
« on: December 06, 2013, 10:26:34 pm »
I'm trying to create a custom mouse cursor for my game using sprites. I have two cameras set up, one to display the game world and one to display UI elements; the cursor will be displayed by the second camera. That said, I'm not sure how to get the mouse's position relative to the UI camera. Any help is appreciated :)

EDIT: To clarify, Input.mousePosition won't work as that gives the position relative to the screen rather than the camera. In the image linked below the mouse cursor in the middle of the screen above the other menu is at (0, 1.5). 0 for the x position is in the very middle of the screen, but 0 for y is off the screen toward the bottom.

http://i.imgur.com/Yt1qq2h.jpg

15
Support / Re: Text parent/child position problem
« on: December 04, 2013, 06:05:54 pm »
Just in case anyone runs into this in the future, I managed to move forward by removing my Wall Button game object and recreating it. The new button worked fine. I still have no idea what caused the problem in the first place though haha.

Pages: [1] 2