Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Malzbier on August 06, 2012, 06:13:08 AM

Title: UIAnchor and UIStretch wrong update in editor
Post by: Malzbier on August 06, 2012, 06:13:08 AM
I have some wired behavior with the UIAnchor and UIStretch components inside of the editor.

I have a UIAnchor set to TopLeft at a resolution of 480X320

Is it possible that this scripts are using the scene view in this case because it does not fit at all with the game view.

A nearly the same problem i have with the scale of UIStretch

My understanding is that this should be only reacting to the Game view and not the Scene view.
The current Behavior makes testing very annoying.

PS: I'm using a UIRoot with the settings  Automatic = True and Manual Height = 480

Greetings Malzbier
Title: Re: UIAnchor and UIStretch wrong update in editor
Post by: ArenMook on August 06, 2012, 02:52:44 PM
Make sure that the size of your game window is actually able to fit the dimensions properly. Unity screen dimensions may also be delayed by one frame at edit time. If you try resizing the game window you will notice that the UI will not scale with it as you would expect to see it (and as it does if you're playing). This is because Unity is simply not sending out any update events. Without updates, there is nothing to tell the UI that the screen has changed and that it needs to be updated.
Title: Re: UIAnchor and UIStretch wrong update in editor
Post by: Malzbier on August 07, 2012, 03:06:48 AM
The updating is not the problem , the problem is that the UIAnchor and UIStretch components are using the size of the scene window instead of the game window.

The problem is that i have to build a layout that fits for the resolution of 480X320 and if i change over to my scene view , this components are using the size of the scene view size to reposition and recalculate size.

Im not sure if it is related to this but the variable MScreenSize of UIPanel is changing if i go over to the scene view and save.

and resize the scene view to the same dimensions of the game view is not an option...
Title: Re: UIAnchor and UIStretch wrong update in editor
Post by: ArenMook on August 07, 2012, 12:01:18 PM
That doesn't happen here, so I don't know what to tell you.
Title: Re: UIAnchor and UIStretch wrong update in editor
Post by: Malzbier on August 08, 2012, 03:32:01 AM
You are using Camera.pixelRect to determine the size of the screen and so i wrote a debug script:
(attached to the GUI camera)
  1. using UnityEngine;
  2. using System.Collections;
  3. [ExecuteInEditMode]
  4. public class CameraDebug : MonoBehaviour {
  5.  
  6.         // Update is called once per frame
  7.         void Update () {
  8.        
  9.                 if(this.camera)
  10.                 {
  11.                         Debug.Log(this.camera.pixelRect);
  12.                 }
  13.                
  14.         }
  15. }

Game View : (left:0.00, top:0.00, width:480.00, height:320.00)
Svene View: (left:0.00, top:0.00, width:640.00, height:480.00)

thats looks like to be the problem.
Title: Re: UIAnchor and UIStretch wrong update in editor
Post by: Malzbier on August 09, 2012, 03:07:11 AM
The same problem at a new project with NGUI 2.1.4.
Title: Re: UIAnchor and UIStretch wrong update in editor
Post by: ArenMook on August 09, 2012, 02:03:57 PM
Thanks, it's on the list of things to look into.