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

Pages: [1] 2
1
Ah, sorry. I posted this right before noticing something I hadn't seen before. Solution:

My script now looks like this:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class UpdateButtonToggleColliders : MonoBehaviour {
  5.  
  6.         public Collider[] onColliders;
  7.         public Collider[] offColliders;
  8.         public UIButton button;
  9.        
  10.         void OnClick () {
  11.                 foreach (Collider collider in onColliders) {
  12.                         collider.enabled = true;
  13.                 }
  14.                
  15.                 foreach (Collider collider in offColliders) {
  16.                         collider.enabled = false;
  17.                 }
  18.                 button.state = UIButtonColor.State.Normal;
  19.         }
  20. }

Part that solved it is the 'public UIButton button;' and the 'button.state = UIButtonColor.State.Normal;'

Hope others with this issue can see how easy it is to do, sorry for the trouble!

2
I'm working on a tutorial scene for my game. I have a script that turns off all colliders of the children in a panel of mine, then I turn on the ones I want active as users go through the tutorial.

I do want the objects to be a specific color when their colliders are disabled so they know they're not clickable (which thankfully, NGUI does standard).

All is fine except it seems when I deactivate an object with the UIButton component, then eventually turn that object's collider back on, the UIButton doesn't automatically leave the 'disabled' state. It'll change once I hover over the object, but I need it to change back to the 'Normal' state when I enable the object's collider.

Any solution to this? 

3
Okay here's the issue:

- I have objects in a grid similar to the Drag Drop example scene; they're in a clipped scroll view with the ability to drag the icons horizontally to go through them.

- Those same icons have a Playmaker FSM that is listening for a 'Press Up' action that activates another object (which I only have there because I want that object to activate when the UI icon is dragged out to my DragDropSurface)

- Any time I press the icon object in the scroll view, it won't execute the NGUI dragging component in the scroll view (so no dragging left or right thru the scrollview), and only activates the gameobject that I want activated when you drag the object to DragDropSurface.

I'm trying to make it so the scroll view/UIDragScrollView script executes first, so if you drag the objects within that panel, it'll listen to that first. If you drag the object out of the panel to the DragDropSurface, it'll execute my playmaker FSM.

Any solutions to this?

4
NGUI 3 Support / UIGrid shifting to the left when I remove object in it?
« on: October 24, 2014, 12:02:11 AM »
Hello all,

Having a strange issue with a ScrollView/Grid set up I have in my scene.

I have a scrollview object as the parent (UIPanel & UIScrollview) and an empty gameobject with UIGrid on it. I have same-sized prefabs instantiated into the grid when user clicks a button. Another button deletes individual prefabs in the grid. Once they're removed, for some reason the UIGrid shifts the Grid object's transform to the left a couple units, each time one is removed.

I call UIReposition and UIPanel refresh after the delete, still no use. Strangely, if I execute the Grid though in the inspector, it returns back to how it should be.

Really strange because I have other grids working totally fine, doing practically the same thing. Any insight on this?

5
NGUI 3 Documentation / Re: UIGrid
« on: July 28, 2014, 05:28:59 PM »
Ah gotcha, that makes sense. Thanks Aren!

6
NGUI 3 Documentation / Re: UIGrid
« on: July 26, 2014, 03:26:58 PM »
Hey Aren,

I have a UIGrid set up in a scrollbar. The children (my game icons in the grid) are active initially but on start, I have a script that removes some dynamically, based on some previous user-based input. However, because the children are all active initially, the UIGrid isn't repositioning the ones left active immediately. It will update them when I click inside of the scrollview though.

Do I just need to set some check in the update, or delay the grid's positioning for the repositioning to work correctly?

7
Thanks for the reply -

I'm now using the public string to id the path to the prefab in the Resources folder, but it's still not working. I'm using this modified script of ExampleDragDrop, and have the prefab in my Resources folder directly:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [AddComponentMenu("NGUI/Examples/Drag and Drop Item (Example)")]
  5. public class ExampleDragDropItem : UIDragDropItem
  6. {
  7.  
  8.         public string path;
  9.  
  10.         protected override void OnDragDropRelease (GameObject surface)
  11.         {
  12.                 if (surface != null)
  13.                 {
  14.                         ExampleDragDropSurface dds = surface.GetComponent<ExampleDragDropSurface>();
  15.  
  16.                         if (dds != null)
  17.                         {
  18.                                 GameObject child = NGUITools.AddChild(dds.gameObject, Resources.Load(path));
  19.  
  20.                                 Transform trans = child.transform;
  21.                                 trans.position = UICamera.lastHit.point;
  22.  
  23.                                 if (dds.rotatePlacedObject)
  24.                                 {
  25.                                         trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f);
  26.                                 }
  27.                         }
  28.                 }
  29.                 base.OnDragDropRelease(surface);
  30.         }
  31. }
  32.  

Do you spot any issues there? I have 'Empty New Gameobject"'s spawning as children of my root, but not the correct prefab. It's active and everything.. just assuming I'm missing something with how the Resources.Load is integrated in the script?

8
But I want to have only one app in the App Store, that will change the atlases loaded based on the device screen resolution. If I don't call them both there, how will it know to switch to the appropriate atlas before memory is allocated?

9
I do start with that actually, just don't understand where to instead insert Resources.Load and overwrite where it calls out the gameObject. Is it here?

  1. GameObject child = NGUITools.AddChild(dds.gameObject, prefab);

I guess I'm just confused with the dds. part before the gameObject call (bit nub there..), and how to properly call the load in the existing script. It is still a prefab.

10
NGUI 3 Support / How to use Resources.Load & UIDragDropItem script?
« on: May 29, 2014, 03:58:19 AM »
I currently instantiate various prefabs from a UI Scroll View via the handy, basically automated drag/drop system with NGUI.

I'm trying to instead have the objects loaded as a resource as they're dragged/dropped into the scene, then I'll call a Resources.UnloadUnusedAssets when they're destroyed. The UIDragDropItem script is a bit daunting and I'm not sure where to start, to get them loaded properly at the right time.

Any pointers? I'd appreciate any help!

11
Hey all,

My app is only for iPads. I recently encountered a stressful memory issue with my App that crashes iPad 2's - mostly due to textures/atlases. One solution I found was to create a reference atlas, have all widgets reference the reference, and have separate HD/SHD atlases that will be loaded AS NEEDED based on specific device screen dimensions.

I've looked through most (if not all) related topics and have gotten closer to the answer, but I can't get the build to ONLY include the specified HD or SHD atlas at runtime; it's still loading both into memory.

Background summary: I originally had the SHD atlas, duplicated it and renamed the original as my reference, resized all sprites in the atlas to 1/2 size, created HD atlas out of them, and assigned their pixel sizes accordingly.

I'm using a script I found on the forums and modified it - and all widgets point to the reference atlas. In this context SD really means HD (and HD = SHD) but it was easier to construct this way, since it's iPad only. Do you see anything wrong with this?:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class AtlasSwapper : MonoBehaviour {
  5.    
  6.     public UIAtlas Reference1;
  7.     private UIAtlas SD1;
  8.     private UIAtlas HD1;
  9.    
  10.     void Awake () {
  11.         GameObject go = Resources.Load("Atlases/Atlas1/SD1", typeof(GameObject)) as GameObject;
  12.         SD1 = go.GetComponent<UIAtlas>();
  13.  
  14.         GameObject go2 = Resources.Load("Atlases/Atlas1/HD1", typeof(GameObject)) as GameObject;
  15.         HD1 = go2.GetComponent<UIAtlas>();     
  16.     }
  17.    
  18.     void Start () {
  19.         if (Mathf.Max(Screen.currentResolution.width, Screen.currentResolution.height) >= 1024)
  20.                 Reference1.replacement = HD1;
  21.         else
  22.             Reference1.replacement = SD1;
  23.     }
  24.    
  25.     void OnDisable()
  26.     {
  27.         Reference1.replacement = SD1;
  28.                 StartCoroutine(RemoveAssets());
  29.     }
  30.        
  31.         IEnumerator RemoveAssets() {
  32.         Resources.UnloadUnusedAssets();
  33.         yield return new WaitForEndOfFrame();
  34.         }
  35. }
  36.  

I'll feel silly if it's an easy fix but for now, I can't get it to work, so I'd really appreciate any insight/help.

12
Super quick reply - thanks man.

For some of the UITextures (which were large, and existed outside of any atlas to decrease memory issues at runtime), I changed the scale of those objects in the scene, respecting the aspect ratio, as they were larger than needed when I imported them. I was going to resize them outside of Unity, but with the prior version of NGUI, I had no apparent quality issue with simply changing the scale of the object.

That may contribute to the issue (?) but they appear way bigger than even the pixel size of the widgets with 3.0.8. i.e. a 37x256 UITexture appeared to be 5x+ longer than my 1536x2048 uiroot panel.


Do sprites default to pixel perfect size now, even if they were previously scaled to not be pixel perfect? Some of my basic widgets/textures were not pixel perfect, and those are the ones that seem to be problematic. If that's the problem, do you know how I could work around that?


13
Hey guys,

I upgraded my project successfully to NGUI 3.0.8 f4 from 2.6.4, however all of my previous UITextures (now UISprites) are far too large, and even some of my basic widgets are resized. Does this have to do with the new Dimensions field in the Inspector?

I didn't follow perfect rules for anchoring in the past, but it worked great prior to this upgrade. My UI Root is still at 1536 fixed size as before.

I'm sure I could just go to a backup of mine and resize all of the UI components again to how they were before, but that'd take a couple hours. Anyone have this issue & find a solution?

14
Hey guys,

I'm in a pickle. I have an NGUI sprite with two animations: Show & Hide (they just move the sprite on and off screen on the X coordinate). I'm trying to link them to a 3D object that's created from a prefab, so when the object is tapped, the "Show" animation plays.

Even further, I'm trying to set it up so if anything OTHER than the object is pressed, the animation "Hide" will play.

Do you guys know if this is possible and how I may go about figuring it out? I'm at my wit's end at the moment and it seems so simple - but I'm not incredibly experienced so I can't quite figure it out. Any help would be appreciated!

15
NGUI 3 Support / Re: Drag & Drop prefab: keep animation?
« on: August 16, 2013, 01:47:00 PM »
Yeah, I have the scale of multiple game objects set to the slider. But you are correct, I think it's more of a Playmaker question  ;D

Pages: [1] 2