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

Pages: [1]
1
Thank you very much for your FAST replay  ;D and please accept my apologies for the late reply I was out of the office for Boxing day in London :-[

Your suggestion is working !

I thought you have to point to the GetComponent<UISprite>() every time otherwise NGUI don’t know what Child NGUI  have to change.. I still don’t know why it was moving but your solution is working!

Thanks and have a great new year from the Netherlands!!



2
Please help me. I think I mix things up.
I’m trying to anchor a prefab object on a not moving panel.
I created a prefab from the “colored Button”
Spawn the prefab with:
  1.  
  2. public GameObject PrefabButton; // Attached the colored Button.prefab
  3. public GameObject TargetPanel;  // Attached the Panel from the UI Root Hirachie
  4.  
  5. void Start ()
  6. {
  7.     GameObject PrefabSpawnButton = NGUITools.AddChild(TargetPanel, PrefabButton) as GameObject;
  8.     // Till this point everything goes well. But the Anchors are on type : none
  9.  
  10.             PrefabSpawnButton.GetComponent<UISprite>().topAnchor.target = TargetPanel.transform;
  11.             PrefabSpawnButton.GetComponent<UISprite>().bottomAnchor.target = TargetPanel.transform;
  12.             PrefabSpawnButton.GetComponent<UISprite>().leftAnchor.target = TargetPanel.transform;
  13.             PrefabSpawnButton.GetComponent<UISprite>().rightAnchor.target = TargetPanel.transform;
  14.  
  15.             PrefabSpawnButton.GetComponent<UISprite>().topAnchor.absolute = -60;
  16.             PrefabSpawnButton.GetComponent<UISprite>().bottomAnchor.absolute = -124;
  17.             PrefabSpawnButton.GetComponent<UISprite>().leftAnchor.absolute = 20;
  18.             PrefabSpawnButton.GetComponent<UISprite>().rightAnchor.absolute = 84;
  19. }
  20.  

BTW : This script is attached to the Panel.
In the inspector the “anchors” are now on “Unified” and the anchor positions are right. But the “PrefabSpawnButton” is (moving) transforming in the X posive and Y negative and I can’t reset or stop it.
 

3
Solved, It was to simple. Thanks Tasharen!

-> drag buttonslection.js to Panel
add to Button object from menu -> GameComponent -> NGUI -> Interaction -> Button Message
-> drag Panel into : Target :
-> Change funtion name : YourButtonFuntion
-> Trigger : OnClick

buttonslection.js
  1. Function YourButtonFuntion()
  2.   {
  3.   // Everything you like todo :P
  4.   }
  5.  
  6.  
  7.  



4
Try to make a several buttons working with an external JAVAscript.
Can anybody tell/help me what I’m doing wrong? :-\

Steps done before:

A. Create 2 buttons with the Widget Tool -> Template “Button” with Background “abcd.jpg”
B. Renamed the Button to “Button1” and “Button2”
C. Create a javascript buttonslection.js and attached this to " UI Root 2D"

Now I’m try to find out what button is pressed and make an action on the buttons..


  1. function Update ()
  2.                 {              
  3.                 if (UIEventListener.Get(GameObject.Find("Button1")).onClick != null)
  4.                         {
  5.                         Debug.Log ("do what you have todo is button 1 is pressed");
  6.                         // Need to force Button 2 into NOT highlighted (change UIButton state -> xx?)
  7.                         // Need to force Button 1 into (change UIButton state -> Pressed?)
  8.                         }
  9.                 if (UIEventListener.Get(GameObject.Find("Button2")).onClick != null)
  10.                         {
  11.                         Debug.Log ("do what you have todo is button 2 is pressed");
  12.                         // Need to force Button 1 into NOT highlighted (change UIButton state -> xx?)
  13.                         // Need to force Button 2 into (change UIButton state -> Pressed?)
  14.                         }
  15.                 }
  16.  


Pages: [1]