Author Topic: UICamera  (Read 108321 times)

Fractalbase

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UICamera
« Reply #15 on: June 16, 2014, 09:16:41 PM »
I have an issue where I have a gameobject programmatically render my graphics, and those are viewed by the main camera created with the scene.  now with ngui in the picture, it seems that both main camera and ui camera are drawing my game graphics.  I tried one work around where I made the position of uiroot to be 3000,3000,0.  Is there a better way?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera
« Reply #16 on: June 17, 2014, 02:15:09 PM »
Yes. Adjust the culling mask on each of your camera. Main camera should not be drawing the UI, and UI camera should not be drawing the world.

savely00

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UICamera
« Reply #17 on: July 03, 2014, 01:55:17 PM »
I am using NGUI for the first time on my project and I ran into a click transparency issue.
I am using a Main Camera for the 3D world and NGUI UICamera for 2D dialogs and the title bar and menus. When I click a button on my dialog, click is also propagated to 3D objects of the scene.
Is there a way to disable this behavior? I'd like the top most dialog to process and absorb the click without further propagation to dialogs underneath and to any 3D objects in the scene.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera
« Reply #18 on: July 04, 2014, 03:01:13 PM »
The only way to stop it is to use NGUI events for both. You are likely doing your own Input.GetButton or similar checks, and that's querying Unity, not NGUI. You're bypassing NGUI. You need to attach UICamera to your main camera as well, and listen to NGUI events instead like OnPress, OnClick, etc.

wwwise

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UICamera
« Reply #19 on: September 02, 2014, 10:32:17 PM »
Problems with generic delegates(UICamera.onDrag,UICamera.onScroll,etc.).
Since I update the NGUI to 3.7.1 , there are new generic delegates to replace the old genericEventHandler GameObject.(Pro-tip#2)
So I want to modify my code , I was using the UICamera.genericEventHandler gameobject to handle OnPress,OnDrag and OnScroll message notified by UICamera in old version,and it works well.
Now I change my code using the UICamera.onPress,UICamera.onDrag and UICamera.onScroll delegates and problems come in.
The UICamera.onPress works well, but the UICamera.onDrag and UICamera.onScroll did not be called when mouse dragged or hovered on empty area(with no collider).
I suspected that some other delegates in UICamera may have the same problem -- process mouse or touch with empty target(no collider), while these problem would not happen when using the old UICamera.genericEventHandler.
After my experience, the UICamera.genericEventHandler cannot be null(you can even set an empty GameObject to it),otherwise the UICamera generic delegates would not be called properly.
« Last Edit: September 02, 2014, 11:07:28 PM by wwwise »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera
« Reply #20 on: September 03, 2014, 12:03:41 PM »
This was brought up in the support forum. Set the UICamera.fallThrough object to something, like the UICamera's game object itself, and all events will work as expected.

There can be no null objects with the new generic system. You can still use the old approach if you like.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
onMouseMove delegate
« Reply #21 on: September 18, 2014, 11:50:42 AM »
I'm about to start using UICamera's onMouseMove delegate. Thanks for adding it!

In reading the code, it seems that the delegate gets raised every update() whether there has been movement or not. I know I can test delta to see if there was any movement, but wouldn't it be more efficient to only raise the delegate when posChanged = true? Just curious. ???
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera
« Reply #22 on: September 18, 2014, 05:28:36 PM »
Yup, that makes sense to me. I'll add the check.

deevo2004

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UICamera
« Reply #23 on: October 26, 2014, 01:10:58 PM »
Is there a way to adjust the camera's event mask programmatically? 
UPDATE: I figured it out, if anyone is interested here is how I did it:

the "this.UICamera" points to the UICamera component of my main camera

  1.     public void LayerEventMaskOn(int layerMask)
  2.     {
  3.         this.UICamera.eventReceiverMask |= layerMask;
  4.     }
  5.  
  6.     public void LayerEventMaskOn(string layerName)
  7.     {
  8.         LayerEventMaskOn(1 << LayerMask.NameToLayer(layerName));
  9.     }
  10.  
  11.     public void LayerEventMaskOff(int layerMask)
  12.     {
  13.         this.UICamera.eventReceiverMask &= ~layerMask;
  14.     }
  15.  
  16.     public void LayerEventMaskOff(string layerName)
  17.     {
  18.         LayerEventMaskOff(1 << LayerMask.NameToLayer(layerName));
  19.     }
« Last Edit: October 26, 2014, 01:33:41 PM by deevo2004 »

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: UICamera
« Reply #24 on: November 10, 2014, 12:46:19 AM »
I've tried use delegate instead of - UICamera.genericEventHandler = gameObject;

  1. EventDelegate.Add(UICamera.onDrag, OnDragging);
  2.  
  3. public void OnDragging(GameObject gameObject , Vector2 delta)
  4.  {
  5.         if (delta.y < 0)
  6.         {
  7.             isScrollDown = true;
  8.         }
  9.         else
  10.         {
  11.             isScrollDown = false;
  12.         }
  13.  }

And get the error

- error CS1502: The best overloaded method match for `EventDelegate.Add(System.Collections.Generic.List<EventDelegate>, EventDelegate)' has some invalid arguments.

NGUI 3.7.4
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera
« Reply #25 on: November 10, 2014, 10:12:44 PM »
It's not an NGUI delegate. It's a C# delegate.
  1. UICamera.onDrag += OnDragging;

toqueteos

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: UICamera
« Reply #26 on: December 03, 2014, 07:10:51 AM »
Events go to... option isn't documented. What are there drawbacks, if any, for using "Colliders" instead of "Rigidbodies" (the default value)?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera
« Reply #27 on: December 04, 2014, 04:27:21 AM »
Collider approach is what you'd use for UI, since you generally have a rigidbody on the root (for performance reasons in Unity), and colliders on actual UI elements.

Rigidbody approach is what you'd use in the game. For example in Windward, each ship is made up of several different colliders, and when I hover over this ship I want a single object to receive the event -- the rigidbody -- rather than having to attach listener scripts to all colliders.

JavaV1

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UICamera
« Reply #28 on: February 06, 2015, 02:33:21 AM »
?? OnInput(text) is non-existence in UICamera  of  Next-Gen UI kit  3.7.2.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera
« Reply #29 on: February 06, 2015, 10:00:51 PM »
Always update to the latest version before posting. All my support is always for the latest version.