Author Topic: Pool Manager with NGUI  (Read 2313 times)

Demigoth

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 18
    • View Profile
Pool Manager with NGUI
« on: April 21, 2014, 06:36:08 PM »
Hey ArenMook,

Do you have any experience with this? I am trying to spawn and locate a menu on top of a clickable object, but so far I have been unsuccessful, I will post some of the code I have been trying. By the way, I am using the UI follow target script on the menu, and the pool is a child of the UI object. The UI Follow Target has the game camera and the UI camera set. Any help on this would be greatly appreciated.


  1.         public Transform uiTowerMenu;
  2.         public static Transform slotPos;
  3.         public static GameObject slotPrefab;
  4.  
  5.         void OnMouseDown()
  6.         {
  7.                 //Debug.Log ("The object was clicked on!");
  8.                 slotPos = this.transform;
  9.                 slotPrefab = this.gameObject;
  10.  
  11.                 PoolManager.Pools ["GUIElements"].Spawn (uiTowerMenu, slotPos.position, Quaternion.identity);
  12.         }
  13.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pool Manager with NGUI
« Reply #1 on: April 22, 2014, 04:49:00 AM »
I don't know what your spawn function does. Keep in mind any and all UI-related instantiation should ideally be done by NGUITools.AddChild(parent, prefab).

Also OnMouseDown is not an NGUI event. It's a Unity event. NGUI's equivalent is OnPress (bool isPressed).