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

Pages: 1 [2]
16
NGUI 3 Support / Re: Draggable panel (in world)
« on: August 13, 2013, 08:32:27 PM »
You should maybe add the info here - http://www.tasharen.com/?page_id=4444

17
NGUI 3 Support / Draggable panel (in world)
« on: August 13, 2013, 05:42:35 PM »
I'm using NGUI as the GUI for an in-game computer screen, so it's 3D in the world.



  • Monitor
    • Mesh
    • Panel (UIPanel, UIDraggablePanel)
      • Item (UIDragPanelContents)
      • Item
      • Item

The problem is that UIDraggablePanel moves the object that it's attached to, so I can't get it to clip to the screen, because it's just moving the clipping window. Here's the setup:

Also, is there a way to slow the mouse drag speed?

18
NGUI 3 Support / Re: UIAnchor not allowing me to save scene
« on: June 26, 2013, 09:02:35 AM »
I managed to fix it by resetting the Panel position/scale. Somehow it had changed to strange decimal values when I duplicated it.

I also added an empty gameobject to the panel, and attached a UIAnchor to it.

One of those two changes fixed it.

19
NGUI 3 Support / UIAnchor not allowing me to save scene
« on: June 26, 2013, 06:52:32 AM »
I get an asterisk in the top-left of unity, showing that the scene is unsaved. When exiting it asks if I want to save. It does save properly, but the asterisk remains.

If I disable the UIAnchor on all of my Anchors it will save. Also, if I add a new UI with camera/anchor/panel auto-attached, it saves too (as long as my previous UIAnchor's are disabled).

20
I switched my project from Standalone to Android and now I get this error:

Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs(120,36): error CS0117: `UnityEditor.PlayerSettings' does not contain a definition for `targetGlesGraphics'

  1. #if UNITY_ANDROID || UNITY_IPHONE
  2.                 if (PlayerSettings.targetGlesGraphics == TargetGlesGraphics.OpenGLES_1_x)
  3.                 {
  4.                         maxSize = Mathf.Min(maxSize, 1024);
  5.                 }
  6.                 else
  7.                 {
  8.                         maxSize = Mathf.Min(maxSize, NGUISettings.allow4096 ? 4096 : 2048);
  9.                 }
  10. #endif

It's also in UIPanelInspector line 185.

Commenting them out allows for export...

21
NGUI 3 Support / Re: Blocking Raycast through NGUI Buttons
« on: March 03, 2013, 03:57:40 AM »
I think you have to scrap your own raycasts, as NGUI does them. Then you need a UICamera script on your MainCamera (just use NGUI > Camera Tool > Tick EV). Modify the Event Receiver Mask in UICamera to your needs.

So this (will go straight through a GUI):
  1. Ray ray = yourMainCamera.ScreenPointToRay(Input.mousePosition);
  2. RaycastHit hitInfo;
  3.  
  4. if (Physics.Raycast(ray, out hitInfo, 100f, layerMask))
  5. {
  6.         if (hitInfo.collider.gameObject.tag == "YourTag")
  7.         {
  8.                 Instantiate(obj, hitInfo.point, Quaternion.identity);
  9.         }
  10. }

Becomes this:
  1. if (UICamera.hoveredObject.tag == "YourTag")
  2. {
  3.         Instantiate(obj, UICamera.lastHit.point, Quaternion.identity);
  4. }

Now clicking a GUI button will not run the code. At least that's how I do it. Maybe there is another way.

If you want Sprites to block, then you have to add a collider to them. Also, I don't think the UI Root should be parented to the Main Camera.

And maybe wrap this in a "if (UICamera.hoveredObject != null)".

22
NGUI 3 Support / Doom 3 style GUI on world objects
« on: February 07, 2013, 03:40:09 AM »
http://youtu.be/o0_kQIlJX_E?t=4m48s

Is this possible with NGUI?

EDIT: Using the Camera Tool to make the Main Camera recieve events makes buttons/etc work fine in the the world. Are there any tips on working with NGUI in this way?

23
I just had this issue. Restarting the editor for me fixed the "Scene is being destroyed..." issue. It was strange. It had a "ghost" version of the GUI there saved from when I had stopped playing, even when I disabled every object in the editor.

When I played again I had another error:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.

The solution was adding an if condition to the OnDisable:
  1. void OnDisable()
  2. {
  3.         if (theButton)
  4.                 UIEventListener.Get(theButton).onClick -= ButtonReciever;
  5. }

But then I got this error:
Destroying object immediately is not permitted during physics trigger and contact callbacks

All I was doing was a "NGUITools.SetActive" on a panel stored in a variable that was currently enabled.

The SetActive was inside an event reciever which checks the game state, and if it's a certain state, does SetActive.

  1. void StateChanged(GameState gameState)
  2.         {
  3.                 if (gameState == GameState.GameCompleted)
  4.                 {
  5.                         NGUITools.SetActive(progressBarPanel, false);
  6.                 }
  7.         }

The state is changed by touching a trigger which increments a value, if that value == something, it sends an event. Then GameStateManager listens to the event and sends its StateChanged event.

The solution to that is here - http://www.tasharen.com/forum/index.php?topic=1417.0 (delay the SetActive by a frame)

Create an intermediary function you send it it like so:

  1. IEnumerator SetActive(GameObject go, bool state)
  2. {
  3.         yield return new WaitForSeconds(Time.deltaTime);
  4.         NGUITools.SetActive(go, state);
  5. }

Then use:
StartCoroutine(SetActive(progressBarPanel, true));

Maybe there is a better way.

24
NGUI 3 Support / Deselect an object using NGUI's event
« on: December 11, 2012, 10:26:16 PM »
I replaced this code to use NGUI's event system instead:

  1. if (Input.GetMouseButtonDown(0))
  2.                 {
  3.                         Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
  4.                         RaycastHit hit;
  5.  
  6.                         if (Physics.Raycast(ray, out hit, 200f))
  7.                         {
  8.                                 if (hit.transform.gameObject.tag == "PhysicsObj")
  9.                                 {
  10.                                         SelectObject(hit.transform.gameObject); // This is the Event sent.
  11.                                 }
  12.                                 else
  13.                                 {
  14.                                         Deselect();
  15.                                 }
  16.                         }
  17.                         else
  18.                         {
  19.                                 Deselect();
  20.                         }
  21.                 }

Basically, anything outside 200f would do the Deselect, and anything that isn't tagged "PhysicsObj", so I can just click anywhere to deselect things. How do I do this with NGUI events?

25
NGUI 3 Support / Re: GUI cameras and Image Effects
« on: August 27, 2012, 06:40:48 PM »
Ahh yes it was because I was in deferred mode. It works in forward. I have the paid version and from searching I hear it's supposed to work in deferred too?

26
NGUI 3 Support / Re: GUI cameras and Image Effects
« on: August 27, 2012, 03:39:09 PM »
Here's a video of it: http://youtu.be/WJu3Bx6X1oE

I forgot to record the mouse movement.

27
NGUI 3 Support / Re: GUI cameras and Image Effects
« on: August 27, 2012, 02:24:07 PM »
My target platform is Windows.

Note: NGUI > Create a New UI > GUI_Layer/Advanced 3D makes the effects disappear, Simple 2D doesn't.

28
NGUI 3 Support / Re: GUI cameras and Image Effects
« on: August 27, 2012, 01:50:39 PM »
It was always on the game camera. The GUI "Camera" is drawing just the GUI_Layer and has no image effects

The Main Camera isn't drawing the GUI_Layer. It has SSAO/Vignette/HDR/etc components. None of them work.

29
NGUI 3 Support / Re: GUI cameras and Image Effects
« on: August 27, 2012, 08:39:06 AM »
Are you saying it's impossible to have if you use NGUI? I can get it if the depth is higher, but no ngui...

I even tried a seperate camera just for drawing the SSAO but I don't think I'm doing it right.

30
NGUI 3 Support / Re: GUI cameras and Image Effects
« on: August 27, 2012, 04:35:17 AM »
So what's the setup for this with regards to an FPS game? I can't get SSAO working.

I have the default FPS camera and UI Root (3D)

- Player
-- Main Camera (Depth 0)

- UI Root (3D)
-- Camera (Depth 2)
--- ...

Pages: 1 [2]