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

Pages: 1 ... 8 9 [10] 11
136
I'm having a really weird issue: I have an inventory system with slots instantiated at run-time via a slot/button prefab.
My Anchor is set to topleft. Everything works as expected when I run in maximized mode. However, if I change the inventory position OR run in normal non-maximized view, some if not all the buttons will not detect input at all! Nothing will happen if I hover over them, etc. Although I checked to see if something went wrong with the slots after I moved the bag/inventory, everything is still set right, the colliders, etc. See the images in the attachment.

I created a simple button and changed its anchor, played around with its position in both normal and maximized views, it worked OK, which means it must be a problem with my slot prefab... However, it seems like it's a normal button, see the inspector image I provided as well :/

Please help, I'm really puzzled here... Thanks.

EDIT: If you want to see the code for instantiating:
  1.         public void AddSlot(int i, int j)
  2.         {
  3.                 GameObject slotObj = NGUITools.AddChild(gameObject, slotTemplate);
  4.                 Transform slotTrans = slotObj.transform;
  5.                 float x = SPACE_BETWEEN_SLOTS * (j + 1) + j * slotSize;
  6.                 float y = -SPACE_BETWEEN_SLOTS * (i + 1) - i * slotSize - headerPadding;
  7.                 slotTrans.localPosition = new Vector3(x, y, 0f);
  8.                 var slot = slotObj.GetComponent<Slot>();
  9.                 slot.Init(new Index2D(i, j), new Dimension2D(x, y), slotSize);
  10.                 slots[i].Add(slot);
  11.         }
  12.  

137
Just to recap: The background is scaled 105,105,1 the gun is 100,100,1 - that gives the result ^. However, if manually change the gun scale down to 85,75,1 it fits perfectly. My whole journey is to figure out a formula to give me back that new scale I have to apply to the gun.

138
Hello, In my inventory system, an item could take more than one slot, 2x2, 2x3, 3x3, etc. Each item has a texture - I don't care about the texture size (for a 2x2 item, the texture size doesn't have to be like, 256x256 or 128x128, but it would be better if it was)

Since I'm using NGUI, the item slot is actually a button, with a background, an icon (both sprites) and a label. I instantiate the slots, by using a Slot prefab, which has a script that stores the Slot size, for now I'm using 50. There's also a spaceBetweenSlots variable, which is 5.

So if I had a 2x2 item, its background would be of size 105x105, I scale the background to that size.

But the problem is, the item icon. I can't seem to know how to scale the icon, for it to fit perfectly inside the background. Take a look at the attached pictures.

Now the RedHerb fits, because its size is 594x601 and I'm scaling it by 100x100x1, but the gun is 640x453, if I scale it by the same scale as the Herb, you would get the results above.

Now the question is, how can I scale the icon to perfectly sit inside the background?


My attempts:
I came up with an idea of finding the difference between the icon's and the background's size, I keep scaling down the icon till there's a low dif between the two sizes. But NGUI is giving me a hard time of doing anything -_-

For my idea to work I just need the icon's and the background's size. I searched and found NGUIMath.CalculateAbsoluteWidgetsBounds, I'm not sure how to use it, it asks for a transform, and returns a Bounds, so I gave my background's, it got me back a bound with size of 0.2x0.2, did the same for the icon it gave me back a size of 0.0x0.0 lol O_O what is that?!

I tried background.relativeSize, I got back a V3 of (50,50,1) - The forums says to Scale that by background.cachedTransform.relativeSize, to get the size in pixles, so I did:

  1.  background.relativeSize.Scale(background.cachedTransform.localScale);

Is that correct? is that how to scale two vectors? - I got back a V2 of (1.0, 1.0) :D

Any help would be much appreciated, thanks a lot.

139
2.6.4 - The line wasn't there.

141
Hello?? anybody home??

142
This is a follow-up question for: http://www.tasharen.com/forum/index.php?topic=3815.0 (only the first part)

After I added the line that ArenMook suggested:
  1. if (textLabel == null) mSelectedItem = null;
It worked well that it didn't auto select an item, but a new problem was introduced, I got what you see in the picture below, whenever I first click on a slot, I get this strange highlight...

What changes should I make in the UIPopupList in order to fix this? Thanks.


143
Hi, when I try to disable the UIPopupList component on one of my objects, clicking on on the object still shows the popup menu, this is strange. Why is this happening? Thanks.

144
NGUI 3 Support / Re: Widgets change their parent by themselves?
« on: August 12, 2013, 12:42:21 PM »
The solution was FAQ #2.

145
NGUI 3 Support / Re: Widgets change their parent by themselves?
« on: August 12, 2013, 07:19:25 AM »
Happens also when I make a prefab out of my widgets...

146
NGUI 3 Support / Widgets change their parent by themselves? [SOLVED]
« on: August 12, 2013, 06:42:51 AM »
Why is it that whenever I add a widget, with a parent other than the panel, let's say a button, the button will get added under the parent I specify, but the background and its other stuff will go under the panel, why? - And if I manually get everything to where they belong (move the button background from the panel and parent it to the button I created), after a while, the button background just changes parents again, and goes under the panel once more! this is REALLY annoying. What can I do to prevent this?

I would order them nicely, then they suddenly go like the pic in the attachment (happens when I reload stuff from Visual Studio)

Thanks.

147
In the attached picture is what I'm trying to achieve (this was done in UnityGUI)

The question is, how can I achieve that with NGUI using a popup menu/list?
I believe this could be done by instantiating the list/menu EXPANDED in the place I want (where I right click), how can I instantiate it in its expanded state?

Thanks for the help.

148
How can I mark this as solved?

149
OK, for some reason, I REALLY DON"T KNOW WHY, but when I recreated everything (which I already did a couple of time with no good) it worked...........

150
Note that Edit|Project settings|Physics|Raycasts hit triggers is checked.

Pages: 1 ... 8 9 [10] 11