Author Topic: Z-Depth resetting, why?  (Read 2282 times)

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Z-Depth resetting, why?
« on: April 17, 2013, 01:18:48 PM »
I've got the following structure:
-Panel
-- Anchor
--- Panel (Draggable)
---- UI_Grid
----- Artwork (GO with drag panel contents) and data for each artwork piece
------ Purchase Button Widget
------ Label (Cost)
------ Label (Name)
------ Background (UISprite)
------ Image (UISprite)

Background and Image are on 2 different atlases so I've adjusted Image to have a Z of -.1 to offset it towards the camera.  The problem is, when I start my game the Z gets changed to 0 by something.  Do you know what's causing this reset based on my hierarchy? Disabling UIGrid doesn't fix the problem, so I have no idea why it's changing my Z depth of the GameObject.

Here's some info that might help.. in Start I'm doing the following:
_sprite.spriteName = "Lock";
_sprite.MakePixelPerfect();

I removed these 2 lines and the Z doesn't get changed from what I want it to.
« Last Edit: April 17, 2013, 01:35:44 PM by Majicpanda »

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Re: Z-Depth resetting, why?
« Reply #1 on: April 17, 2013, 02:49:56 PM »
I fixed this by setting my z depth to -1... I found the following in UISprite:   

  1. // Sliced sprite should have dimensions divisible by 2 for best results
  2. Vector3 pos = cachedTransform.localPosition;
  3. pos.x = Mathf.RoundToInt(pos.x);
  4. pos.y = Mathf.RoundToInt(pos.y);
  5. pos.z = Mathf.RoundToInt(pos.z);
  6. cachedTransform.localPosition = pos;

So you have to be careful when using Z position and use whole numbers only.

freeglass

  • Guest
Re: Z-Depth resetting, why?
« Reply #2 on: June 08, 2013, 12:17:46 AM »
NGUI Depth Manager you requested issues can be fixed by using.

This program is a tool designed to help solve problems that occur while using NGUI Widgets Depth .

NGUI Depth Manager in AssetStore