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

Pages: 1 2 3 [4] 5
46
You should be able to just put a collider ON the object in question, then it will trigger OnClick() when it's touched.

47
NGUI 3 Support / "flat" 3D panels impossible with clipping?
« on: March 10, 2013, 04:34:43 PM »
I'm trying to make the nice 3d angled panels as demonstrated in the examples, but since the contents are a clipped draggable panel, is this not an option? If I raise the contents off the Z-level enough to not get stuck behind the window, it's pretty obvious when they're at an angle!

To make matters stranger, normally when I tilt down the content falls behind the window, but I found that if I cloned the menu, then I could look at them from top or bottom and they would be correct, as long as they were closest to the camera... where before they would have their contents covered if looked at from below!

I was hoping to use flat 3D menus, but it seems this is not possible with that sub-panel with clipping and dragging?

Is there some workaround? Perhaps if I can specify the order of the draw calls on the panels?

48
NGUI 3 Support / Re: Making Menus: Has to be a better way!
« on: March 10, 2013, 05:30:09 AM »
EDIT: While I was able to convert the Action delegates to the uiEventListener.VoidDelegate type, is that the only kind of delegate I can assign to onClick ?

I was hoping to keep the code in the menu scripts and not on the buttons by adding the method to the onclick listener, but it seems to take its own kind of delegate... which is a bit problematic as I was hoping to use other delegates loaded with parameter info as well.

  1. public class MainMenu : MenuScript
  2. {      
  3.         // Use this for initialization
  4.         void Start ()
  5.         {
  6.                 AddTitle("Main Menu");
  7.                
  8.                 AddButton("Game Help", GameHelpMenu);//implicit. should also work.
  9.                 AddButton("Review", new Action(ReviewMenu));
  10.         }
  11.         public void ReviewMenu ()
  12.         {
  13.                 //stuff
  14.         }
  15. }
  16.  
  17. public delegate void OpDelegate(Operative op);
  18. public delegate void strDelegate(string str);
  19.  
  20. public class GUIManager : MonoBehaviour
  21. {
  22.         //stuff
  23.         public void AddButton (string label, Action methodToCall, GameObject contents)
  24.         {      
  25.                 //make newButton
  26.                 GameObject newItem;
  27.                 newItem = NGUITools.AddChild(contents, menuButton);
  28.                 newItem.GetComponentInChildren<UILabel>().text = label;//write Title label
  29.                 newItem.name = ChildCount(contents) + "Button";
  30.                
  31.                 //add method to call to button event
  32.                 UIEventListener.Get(newItem).onClick += methodToCall;//ERROR: Operator `+=' cannot be applied to operands of type `UIEventListener.VoidDelegate' and `System.Action'
  33.         }
  34.  
  35.         public void AddStringButton (string label, strDelegate methodToCall, GameObject contents)
  36.         {      
  37.                 //make newButton
  38.                 GameObject newItem;
  39.                 newItem = NGUITools.AddChild(contents, menuButton);
  40.                 newItem.GetComponentInChildren<UILabel>().text = label;//write Title label
  41.                 newItem.name = ChildCount(contents) + "Button";
  42.                
  43.                 //add method to call to button event
  44.                 UIEventListener.Get(newItem).onClick += methodToCall;
  45.         }
  46. }
  47.  

49
NGUI 3 Support / Re: UIButtonMessage Guidance Please
« on: March 09, 2013, 11:52:09 PM »
But what if you wanted to do the part where you added the method to the listener elsewhere? like:


  1.         void Start ()
  2.         {
  3.                 AddButton("Manage Circles", ManageCirclesMenu(), ThingToAdd);
  4.         }
  5.  
  6.         public void AddButton (string name, ????? methodToCall, GameObject thingToAdd)//how to send in the method?
  7.         {
  8.                 //make newButton
  9.                 UIEventListener.Get(newButton).onClick += methodToCall;
  10.                 //add thingToAdd to button
  11.         }

50
NGUI 3 Support / Re: UIButtonMessage Guidance Please
« on: March 09, 2013, 11:44:14 PM »
EDIT: Just realized you meant MyButtonCode to be the thing in the CoreLogic, not the script on the button. Yes, I think that's what I needed! Thank you.

51
NGUI 3 Support / Re: UIButtonMessage Guidance Please
« on: March 09, 2013, 09:22:54 PM »
Consider looking at it from the opposite side. Create a script attached to your button that has a public variable (index you need), and uses NGUITools.FindInParents inside OnClick() to find your manager script that's attached to one of the parent objects. Your script can then call some function on the manager script, passing the index.

It's clean, the parent doesn't know anything about what's calling it, and the only thing you have to do is set the index when instantiating your grid items.

Sorry to revive an old thread, but can you give an example of this? I'm not quite sure what you're suggesting here.

52
NGUI 3 Support / Making Menus: Has to be a better way!
« on: March 09, 2013, 08:36:37 PM »
Hi! So my current GUI is getting scrapped, and I'm sure there's a better way to build one.

Might just skip to CLARIFICATION on the bottom to get an idea of the key problem.

the current system has a set 3 windows (menu, selection, detail) and I want to allow infinite windows, opening as needed.

Currently, the awkward system is:
there are prefab buttons for the three different windows. they each reference a guimanager, menuType (for if its menu,selection,or detail), and id (for listing the buttons purpose, or specific object id it refers to, etc).
OnClick(), it calls gui.manager.Pick(menuType, id)

for example, we click a button with menuButton,gamehelp. it sends that to guimanager, who then sends "gamehelp" to the menu case statement, which then determines gamehelp should run the connected script function, this.GetComponent<GameHelp>().PickMenu();

that then, according to the gamehelp script, populates the middle "Selection" window with buttons.

say we click "quickstart" button, it sends SelectionButton,quickstart to GUImanager, which then jumps to the selection button case statement (so any click on a button on the middle window comes here), then in that case statement it says this.GetComponent<GameHelp>().PickSelection(selectionName);

pick selection then, in yet another case statement, takes the selection (quickstart) and draws that info in the details window.

it's the same process for the detail clicks.

so yeah, this seems all sorts of loopy. Ideally, I can just create menu scripts and when i make a new window, attach the relevant script, then when any buttons in that window are clicked, it sends a notice and id's which button/thing was clicked to the target script specified, and if it cant find it it makes it.

For example, i click gamehelp button in the base window. it looks for a gamehelp script, cant find one, so it makes a new gamehelp window w/ script, and fills with buttons like quickstart and tutorialOnThing. Clicking on one of those buttons looks for helpDetail window, it doesnt exist so it makes one and populates it. If i were to click a different gamehelp button, it'd find the existing gamedetail window and repolulate it. by the same token, a button could close it's own window and send the relevant data to another (still open) window.

Is this still backwards? am I on the right track? how do you do this sort of thing?

EDIT: Clarification
Gonna try to describe what I want in the most basic terms.

a mainmenu script starts. it creates a window and procedurally adds some buttons: help, quit, review, and a list of 1-8 names. when it adds the button, it passes on the information of what method in mainmenu.cs it should call. In the case of the name buttons, it also passes on a specific indicator as to what name is referred to. For example, AddButton("Guy 1", NameDetails, "n1") with NameDetails being the method, and n1 being the data it should send back when it's pressed.

the Guy 1 button is pressed, and the event listener picks it up, running mainmenu.NameDetails(n1).

I figure AddButton(string name, ??? method) would take that data, make the button, and do the whole UIEventListener.Get(button).onClick += method;
though I'm not sure how to transfer a method to AddButton, or how to make it set the "n1" data to that specific button so when method is called, it sends the "n1" parameter.

53
NGUI 3 Support / Re: Creating a new font crashes Unity 100% of the time
« on: February 26, 2013, 04:33:07 PM »
Atlas changed dialog? There is no atlas changed dialog. This was removed a long time ago.

Haha, ok so the problem is something else... The asset store apparently wasn't actually updating my NGUI package despite directly telling it to do so. Still on 2.2.6B... Sorry about that :P

54
NGUI 3 Support / Re: Creating a new font crashes Unity 100% of the time
« on: February 25, 2013, 11:39:42 PM »
He's not the only one. I have a fresh install of Unity, fresh install of NGUI, and a fresh Scene and the exact same problem happens to me.

Whenever I try to create a font with Font Maker, I click create the font and it opens the atlas changed dialogue. i click ok, get a spinning wheel for a second, and unity crashes. This happens EVERY time.

However, if I create the same font WITHOUT selecting an atlas, it works fine, every time.
I can then select that font and the atlas I want, and "replace the font", and it *seems* to add it to the proper atlas without any fuss.

55
NGUI 3 Support / Re: UITable construction "hide"
« on: November 16, 2012, 10:14:10 AM »
I haven't tried it, but I believe you can loads them inactive (so they are not seen), adjust them (they should still have their shape you can see in the scene view), then loop through and turn them back on? Not sure if you'd see them all turning back on one at a time or not, though.

56
What I'm trying to do is make a GameObject based on a prefab, load in the details (name, scripts, etc), move that object into a List<GameObjects> selectionMenu, then when I'm done making all the various objects, call DrawList()and addChild each of those elements to the table.

The problem is the list seems to only contain empty default game objects, not the prefabs or their modifications.

Is this even possible? I used to instantiate the items as you'll see in "AddButton()", but I need them to go in these lists first now, and addChild them when I have them all. Any help would be greatly appreciated! 8)

EDIT: so perhaps to clarify my goal here: I want to take a prefab, modify it's properties (name, component data, etc), load that item into a list, and then add it to the GUI (via addchild, as this is the only way it seems to work?) from that list.

  1. public void AddTitle (string label)
  2.         {              
  3.                 GameObject newTitle = (GameObject) Instantiate(Title);//this is making them in the root heirarchy. it makes them correctly,
  4. //but the point is I just want to store the object, to AddChild from a list later.
  5.                 newTitle.GetComponentInChildren<UILabel>().text = label;//write Title label
  6.                
  7.                 switch (buildMenu)
  8.                 {
  9.                 case BuildMenu.Selection:
  10.                         newTitle.name = selectionItems.Count + "Title";
  11.                         selectionItems.Add(newTitle);//this seems to only add a empty default GameObject, not this prefab item
  12.                         break;
  13.                 case BuildMenu.Detail:
  14.                         newTitle.name = detailItems.Count + "Title";
  15.                         detailItems.Add(newTitle);
  16.                         break;
  17.                 default:
  18.                         break;
  19.                 }
  20.                
  21.         }
  22.  
...
  1. public void DrawList ()
  2.         {
  3.                 List<GameObject> itemsToDraw = new List<GameObject>();
  4.                 GameObject tableToDraw = new GameObject();
  5.                
  6.                 switch (buildMenu)
  7.                 {
  8.                 case BuildMenu.Selection:
  9.                         itemsToDraw = selectionItems;
  10.                         tableToDraw = SelectionTableRef;
  11.                         break;
  12.                 case BuildMenu.Detail:
  13.                         itemsToDraw = detailItems;
  14.                         tableToDraw = DetailTableRef;
  15.                         break;
  16.                 default:
  17.                         itemsToDraw = selectionItems;
  18.                         tableToDraw = SelectionTableRef;
  19.                         break;
  20.                 }
  21.                
  22.                 for (int i = 0; i < itemsToDraw.Count; i++)
  23.                 {
  24.                         itemsToDraw[i] = NGUITools.AddChild(tableToDraw);
  25.                 }                              
  26.                 tableToDraw.GetComponent<UITable>().repositionNow = true;//adjust table
  27.         }
  28.  

57
NGUI 3 Support / NGUI and SVN: Can they play nice?
« on: November 11, 2012, 01:33:17 PM »
So I use SVN with my projects, and part of that means not including the library in the SVN; you're supposed to let it rebuild when you download a fresh copy. However, if the library is rebuilt when you use NGUI, it removes ALL references to scripts, leading to the structures in the hierarchy having "Monobehaviour" as every component name, and no script referenced in the script line below that. Obviously going through every ui element and reattaching the scripts isn't the solution, but including the library in the SVN leads to constant conflicts and corruptions as files are moved back and forth.

Is there an easier solution I don't know about?

58
NGUI 3 Support / UITable "Reposition Now" moves the panel and clipping?
« on: November 02, 2012, 07:37:38 PM »
This may be a bit hard to explain, as it's a very odd bug.

So I make a panel that contains a "table" gameobject with table attached, and inside that assorted buttons and labels. The panel is at 0,0,0; it has clipping on, centered at 0,0. Everything "lines up" with the sprite box underneath it.
The "Table" game object located at -150,255,0 (since otherwise half the contents will stick out of the panel). the contents all line up perfectly.

Now, if I hit reposition now on the UITable (currently doing this in inspector), it LOOKS like nothing has changed, but actually it does something odd:
It moved the panel to 4.999985,15,0 and sets the "center" in UIPanel's clipping settings to -4.999985,-15. With different paddind in the table, it changes the numbers it shifts to.

The expected behaviour is for the clipping and the panel transform to stay put.
This is a somewhat minor bug, since it *visually* doesn't change things, but if you are setting up panels in specific locations, having transforms that shift to apparently random numbers causes all sorts of problems.

(P.S. Congrats on the hire! I look forward to seeing what you do with Unity UI now that you've got your hands on the source!)

59
NGUI 3 Support / Re: Scaling to fill the screen with the new UI Anchor>
« on: August 28, 2012, 03:45:57 PM »
That style of UI placement only tends to work if the UI is complementing a central scene (for example, the WoW UI elements around the 3d world view).
I don't have such a central scene; the entire game view is composed of the UI elements. the only thing behind them is dead screen space.

For reference:

Note the dead space on the top and bottom... and this only fits on this particular set up. on other screens it could have dead space on the sides, or even be cut off on the sides.

60
NGUI 3 Support / Scaling to fill the screen with the new UI Anchor>
« on: August 28, 2012, 03:33:57 PM »
This is more of a design question, I think.

The program is set on portrait only. I have a "Landscape" (a 16:9 image) that I want to scale out to the width of the phone screen, taking the full width, and the height being whatever the scaling brings it to. Then, I'd like to create a panel attached to the bottom of that Landscape, width also filling the screen, and extending all the way to the bottom of the screen (i.e. height - height of the Landscape).
In theory these two elements should then always fill the screen, with no dead space around them.

With the GUI scaling function only "scaling to height", how would I set it up to scale to screen width?

Pages: 1 2 3 [4] 5