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.


Topics - CoderBear

Pages: [1]
1
Hi I am trying to spawn an NGUI sprite (not a NGUI Unity2D sprite) only when needed.  It for some reason normally spawns at (0,0,0) despite the prefabs set position.  So I set it in code and then gets a really weird position  as shown below in the picture.  Here is the code used:
  1. NGUITools.AddChild (panel.gameObject, mobFollower); // Spawn and add to panel so it shows up in the scene on top
  2. spawnedMobs.Add (GameObject.FindWithTag ("follower"));  // Add to list of spawned enemies for the current combat.
  3. Debug.Log ("Vector3 position of pfFollower (clone) was " + GameObject.FindWithTag ("follower").transform.position);
  4. GameObject.FindWithTag ("follower").transform.Translate (MOB1_POS);  // Place newly spawned object at the correct spot on the screen.
  5. Debug.Log ("Vector3 position of pfFollower (clone) is " + GameObject.FindWithTag ("follower").transform.position);
  6.  


As you can see the code console itself says the code worked, but the inspector tells a different story.  If I don't do anything it just spawns at center (0,0,0).

2
NGUI 3 Support / Weird Issue with Sprites (Urgent!)
« on: April 04, 2014, 06:23:06 PM »
I'm having an issue and bare with me due to the posting limit it is going to have 2 replies under it.  Please note all included pics are running the game is running in the editor as this is when the issue is occurring.

I have setup the scene to show the character with the UI like in the NGUI example X (ARGZ NGUI001 & ARGZ NGUI002).  and in the editor it appears as it should.  Yet it does not show up as it should in game (ARG NGUI 002).




PlayerObject is a persistent from the moment the game starts up, but the sprite attached is invisible until need and code shows it when the scene above is started and hides it when it ends.

3
Hi there, I know that you can do radio button root and it will affect multiple check boxes.  However I need to do it with multiple roots but not sure how to go about this.

For example if item 1 is checked, and the Item 3 is pressed and becomes checked, item 1 goes off, and if then item 5 is pressed, item 3 goes off.

My hierarchy looks like this
-UiGrid
  -Item1 (not a pane)
    - Checkbox
  -Item2 (not a pane)
    - Checkbox
  -Item3 (not a pane)
    - Checkbox
  -Item4 (not a pane)
    - Checkbox
  -Item5 (not a pane)
    - Checkbox
  -Item6 (not a pane)
    - Checkbox

yet RadioButtonRoot can only be attached to a single item.

I had tried to do this, but it does't do anything.
  1. void EquipAndy()
  2.     {
  3.         string itemId = AndysApplesAssets.ANDY_GOOD.ItemId;
  4.  
  5.         if (andy.equipCheck.isChecked)
  6.         {
  7.             if (!StoreInventory.IsVirtualGoodEquipped(itemId))
  8.             {
  9.                 StoreInventory.EquipVirtualGood(itemId);
  10.                 kelly.equipCheck.isChecked = false;
  11.                 ninja.equipCheck.isChecked = false;
  12.                 pig.equipCheck.isChecked = false;
  13.                 pirate.equipCheck.isChecked = false;
  14.                 wizard.equipCheck.isChecked = false;
  15.             }
  16.         }
  17.     }

Any and all help will be greatly appreciated.

4
NGUI 3 Support / Rotating sprite not rotating visually.
« on: May 02, 2013, 04:27:43 PM »
Ok so I have a sprite that I need to rotate in a single spot along the Z axis.  When the program is running you can see the Z is in fact in a circle, but visually the Sprite is not following suit.  What am I doing wrong as this happens without issue in the game that is using 2D toolkit.

I would include code but the code itself is functioning properly and it is attached to the object.

I also tried using tween animation and nothing.

5
NGUI 3 Support / [SOLVED] Text not appearing on device
« on: April 20, 2013, 02:09:49 PM »
Ok this is weird.  When I run this one screen on the device it is not showing any of the text. (NGUI006)  But clearly it is showing up in the editor and when one on device via unity remote. (NGUI007 & 008)  Any ideas as to why this is happening?

Oh and before some gives the "I did something wrong" response.  This is the only screen it is occurring on.  I point you to another screen in the game also built in pure NGUI. (NGUI009)

6
Ok so here is a doozy of a conundrum.  I create my list via code and it all gets created fine.  However, when I try to go and scroll the list it does not scroll.  I've attached a picture of what the editor looks like at run-time.  Below is the code.

Why would it be doing this when it it works perfectly fine when I just setup it up in the editor?  As I did when I made a simple Stat page (I rather not have to make 45 of these by hand.)

Would be especially nice if one of the devs might offer their suggestions.

  1.     public Achievement[] Achievements;
  2.     public AudioClip EarnedSound;
  3.        
  4.         /*--- NGUI Elements ---*/
  5.         public UIDraggablePanel MasterDragPanel;
  6.         UIGrid MasterGrid;
  7.         UIDragPanelContents dragPanelContents;
  8.         public Transform achievePrefab;
  9.         GameObject newAchievementObj = null;
  10.  
  11.     private int currentRewardPoints = 0;
  12.     private int potentialRewardPoints = 0;
  13.     private Vector2 achievementScrollviewLocation = Vector2.zero;
  14.        
  15.         void Start()
  16.         {      
  17.                 MasterGrid = this.transform.GetComponent<UIGrid>();
  18.                 AchievementDisplay display = achievePrefab.gameObject.GetComponent<AchievementDisplay>();
  19.                
  20.                 for (int j = 0; j < Achievements.Length-1; j++) {
  21.                         // Get UI Label for name in child obj and set it to Achievments[j].name
  22.                         // Do this for description, points, and target
  23.                         display.nameLabel.text = Achievements[j].Name;
  24.                         display.descriptionLabel.text = Achievements[j].Description;
  25.                         display.pointsLabel.text = Achievements[j].RewardPoints.ToString();
  26.                         display.targetLabel.text = Achievements[j].getProgress().ToString() + " / " + Achievements[j].TargetProgress.ToString();
  27.                         dragPanelContents = achievePrefab.GetComponent<UIDragPanelContents>();
  28.                         dragPanelContents.draggablePanel = MasterDragPanel;
  29.                        
  30.                         newAchievementObj = NGUITools.AddChild(MasterGrid.gameObject, achievePrefab.gameObject);
  31. //                      dragPanelContents = newAchievementObj.GetComponent<UIDragPanelContents>();
  32. //                      dragPanelContents.draggablePanel = MasterDragPanel;
  33.                 }
  34.                
  35.                 MasterGrid.Reposition();
  36.                 MasterGrid.transform.position.Set(-195,245,0);
  37.                                
  38.             ValidateAchievements();
  39.         UpdateRewardPointTotals();
  40.         }

7
Note: I know of the hard brute force way of doing it.  However I am wondering if anyone has some insight to a more optimized way of handling this.

So I am trying to make an achievement list that is adapted to NGUI.  As the recent version of unity has made my once function sections using scroll-view no longer scroll.  My question is I understand how to dynamically generate items on a grid parented to a draggable panel.

The problem I am having is that the prefab has 5 child objects in it.  My question is how would I go about accessing the child objects?  Since I have to make multiple copies and need to fill in info.  I have included a picture of my editor to give the visual representation of what I am talking about.

  1.         /*--- NGUI Elements ---*/
  2.         UIGrid MasterGrid;
  3.         UIDragPanelContents dragPanelContents;
  4.         public Transform achievePrefab;
  5.         GameObject newAchievementObj;
  6.  
  7.  
  8. void Start() {
  9. MasterGrid = this.transform.GetComponent<UIGrid>();
  10.                 MasterDragPanel = MasterGrid.transform.parent.GetComponent<UIDraggablePanel>();
  11.                
  12.                 for (int j = 0; j < Achievements.Length; j++) {
  13.                         for (int k = 0; k < achievePrefab.GetChildCount; k++) {
  14.                                 // Get UI Label for name in child obj and set it to Achievments[j].name
  15.                                 // Do this for description, points, and target
  16.                                
  17.                         }
  18.                        
  19.                        
  20.                         newAchievementObj = NGUITools.AddChild(MasterGrid, achievePrefab);
  21.                         dragPanelContents = newAchievementObj.GetComponent<UIDragPanelContents>();
  22.                         dragPanelContents.draggablePanel = MasterDragPanel;
  23.                 }
  24. ...
  25. }
  26.  

8
NGUI 3 Support / Images no longer Displaying on Device (only editor)
« on: April 02, 2013, 02:08:05 PM »
I had a working menu with NGUI.  It displayed properly when both running from the editor and running on Android Devices (I'm using a Nexus 7 and an Atrix 4G).

I have recently updated to v2.5 of NGUI and Unity 4.1 and now when it is pushed to the device and run it displays only a black screen.  However it is only not displaying the sprites, the functionality of the buttons are still present because it will still make a sound and activate scripts taking me to the other scenes when corresponding buttons are pressed.

Why exactly is this happening and what can I do to fix it?

Pages: [1]