Author Topic: New NGUI user/android questions:  (Read 8214 times)

J450NP13

  • Guest
New NGUI user/android questions:
« on: November 18, 2013, 10:44:41 PM »
I am a new ngui user.  I have had it for awhile now but never seemed to have time to learn it.  I have a android game and I think ngui would be best to use for the anchoring feature. 

My question is I already have guitextures coded for touch and what not, how hard would it be to swap the guitextures out for ngui stuff?

I can't seem to find the right way to position the guitextures right on any resolution and I was told that ngui would do it automatically.

Any help would be appreciated.

duncanx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: New NGUI user/android questions:
« Reply #1 on: November 19, 2013, 02:32:18 AM »
I found that once you learn NGUI, doing most things is pretty quick. But, if you're doing anything even a little interesting with the UI then the initial mastery is deceptively extensive. For every major UI feature you'll get 99% of the way there in 10 minutes, then spend a day or 2 learning something subtle about it for the last 1%. But this doesn't mean you shouldn't use it. The value is really the draw calls management, which is pretty critical on Android.

J450NP13

  • Guest
Re: New NGUI user/android questions:
« Reply #2 on: November 19, 2013, 07:41:34 AM »
Well I got up and running pretty quick , but I am having some trouble.  I have GUITextures as my buttons, I am not using them in a OnGUI function, I am using touch....how can I drag and drop NGUI elements into the public vars that the GUITextures are in?

I already created a few NGUI textures and tested the resolutions and it works great....but I need to use them as buttons for touches???

Any help?   I've searched everywhere and can't find anything.

J450NP13

  • Guest
Re: New NGUI user/android questions:
« Reply #3 on: November 19, 2013, 11:10:16 AM »
Ok, thanks for the non-support.   Exactly what I expected.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New NGUI user/android questions:
« Reply #4 on: November 19, 2013, 08:39:14 PM »
Unity's OnGUI and NGUI are vastly different systems. Where you code everything for OnGUI, in NGUI you create everything visually. I suggest you start by watching the NGUI 3.0 tutorial -- it covers all the basics.

In your case, I recommend setting the UIRoot to "manual" sizing mode. This way your UI textures will always remain the same size proportionally -- this is covered in the tutorial.

And in the future, consider giving people more time to respond. I, for example cover these forums at least every 24 hours.

J450NP13

  • Guest
Re: New NGUI user/android questions:
« Reply #5 on: November 19, 2013, 09:09:26 PM »
Thank you ArenMook,

I will look at the tutorials.  So I don't need to code for the touch?? 

I did watch a few of those tutorials.  I didn't see anything about touch.  I am also using an itween animation with the buttons.

Could I use the NGUI anchor on a GUITexture?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New NGUI user/android questions:
« Reply #6 on: November 19, 2013, 09:14:13 PM »
This is a good starting point:

http://www.youtube.com/watch?v=OT0hTxjjkY4

No, GUITexture and NGUI have nothing in common. NGUI's equivalent is "UITexture".

J450NP13

  • Guest
Re: New NGUI user/android questions:
« Reply #7 on: November 19, 2013, 09:17:03 PM »
Rgr that.  I seen that one.  I still can't wrap my head around it. 

I can't use this code on a NGUI Texrue?

  1. if (touch.phase == TouchPhase.Began && Button.enabled && Button.HitTest(touch.position))
  2.                     {
  3.                         iTween.PunchScale(iTweenButton, iTween.Hash("x", -.4, "y", -.4, "time", .3));
  4.                         doThis();
  5.                     }
  6.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New NGUI user/android questions:
« Reply #8 on: November 19, 2013, 09:20:04 PM »
NGUI texture is just a game object. You can move it around like any other game object, so yes it will work.

However instead of "TouchPhase" stuff, all you'd need is to have an OnClick function (or OnPress, whatever you need to do).

  1. void OnClick () { Debug.Log("Clicked!"); }

J450NP13

  • Guest
Re: New NGUI user/android questions:
« Reply #9 on: November 19, 2013, 09:24:26 PM »
Ok, sweet.  I'll Let you know how it goes.

J450NP13

  • Guest
Re: New NGUI user/android questions:
« Reply #10 on: November 19, 2013, 09:38:54 PM »
Question,

How do I link the NGUI texture to that onClick funtion?

In the video the code is attached to the button, I need the code in my main class where all my other functions are.   How can I do this?

The itween isn't working on it either.  When I am attaching the ngui element in the inspector am I doing the entire element or just the texture?
« Last Edit: November 19, 2013, 10:12:25 PM by J450NP13 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New NGUI user/android questions:
« Reply #11 on: November 19, 2013, 10:20:06 PM »
Every button as an OnClick notification you can set in inspector by targeting a function on a remote object. Any public "void FunctionName(void)" type function will do. You can also subscribe to remote notifications from code by using UIEventListener.Get(targetGameObject).onClick = YourFunction;

J450NP13

  • Guest
Re: New NGUI user/android questions:
« Reply #12 on: November 19, 2013, 10:37:46 PM »
Ok, I'll try that way to see if it is any better.  I am getting it to work, although it isn't as responsive as gui.  I have to press hard and a couple times for it to get pressed.

Is there a way to make it more responsive?

The itween is working but in a wierd way.  It is like scaling about 1000% instead of the -.4 it is suppose to.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New NGUI user/android questions:
« Reply #13 on: November 20, 2013, 03:51:38 AM »
NGUI has built-in tweens for most basic functionality -- position, rotation, scale, color, alpha, etc. Everything should be responsive. Check examples that come with NGUI to see how they behave in comparison.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: New NGUI user/android questions:
« Reply #14 on: November 20, 2013, 09:40:08 AM »
Play around with the examples provided in the package, that way you'll learn most of the basics, so you don't have to waste time waiting for answers here until it's bigger issues.