Author Topic: [Solved]Alpha 0 on gameobject's children: not working?  (Read 2524 times)

Somoraze

  • Guest
[Solved]Alpha 0 on gameobject's children: not working?
« on: March 25, 2013, 05:03:08 AM »
Hi,

I found this thread (http://www.tasharen.com/forum/index.php?topic=311.0) to add an alpha value to a gameObject: I would like to hide a Panel with all its children (2 labels, and 1 sprite), but its children are not recognized by NGUI, would you know why? (GameObject.name works well though) :

  1.         private static void SetNguiVisible(GameObject gameObject, bool visible)
  2.     {
  3.         //Debug.Log("setNgui");//works fine
  4.         Debug.Log("gameObject.GetComponents<UIWidget>() : "+gameObject.GetComponents<UIWidget>().Length); //output 0
  5.         foreach(UIWidget widget in gameObject.GetComponents<UIWidget>()) //same with var widget
  6.         {
  7.                 Debug.Log("A");//does not show up
  8.             widget.enabled = visible;
  9.         }
  10.     }

I call it like this :
  1. //in the child script
  2. void OnClick(){
  3.         startTween(0);
  4. }
  5.  
  6.  
  7. //in the parent script
  8. protected string changeIndex(int indexp){
  9.         switch(indexp){
  10.                 case 0:
  11.                         return "PanelLevel";
  12.                                 //...
  13.                                
  14.                                
  15.                                
  16. protected void startTween(int indexp){
  17.                
  18.                 string newPanel = changeIndex(indexp);
  19.                 string oldPanel = changeIndex(currentIndex);
  20.                
  21.                 if (currentIndex != indexp){
  22.                         SetNguiVisible(GameObject.Find(oldPanel), false);
  23.                         //...

Would you have any idea?

Thanks
« Last Edit: March 25, 2013, 07:47:17 AM by Somoraze »

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Re: Alpha 0 on gameobject's children: not working?
« Reply #1 on: March 25, 2013, 05:23:38 AM »
Hi!

Why not just use:

  1. TweenAlpha.Begin(gameObject, duration, alpha)

for change alpha?

Somoraze

  • Guest
Re: Alpha 0 on gameobject's children: not working?
« Reply #2 on: March 25, 2013, 07:46:57 AM »
argh, it works better, thanks!