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

Pages: [1] 2
1
  1. GameObject go_lbl = new GameObject("new_label");
  2.                 go_lbl.AddComponent(typeof(UILabel));  
  3.                 go_lbl.transform.position = Vector3.zero;
  4.                
  5.                 // get fonts
  6.                 UIFont[] fonts = (UIFont[])Resources.FindObjectsOfTypeAll(typeof(UIFont));
  7.                
  8.                 // set font
  9.                 go_lbl.GetComponent<UILabel>().font = fonts[0];
  10.                 go_lbl.GetComponent<UILabel>().text = "Test label";
  11.                
  12.                
  13.                 go_lbl.transform.parent = this.transform;
  14.  

2
Hi,

I never had this error before with 2.3.x versions, but with 2.5.0 i get this error when i want update NGUI in my project:

Assets/NGUI/Scripts/Editor/UIWidgetInspector.cs(528,55): error CS0117: `Tools' does not contain a definition for `current'

Is it Unity or NGUI problem?

3
NGUI 3 Support / Re: Issue setting variable with OnPress()
« on: November 18, 2012, 03:29:20 AM »
OnPress function return press/release state via argument, when script is assigned on UIButton component.
true - when button is pressed
false - when button is up

void OnPress(bool isPressed) ....

http://www.tasharen.com/forum/index.php?topic=2249.msg11218#msg11218

4
NGUI 3 Support / Re: Scrolling UIButton with UIDraggableCamera
« on: November 06, 2012, 12:24:17 PM »
You need write your button event, I had same problem too.
http://www.tasharen.com/forum/index.php?topic=2086.msg10395#msg10395

5
Try this.

I have assigned this script on buttons in panel with UIDragPanelContents too. Every button in my panel then works as DRAG event for drag content, Click event on button and Hold event on button.

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class OnClick_and_OnHold: MonoBehaviour
  5. {
  6.        
  7.         public float time_press = 0;
  8.         public float time_release = 0;
  9.         private bool inUse = false;
  10.         private float delta_time;
  11.         public UILabel label;
  12.        
  13.         void OnPress(bool isPressed)
  14.         {
  15.                                
  16.                         if(isPressed)
  17.                         {                      
  18.                                 time_press = Time.realtimeSinceStartup;
  19.                                 inUse = true;
  20.                         }
  21.                         else
  22.                         {
  23.                                 time_release = Time.realtimeSinceStartup;
  24.                                
  25.                                
  26.                                 if ((time_release-time_press)<0.25f)
  27.                                 {
  28.                                         this.MyOnClick();
  29.                                 }      
  30.                                
  31.                                 inUse = false; 
  32.                         }
  33.         }
  34.        
  35.         void OnDrag()
  36.         {
  37.                 this.inUse = false;    
  38.         }
  39.        
  40.         void MyOnClick()
  41.         {
  42.                 // YOUR CODE for CLICK HERE
  43.                
  44.         }
  45.        
  46.  
  47.         void MyOnHold()
  48.         {
  49.                 // YOUR CODE for HOLD here
  50.                
  51.         }
  52.  
  53.         void Update()
  54.         {
  55.                
  56.                 if (inUse)
  57.                 {
  58.                        
  59.                        
  60.                         delta_time = Time.realtimeSinceStartup - time_press;
  61.                         if (delta_time>0.5f)
  62.                         {                              
  63.                                 if (Input.touchCount < 2)
  64.                                 {
  65.                                         this.MyOnHold();
  66.                                        
  67.                                 }
  68.                         }
  69.                
  70.                 }
  71.         }
  72.        
  73. }
  74.  
  75.  

6
NGUI 3 Support / Re: NGui and Gestures
« on: October 19, 2012, 05:30:06 PM »
Try add collision plane at top of all elements when OnPress is true, and remove when gesture is done.

8
NGUI 3 Support / Sprite preview in 2.22 - bug
« on: October 06, 2012, 01:01:20 PM »
From NGUI 2.22:

FIX: Sprite preview should now display wide sprites correctly.

but looks like doesn't works :(

9
NGUI 3 Support / Re: Error when update 2.21
« on: September 23, 2012, 04:00:54 AM »
You need update Unity too to 3.5.5f3

10
NGUI 3 Support / OnEnable/OnDisable
« on: September 16, 2012, 01:22:07 PM »
I have assigned script to a few game objects with UI childs this script for visibility controll when GUI items are showed:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class VisibleByCheckbox : MonoBehaviour
  5. {
  6.        
  7.         public UICheckbox cb;
  8.        
  9.         void OnEnable()
  10.         {              
  11.                 NGUITools.SetActive(this.gameObject,cb.isChecked);                                             
  12.         }
  13.        
  14.        
  15.         void OnDisable()
  16.         {
  17.                 NGUITools.SetActive(this.gameObject,cb.isChecked);                             
  18.         }
  19.        
  20. }
  21.  
  22.  

but NGUITools.SetActive command enable only parent and not all child objects.

On checkbox is assigned UICheckboxControlledComponent for hide/show GUI groups and workls well, parent and child objects are hide/show.

It's strange.

11
NGUI 3 Support / Re: Clipping doesn't work
« on: September 14, 2012, 03:55:40 PM »
First-time i had problem too. Try this step-by-step tutorial.  http://www.tasharen.com/?page_id=4444
Clipping works cool.

12
NGUI 3 Support / Re: Grid - Prefabs are positioned on the same position
« on: September 08, 2012, 05:49:07 AM »
1) ... and remove update void
2) set sorted to true on UIGrid
3) call reposition on grid
4) ResetPosition on panel

i have similar method used with Table and works.

  1.  
  2.    // Use this for initialization
  3.     void Start ()
  4.     {
  5.         GlobalEditorData.cells = new TSourceCell[this.cellWidth,this.cellHeight];
  6.        
  7.         this.table = NGUITools.FindInParents<UITable>(this.gameObject);
  8.         this.panel = NGUITools.FindInParents<UIDraggablePanel>(table.gameObject);
  9.         table.sorted = true;
  10.         this.table.columns = this.cellWidth;
  11.        
  12.         // rename objects to standard matrix direction from left -> right and from top -> down
  13.         int idx = 0;
  14.         for (int y=0;y<this.cellHeight;y++)                    
  15.         for (int x=0;x<this.cellWidth;x++)
  16.         {
  17.            
  18.             int cx = x;
  19.             int cy = y;
  20.             GlobalEditorData.cells[cx,cy] = new TSourceCell();                 
  21.              
  22.             GameObject cell = NGUITools.AddChild(this.gameObject,this.itemPrefab);
  23.            
  24.             string name_cell = string.Format("{0:0000}",idx);
  25.            
  26.             GlobalEditorData.cells[cx,cy].name = name_cell;
  27.             GlobalEditorData.cells[cx,cy].item = cell;
  28.             GlobalEditorData.cells[cx,cy].item.name = name_cell;
  29.            
  30.             string path = "/UI Root (2D)/Camera/Anchor/Source_Window/SourcePanelEmpty/SourceTable/"+GlobalEditorData.cells[cx,cy].item.name+"/ButtonEmpty_CMD";
  31.            
  32.             GameObject o = GameObject.Find(path);
  33.            
  34.             GlobalEditorData.cells[cx,cy]._cmd = (OnClick_SourceCell)o.GetComponent<OnClick_SourceCell>();                             
  35.             GlobalEditorData.cells[cx,cy]._cmd.parentName = GlobalEditorData.cells[cx,cy].item.name;
  36.             GlobalEditorData.cells[cx,cy]._cmd.label.text = cx.ToString()+"x"+cy.ToString();
  37.             GlobalEditorData.cells[cx,cy].icon = (UISlicedSprite)GlobalEditorData.cells[cx,cy]._cmd.GetComponentInChildren<UISlicedSprite>();
  38.            
  39.             idx++;
  40.            
  41.         }
  42.        
  43.        
  44.         this.table.Reposition();
  45.         this.panel.ResetPosition();
  46.        
  47.     }
  48.  

13
NGUI 3 Support / Re: Grid - Prefabs are positioned on the same position
« on: September 08, 2012, 03:58:16 AM »
grid.Reposition();

add it at and of void Start()

14
NGUI 3 Support / Re: UIInput on iOS and Android
« on: September 04, 2012, 02:57:05 PM »
I have implemented working text input, but when is released on adroind device, entered text from virtual keyboard after done, isnt included to NGUI input text field. Is it a bug or i am again forgot call any function to transfer text to textfield?

15
NGUI 3 Support / Re: Examples of Reading which button OnClick'd
« on: August 31, 2012, 02:26:29 PM »
For example:

You can create static class called i.e. GameGlobals with static variable

public static GameObject lastPressedButton;

, and then, in your button script add into OnClick method ... GameGlobals.lastPressedButton = this;

Now you have access to last pressed object ( button) from all classes.




Pages: [1] 2