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

Pages: [1]
1
NGUI 3 Support / Re: NGUI Element - Transform position
« on: May 11, 2014, 10:01:13 AM »
Thank you very much for your replay
And thank you for a tip to avoid the loop and iterating trough childs, will defiantly include script to prefab to store references.

Regarding transform.position - that was very silly mistake :) got it sorted!
Regarding "NGUITools.AddChild" - I believe parent have to be "UI Root"? is there a quck way to get root? like:

NGUITools.AddChild(NGUITools.getRoot(), myPrefab); cause i didnt find
Or i have to make reference as you recommend with labels?

P.S. is that you who developing new GUI system for Unity 3.6? Got beta build of it, looks very nice and promising, but.... NGUI is way more advanced at the moment, so we rolled back to 4.3 and NGUI :)

P.P.S. I would defiantly recommend include more tutorials and documentation regarding how to work with NGUI or New Unity GUI from the code, rather than in Editor drag and drop.
What is more - would be nice to have pre-scripted methods to add NGUI element like
NGUITools.CreateButton(*params*)
NGUITools.CreateInputFied(*params*)
and so on...

But anyway, thank you very much and you know how great you are with your tool     

2
NGUI 3 Support / NGUI Element - Transform position
« on: May 11, 2014, 07:10:52 AM »
Hello everyone, im having some difficulties with NGUI (3.5.8)

We are working on applications and GUI where GUI elements should be dynamically moving here and there, new items appears, move in, move out and so on... It would be kind of hard to define all GUI in editor, as GUI have to change dynamically depending on situation. So I have to create NGUI elements from code, however i faced one problem with transform position - it is set to zero always, and im not sure how to fix it

here is my small example code:

  1. public class GUIManager : MonoBehaviour {
  2.  
  3.  
  4.     private GameObject inputField;
  5.  
  6.     public void LoginButtonClick()
  7.     {
  8.         Debug.Log("Login Button Clicked");
  9.         inputField = CreateInputField("Please Enter some text", new Vector3());
  10.         CreateButton("Get Input Value", new Vector3(0.0f, -45f, 0.0f), PrintInputFieldValue);
  11.  
  12.     }
  13.  
  14.     public GameObject CreateInputField(string baseText, Vector3 pos)
  15.     {
  16.         GameObject inputPrefab = Resources.Load<GameObject>("Prefabs/GUI/InputField");
  17.         GameObject input = Instantiate(inputPrefab, new Vector3(), transform.rotation) as GameObject;
  18.         input.transform.position = pos;
  19.         SetTextToChiledLable(input, baseText);
  20.         return input;
  21.     }
  22.  
  23.     public void CreateButton(string btnName, Vector3 pos, EventDelegate.Callback method)
  24.     {
  25.         GameObject buttonPrefab = Resources.Load<GameObject>("Prefabs/GUI/Button");
  26.         GameObject btn = Instantiate(buttonPrefab, pos, transform.rotation) as GameObject;
  27.         SetTextToChiledLable(btn, btnName);
  28.         btn.GetComponent<UIButton>().onClick.Add(new EventDelegate(method));
  29.     }
  30.  
  31.     public void SetTextToChiledLable(GameObject parent, string text)
  32.     {
  33.         foreach(Transform child in parent.transform)
  34.         {
  35.             if (child.gameObject.name.Equals("Label"))
  36.             {
  37.                 child.gameObject.GetComponent<UILabel>().text = text;
  38.                 break;
  39.             }
  40.         }
  41.     }
  42.  
  43.     public string GetTextFromChiledLable(GameObject parent)
  44.     {
  45.         foreach (Transform child in parent.transform)
  46.         {
  47.             if (child.gameObject.name.Equals("Label"))
  48.             {
  49.                 return child.gameObject.GetComponent<UILabel>().text;
  50.             }
  51.         }
  52.         return "";
  53.     }
  54.  
  55.     public void PrintInputFieldValue()
  56.     {
  57.         Debug.Log("Input field value was: " + inputField.GetComponent<UIInput>().value);
  58.     }
  59.  
  60. }
  61.  

In 2 words:
I have static predefined button created in Editor with attached call back method: "LoginButtonClick", and predefined prefabs (button, input field).
By clicking that static button it would call: "LoginButtonClick"
which create one input field and one button where input field will be at zero coordinates and button should be a bit bellow (-45 on Y axes)

When i debug the process of creation of the button, prefab instantiated at the right position, however when item appear in the scene it already some how resets to zero, so it appears on top of input field and overlap it.
moreover setting "myButton.transform.position" to newly created button after it was placed in the scene doesn't have any effect.

So im wondering how to set position of GUI element in the script?
am also very surprised that there are so little information and tutorials on manipulations with NGUI trough script, I cant believe that most of the developers enough just in-editor gui definition.
I even have specious that im missing some concept of using NGUI and doing something wrong. or is there already some predefined helper code like "NGUI.CreateButton(btnName, callback)"

Here is logic my current test case:
Depending on application logic, i need to display NGUI elements for Login or Register actione where amount and position of elements could be different.
I know i can set all of that in editor with use of "tabs" where GUI for each tab (Login/Register) is predefined, however what if i don't want any tabs? If i need the same single screen where i would need 2 input fields(login/pass) and 2 buttons (login/Register) for Login screen and once user press "Register" add more (with nice animation: move in/move out) 3 input fields (email, name, etc..) without separate screens or tabs?
I believe that is achievable only trough script? am i right? Or im seriously missing some NGUI concept?   



3
NGUI 3 Support / Re: Gather input fields data from one button click
« on: March 25, 2014, 05:55:48 PM »
Topic UP!
Still no answer? c'mon guys give me your advice :)

4
NGUI 3 Support / Gather input fields data from one button click
« on: March 24, 2014, 07:25:11 PM »
Hello

I'm very new to NGUI, literally just started. However im good programmer. I Watched few video tutorial and played around with all examples scenes in the NGUI pack and found it very cool, however one main and major thing is missing in example or video tutorial - it is how to deal with input and other GUI elements from the code.
How to gather input fields data?

Lets assume I have registration form with 5 fields.
Each field has "On Submit" and "On Change" event listener
Final 'Register' Button - has "On Click" event listener

How to gather all inputs from all fields from "On Click" event?
From what i got first in my mind - i see few scenarios:

1) Find each input field as GO, get it components and gather data - that's very over complicated and compute intensive i would say, dont like an idea of searching objects in entire scene, especially if i have tons of them.
2) Attach script which dealing with button "On Click" event to each text field and try to collect or to be more clear build up final values trough "On change" event by appending value -  I'm not sure yet would i be able to differentiate between input fields in "On change" event, and all this still feels over complicated
3) Create static script for each field and then collect the data - easy implementation, but too many scripts in project
4) not even sure, but im sure there should be easy, nice and clean way of doing so

Could you guys please explain to me what is the best and common way to gather data from input fields trough button click event?


While I already create new topic ill use that chance and ask one more question :)
Is gui elements dynamic in relation to screen resolution?
For example if ill make bottom slide bar which fit at the very bottom and fill full screen width, will it be automatically scaled to the window size?
for example my Web Build has resolution set to 1024 x something, my Android SGS4 is 1080 x 1920 , my PC is opposite of SGS4 - 1920x1080
Would this bottom bar continue to consume entire screen width and proportional high to different resolutions dynamically? or I will have to handle it and scale gui items from the code?

NGUI is truly amazing but oriented more to the Unity Editor, rather then dynamic creation from the code as far as i see? am i right? or horribly mistaken? however if it dynamically scales depending on build target screen resolution I probably even dont need to have it the code as it is already dynamic, i could design then in Editor once :)

Anyway - thank you guys very much in advance           

5
Misc Archive / New Unity GUI and NGUI
« on: March 18, 2014, 07:07:28 AM »
Hello

Yesturday was anounced Unity 5(http://forum.unity3d.com/threads/234725-Unity-5-Announced), which supose to be avaliable for pre-order today.

Acorting to my research, Unity anounce new GUI system in summer 2012
(http://blogs.unity3d.com/2012/06/29/the-new-gui/)
and our loved ArenMook after few month later wrote that he accept offer and join Unity as he believe that with full access to the Unity core he would be able to make GUI even better and faster instead of using current hacks
(http://www.tasharen.com/forum/index.php?topic=2126.0)

So it is now 2nd quartal of 2014 - and Unity 5 was just anounced.
It happens that we working on our project, and my networking module nearly complete and it come to the point of creating GUI.
Obviously we consider to use NGUI, but with today news im a bit confused...
I assume new Unity GUI will be improved version of NGUI. But the question is: When it will be avaliable? Will it be part of Unity 5? should we wait for a week or stick with NGUI?  Will new Unity 5 include new GUI? should we wait a bit while Unity 5 become available?

Thank you in advance for clarification

Pages: [1]