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

Pages: [1]
1
NGUI 3 Support / Re: Problem with NGUI and GameObject touch
« on: February 23, 2017, 03:01:44 PM »
Found it, I set the main camera depth to -1 and now works ;)

2
NGUI 3 Support / Re: Problem with NGUI and GameObject touch
« on: February 23, 2017, 02:01:19 PM »
My cameras config:

MainCamera -> UICamera (component)
    - Event type = 2d world

UI Root -> UICamera
    - Event type = 3d ui

3
NGUI 3 Support / Re: Problem with NGUI and GameObject touch
« on: February 23, 2017, 12:06:58 PM »
Hi,

I'm having the same issue too, and I really try to figure out what to do, but I still cant make it work.

I have a button and and object over my button as you can see in my picture.

When I hover the button in the very right, outside of the object works (red line),
Inside the object (blue line), I'm not able to click, the click goes to the object.

I note when I hover the button in the very corner the button hover effects works, but not when is inside the blue line.
I tough this was something related with the Deph but is not since one is an game object and the other the ui (correct)?

I create a simple script for my button click event
  1. using UnityEngine;
  2.  
  3. public class Menu : MonoBehaviour
  4. {
  5.         private UIButton MyButton;
  6.        
  7.         private void Awake()
  8.     {
  9.         MyButton = GameObject.Find("MyButton").GetComponent<UIButton>();
  10.         }
  11.        
  12.         private void Start()
  13.     {
  14.         EventDelegate.Set(MyButton.onClick, delegate () { Test(); });
  15.     }
  16.        
  17.         private void Test()
  18.         {
  19.                 Debug.Log("test button action");
  20.         }
  21. }
  22.  

And one for my object:

  1. using UnityEngine;
  2.  
  3. public class MyObject : MonoBehaviour
  4. {
  5.     void OnPress(bool isPressed)
  6.     {
  7.         if (isPressed)
  8.         {
  9.             Debug.Log("my object click");
  10.         }
  11.     }
  12. }
  13.  

Anybody have any idea what is the problem?

Thanks :)

4
NGUI 3 Support / Wrong position for child objects
« on: June 30, 2016, 02:06:43 PM »
Guys a Have a question about child components position.

My widget structure is like:
  1. - UI Sprite
  2.     - Button
  3.         - Label
  4.  
  5.  

Every time, when I try to create a dynamic button inside the sprite, the button "spawn" in the middle of the sprite. Why?
Why the button don't go for the position X = 0 and Y = 0 ?

Here is how I create my button:
  1. private void CreateButtonUI(GameObject parent, string name, int width, int height, string label, string atlas = "Atlas/ui")
  2.     {
  3.         GameObject main = NGUITools.AddChild(parent);
  4.         main.name = name;
  5.  
  6.         // Attach sprite to receive atlas
  7.         UISprite background = main.AddComponent<UISprite>();
  8.         background.height = height;
  9.         background.width = width;
  10.         background.atlas = Resources.Load<UIAtlas>(atlas);
  11.         background.depth = 1;
  12.  
  13.         // Add collider to the button
  14.         BoxCollider bc = main.AddComponent<BoxCollider>();
  15.         bc.size = new Vector3(width, height, 0);
  16.         bc.isTrigger = true;
  17.  
  18.         // Attach button component
  19.         UIButton bt = main.AddComponent<UIButton>();
  20.  
  21.         // Set sprite state
  22.         bt.tweenTarget = bt.gameObject;
  23.         bt.normalSprite = "btn_brown";
  24.         bt.hoverSprite = "btn_green";
  25.         bt.pressedSprite = "btn_red";
  26.         bt.disabledSprite = "btn_gray";
  27.  
  28.         // Set text label
  29.         GameObject btLabel = NGUITools.AddChild(main);
  30.         UILabel lb = btLabel.AddComponent<UILabel>();
  31.         lb.bitmapFont = Resources.Load<UIFont>("Fonts/calibri");
  32.         lb.depth = 1;
  33.         lb.width = 142;
  34.         lb.height = 28;
  35.         lb.text = label;
  36.         lb.alignment = NGUIText.Alignment.Center;
  37.         lb.fontSize = lb.bitmapFont.defaultSize;
  38.         lb.effectStyle = UILabel.Effect.Shadow;
  39.         lb.applyGradient = false;
  40. }
  41.  

Pages: [1]