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

Pages: [1] 2 3 ... 10
NGUI 3 Support / Re: Camera problem
« on: February 20, 2013, 11:00:01 AM »
Your UI structure should not be attached to the main camera, as that would move around the UI in world space for no reason, whatsoever.  Also, you probably have some problems with your layer masks (or z-clear selection) that is causing problems.  Load up one of the NGUI samples and compare.

NGUI 3 Support / Re: Graphing
« on: January 01, 2013, 04:03:40 PM »
This is one of those areas where you have to embrace one of the various ugly options.  NGUI isn't going to hold your hand here much at all... you'll either have to go vector or bitmap.  If you go vector you have to figure out your data points relative to an arbitrary scale that you decide, then create quads that are the lines... getting proper butt and corner junctions is... a non-trivial math exercise.  Alternatively you can blit your data to a texture that is appropriately sized/scaled and then just display that texture as a UITexture.  However, compositing bitmap data is always a barrel of laughs as well.

In short, there is no easy way to accomplish this without cooking up your own custom solution depending upon what type of graph you want to display.  Like you, I really wish there were something like the DevExpress ultimate library that gives you a metric shit-ton of widgets, graphs, controls, and containers to deal with, but when dealing with low-level frameworks that are primarily intended to create games, having a good graph library is hard to come by.

NGUI 3 Support / Re: Button Background
« on: December 18, 2012, 01:47:23 AM »
A 9-sliced sprite can be any size you want.  If your art for the button is the size of a full-sized button, fine.  If it's just a tiny box that is then sliced appropriately, fine.  You need to take a good hard look at how they are defined in the atlas, because it seems like you don't quite get how they work just yet.

NGUI 3 Support / Re: Make 3D Object inside a Button (orthographic)
« on: December 11, 2012, 02:54:06 AM »
What you want to do begs for render to texture, and in thinking about it you are going to have a very complex rig to accomplish this... provided you can.

In short, I'm not providing a very helpful response.  Just stating that the Pro version of Unity is worth every penny.

NGUI 3 Support / Re: Making modal dialogs - want a "dimmer" background
« on: December 07, 2012, 04:51:30 PM »
No, that's pretty much it.  And make sure that dim backdrop panel has a collider so that it catches clicks and prevents them fro interacting with items that aren't your modal top-level dialog box.

At least I'm doing it that exact same way.

NGUI 3 Support / Re: Dragging off an object.
« on: December 06, 2012, 04:55:41 PM »
On mobile, where there is no hover, you should be able to just use .lasthit, which should be null if no collider is under the press, and the gameobject of the collider if there is.  That's just a hint to get you started.  Aren will probably provide a much more elegant suggestion.

Aha.  The returned gameObject reference from FindInParents<> is actually a reference to the component, not the parent gameObject.  So as long as you compare:


My logic will then work.

It's not completely clear from FindInParents calling structure that it is returning a component reference, not the owning gameObject's reference.  I had to logically work out what was actually being passed back.  Might want to be a bit more explicit in the function header comment?   (At least for noobs.)

Aren, I'm having to compare the property against either lasthit.collider.gameObject or .hoveredObject.  For some odd reason the gameObjects and InstanceIDs are different, even though resolving the .name yields the same object name.  And these gameobjects that have UIPanel are definitely unique and have unique names.  I just don't get why I'm not getting the same object reference.

Here's the skeleton of the function I'm using to check if the mouse has left a given panel:

  1.         if (hideIfLosesMouseFocus)
  2.         {
  3.             _ObjectHovered = (UICamera.hoveredObject != null);
  5.             if (!_ObjectHovered || != NGUITools.FindInParents<UIPanel>(UICamera.hoveredObject).name)
  6.             {
  8.                 if (!_focusLost)
  9.                 {
  10.                     _focusLost = true;
  11.                     _hideAtTime = DateTime.Now + TimeSpan.FromMilliseconds(500);
  12.                 }
  13.                 else
  14.                 {
  15.                     if (DateTime.Now > _hideAtTime)
  16.                     {
  17.                         NGUITools.SetActive(this.gameObject, false);
  18.                         _focusLost = false;
  19.                     }
  20.                 }
  23.             }
  24.             else
  25.             {
  26.                 // hovering within panel
  27.                 _focusLost = false;
  28.             }

This works, but I'd be happier if I could avoid using the .name property, since there is no guarantee of uniqueness there.

I guess I re-invented the wheel since the implications of any given member function is not immediately apparent when you're first starting off with NGUI.  Time to go back and re-factor some of my common classes.

You don't have to do your own raycast event, you can just use UICamera.lasthit

But, yeah, you pretty much got it.

You will need to create a script that you attach to the panel that enumerates and stores all of its children's instanceID, as well as the panel's own.  I recommend using a hashtable or dictionary for storage, so it's fast.  Then, your panel script that checks to see if the mouse is still hovering simply needs to check if the currently hovered target instanceID is the panel itself or one of those children.  If so, do nothing.  If not, close the panel.  I also recommend adding a small window of opportunity for the mouse to re-hover the window, as sometimes the user will not be accurate and the mouse will stray off the window for a fraction of a second.

I wrote a fairly general panel manager with this type of functionality for my own project, which you will want to do as well... so you can easily add it to any panel you create that you want to behave in this fashion.

NGUI 3 Support / Re: Is NGUI supported by Unity4?
« on: November 27, 2012, 02:45:10 PM »
Yes, it works just fine with Unity4.

Are you sure it's NGUI causing that error, and not your own code?  Or are you using the old free version that likely isn't Unity4 updated?

NGUI 3 Support / Re: Button disappears after hover
« on: November 27, 2012, 02:43:47 PM »
So do some event handling of your own and write the correct alpha value to the control?

NGUI 3 Support / Re: Create UI "on-the-fly" (programmatically)
« on: November 22, 2012, 06:00:35 PM »
Of course.  You'd just create gameobjects in a hierarchy and attach the script components in proper sequence.  You can set all of the component variables and settings via code, too.

Caveat:  Aren might correct the statements above if there is some under the hood magic that I'm not aware of.

NGUI 3 Support / Re: Sending Parameters within Buttons?
« on: November 22, 2012, 12:02:06 AM »
Well, off the top of my head, you seem to need to attach another piece of metadata to your button gameobjects.  For example, you could add a tiny custom component like this:

  1. using UnityEngine;
  2. using System.Collections;
  4. public class MyButtonData : MonoBehaviour
  5. {
  7.     private int _intValue = -1;
  9.     public int ButtonIntValue
  10.     {
  11.         get { return _intValue; }
  12.         set { _intValue = value; }
  13.     }
  15.     void OnClick()
  16.     {
  17.         MyMainClass.ButtonHandlerFunction(ButtonIntValue);
  18.         // or get an instance to a gameobject and call the appropraite class method
  19.     }
  20. }

When you instance the button you have to take the gameObject and use .GetComponent<"MyButtonData"> and then set ButtonIntValue to be the integer you want.  In OnClick() we are using the int value that is stored in this component (which is a class, really) and then firing some static method that is part of MyMainClass.  You can also, instead, also store in a reference to the gameObject that is the panel owner, or whatever else, that might have the master logic handling class attached, and call that instance method.

If this is not making sense to you, then you really need to learn about C# and OOP at a basic level, because you seem to be trying to attack this via old C++ style functional coding or something.

Pages: [1] 2 3 ... 10