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

Pages: [1] 2
1
NGUI 3 Support / Re: Unity 5.2 crash (focus/save)
« on: October 04, 2015, 05:20:09 AM »
I updated to Unity 5.2.1p2 and NGUI 4.9.4 (deleted NGUI folder first). Now it doesn't crash anymore. hurray

2
NGUI 3 Support / Re: Unity 5.2 crash (focus/save)
« on: October 01, 2015, 04:01:56 AM »
I notice an error when using Unity 5.1.3, maybe it has something to do with it all???

1.) Deleted NGUI Folder
2.) Downloaded latest NGUI

NOTE:
NGUI/Editor files in package
FreeType.dylib (should it be named FreeType64.dylib)?

3.) NGUI -> Open -> Font Maker

Error: Assets/NGUI/Editor/FreeType64.dylib is missing

4.) Terminal goto Assets/NGUI/Editor/
   cp FreeType.dylib FreeType64.dylib
   Check that it has same permissions
   
5.) Back to Unity, now dialouge popup

Copying /Volumes/Work/Unity/xRockets/Assets/NGUI/Editor/FreeType64.dylib to /usr/local/lib/FreeType64.dylib: Permission denied

6.) Back to Terminal,
   sudo cp FreeType64.dylib /usr/local/lib/FreeType64.dylib
   
7.) Back to Unity
   Cancel the dialouge and now Font Maker looks good
   
8.) Select font
   Unity now crashes

My crash log https://dl.dropboxusercontent.com/u/27479515/forums/nguicrash1.txt

3
NGUI 3 Support / Re: Unity 5.2 crash (focus/save)
« on: October 01, 2015, 03:16:15 AM »
I've submitted my project to Unity as an bugg. Will add this info about the dynamic fonts.

4
NGUI 3 Support / Re: Unity 5.2 crash (focus/save)
« on: September 28, 2015, 03:04:48 AM »
Hard to reproduce from scratch. Created a new scene and added some stuff, no issue. Reopened my main scene and crash instantly. Been building on the project for over 1 year so a lot of plugin updates issue? Tried to reimport all assets as well.

When opening my scene the output shows a lot of errors. Pressing clear will remove them.

  1. ArgumentOutOfRangeException: Argument is out of range.
  2. Parameter name: index
  3. System.Collections.Generic.List`1[UIPanel].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
  4. UILabel.OnFontChanged (UnityEngine.Font font) (at Assets/NGUI/Scripts/UI/UILabel.cs:985)
  5. UnityEngine.Font.InvokeTextureRebuilt_Internal (UnityEngine.Font font)
  6. UnityEngine.Font:RequestCharactersInTexture(String, Int32, FontStyle)
  7. NGUIText:Update(Boolean) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:130)
  8. NGUIText:Update() (at Assets/NGUI/Scripts/Internal/NGUIText.cs:92)
  9. UILabel:UpdateNGUIText() (at Assets/NGUI/Scripts/UI/UILabel.cs:2000)
  10. UILabel:OnFill(BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/UI/UILabel.cs:1708)
  11. UIWidget:UpdateGeometry(Int32) (at Assets/NGUI/Scripts/Internal/UIWidget.cs:1461)
  12. UIPanel:UpdateWidgets() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1601)
  13. UIPanel:UpdateSelf() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1242)
  14. UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1203)
  15. UIPanel:Refresh() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1716)
  16. UILabel:OnFontChanged(Font) (at Assets/NGUI/Scripts/UI/UILabel.cs:986)
  17. UnityEngine.Font:RequestCharactersInTexture(String, Int32, FontStyle)
  18. NGUIText:Update(Boolean) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:130)
  19. NGUIText:Update() (at Assets/NGUI/Scripts/Internal/NGUIText.cs:92)
  20. UILabel:UpdateNGUIText() (at Assets/NGUI/Scripts/UI/UILabel.cs:2000)
  21. UILabel:OnFill(BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/UI/UILabel.cs:1708)
  22. UIWidget:UpdateGeometry(Int32) (at Assets/NGUI/Scripts/Internal/UIWidget.cs:1461)
  23. UIPanel:UpdateWidgets() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1601)
  24. UIPanel:UpdateSelf() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1242)
  25. UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1203)
  26. UIPanel:Refresh() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1716)
  27. UILabel:OnFontChanged(Font) (at Assets/NGUI/Scripts/UI/UILabel.cs:986)
  28. UnityEngine.Font:RequestCharactersInTexture(String, Int32, FontStyle)
  29. NGUIText:Update(Boolean) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:130)
  30. NGUIText:Update() (at Assets/NGUI/Scripts/Internal/NGUIText.cs:92)
  31. UILabel:UpdateNGUIText() (at Assets/NGUI/Scripts/UI/UILabel.cs:2000)
  32. UILabel:OnFill(BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/UI/UILabel.cs:1708)
  33. UIWidget:UpdateGeometry(Int32) (at Assets/NGUI/Scripts/Internal/UIWidget.cs:1461)
  34. UIPanel:UpdateWidgets() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1601)
  35. UIPanel:UpdateSelf() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1242)
  36. UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1203)
  37. UIPanel:Refresh() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1716)
  38. UILabel:OnFontChanged(Font) (at Assets/NGUI/Scripts/UI/UILabel.cs:986)
  39. UnityEngine.Font:RequestCharactersInTexture(String, Int32, FontStyle)
  40. NGUIText:Update(Boolean) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:130)
  41. NGUIText:Update() (at Assets/NGUI/Scripts/Internal/NGUIText.cs:92)
  42. UILabel:UpdateNGUIText() (at Assets/NGUI/Scripts/UI/UILabel.cs:2000)
  43. UILabel:OnFill(BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/UI/UILabel.cs:1708)
  44. UIWidget:UpdateGeometry(Int32) (at Assets/NGUI/Scripts/Internal/UIWidget.cs:1461)
  45. UIPanel:UpdateWidgets() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1601)
  46. UIPanel:UpdateSelf() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1242)
  47. UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1203)
  48. UIPanel:Refresh() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1716)
  49. UILabel:OnFontChanged(Font) (at Assets/NGUI/Scripts/UI/UILabel.cs:986)
  50. UnityEngine.Font:RequestCharactersInTexture(String, Int32, FontStyle)
  51. NGUIText:Update(Boolean) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:130)
  52. NGUIText:Update() (at Assets/NGUI/Scripts/Internal/NGUIText.cs:92)
  53. UILabel:UpdateNGUIText() (at Assets/NGUI/Scripts/UI/UILabel.cs:2000)
  54. UILabel:ProcessText(Boolean, Boolean) (at Assets/NGUI/Scripts/UI/UILabel.cs:1216)
  55. UILabel:ProcessText() (at Assets/NGUI/Scripts/UI/UILabel.cs:1177)
  56. UILabel:get_processedText() (at Assets/NGUI/Scripts/UI/UILabel.cs:832)
  57. UILabel:OnFill(BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/UI/UILabel.cs:1705)
  58. UIWidget:UpdateGeometry(Int32) (at Assets/NGUI/Scripts/Internal/UIWidget.cs:1461)
  59. UIPanel:UpdateWidgets() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1601)
  60. UIPanel:UpdateSelf() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1242)
  61. UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1203)
  62. UIPanel:Refresh() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1716)
  63. UILabel:OnFontChanged(Font) (at Assets/NGUI/Scripts/UI/UILabel.cs:986)
  64. UnityEngine.Font:RequestCharactersInTexture(String, Int32, FontStyle)
  65. NGUIText:Update(Boolean) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:130)
  66. NGUIText:Update() (at Assets/NGUI/Scripts/Internal/NGUIText.cs:92)
  67. UILabel:UpdateNGUIText() (at Assets/NGUI/Scripts/UI/UILabel.cs:2000)
  68. UILabel:OnFill(BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/UI/UILabel.cs:1708)
  69. UIWidget:UpdateGeometry(Int32) (at Assets/NGUI/Scripts/Internal/UIWidget.cs:1461)
  70. UIPanel:UpdateWidgets() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1601)
  71. UIPanel:UpdateSelf() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1242)
  72. UIPanel:LateUpdate() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1203)
  73.  

Also updated to latest 3.9.3 and Unity 5.2.1
The error report: https://dl.dropboxusercontent.com/u/27479515/forums/nguicrash.txt

5
NGUI 3 Support / Unity 5.2 crash (focus/save)
« on: September 21, 2015, 01:36:39 PM »
I've updated Unity to 5.2. When opening my project (from 5.1.3p0) it crashes. Seems to be crashing if I select another app and then focus back to Unity. Also when press Play or build it crashes.

Don't know if its Unity or the NGUI plugin that creates the issue. I've also opened another project (with NGUI) that works fine. But when trying to figure out the logs it's NGUI everywhere.

Log file (11mb) https://dl.dropboxusercontent.com/u/27479515/forums/crashlog%20unity%205.2.txt

Last lines

  1. (Filename: Assets/NGUI/Scripts/Internal/NGUIText.cs Line: 130)
  2.  
  3. NullReferenceException: Object reference not set to an instance of an object
  4.   at NGUIText.Update (Boolean request) [0x000f6] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/Internal/NGUIText.cs:130
  5.   at NGUIText.Update () [0x00000] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/Internal/NGUIText.cs:92
  6.   at UILabel.UpdateNGUIText () [0x00315] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UILabel.cs:2046
  7.   at UILabel.ProcessText (Boolean legacyMode, Boolean full) [0x001c5] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UILabel.cs:1237
  8.   at UILabel.ProcessText () [0x00000] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UILabel.cs:1197
  9.   at UILabel.get_processedText () [0x0004c] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UILabel.cs:845
  10.   at UILabel.OnFill (.BetterList`1 verts, .BetterList`1 uvs, .BetterList`1 cols) [0x000a6] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UILabel.cs:1742
  11.   at UIWidget.UpdateGeometry (Int32 frame) [0x00081] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/Internal/UIWidget.cs:1461
  12.   at UIPanel.UpdateWidgets () [0x0023c] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UIPanel.cs:1596
  13.   at UIPanel.UpdateSelf () [0x0000c] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UIPanel.cs:1237
  14.   at UIPanel.LateUpdate () [0x00035] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UIPanel.cs:1198
  15.   at UIPanel.Refresh () [0x0001d] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UIPanel.cs:1711
  16.   at UILabel.OnFontChanged (UnityEngine.Font font) [0x000ce] in /Volumes/Work/Unity/xRockets/Assets/NGUI/Scripts/UI/UILabel.cs:1001
  17.   at UnityEngine.Font.InvokeTextureRebuilt_Internal (UnityEngine.Font font) [0x00000] in <filename unknown>:0
  18.  
  19. (Filename: Assets/NGUI/Scripts/Internal/NGUIText.cs Line: 130)
  20.  
  21. Receiving unhandled NULL exception
  22. Launching bug reporter
  23. Obtained 18 stack frames.
  24. #0  0x00000000000100 in (Unknown)
  25. #1  0x0000010141d1a7 in AssetInterface::WriteRevertAssets(std::set<UnityGUID, std::less<UnityGUID>, std::allocator<UnityGUID> > const&, std::set<UnityGUID, std::less<UnityGUID>, std::allocator<UnityGUID> > const&)
  26. #2  0x000001019a28df in Application::SaveScene(std::string, bool)
  27. #3  0x000001019a2dcb in Application::FileMenuSave(bool)
  28. #4  0x007fff95a31cd7 in _os_activity_initiate
  29. #5  0x007fff8984feb1 in -[NSApplication sendAction:to:from:]
  30. #6  0x007fff8984fc4e in -[NSMenuItem _corePerformAction]
  31. #7  0x007fff8984f97c in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:]
  32. #8  0x007fff95a31cd7 in _os_activity_initiate
  33. #9  0x007fff8984e8ad in -[NSMenu performKeyEquivalent:]
  34. #10 0x007fff8984da6f in -[NSApplication _handleKeyEquivalent:]
  35. #11 0x007fff8975883a in -[NSApplication sendEvent:]
  36. #12 0x00000101be75b1 in -[EditorApplicationPrincipalClass sendEvent:]
  37. #13 0x007fff89681b68 in -[NSApplication run]
  38. #14 0x007fff895fe244 in NSApplicationMain
  39. #15 0x00000101be7c96 in EditorMain(int, char const**)
  40. #16 0x00000101be84e9 in main
  41. #17 0x00000100002264 in start
  42. Launching external process: /Applications/Unity 5.2/Unity.app/Contents/BugReporter/Unity Bug Reporter.app/Contents/MacOS/unity.bugreporter.exe
  43.  

6
NGUI 3 Support / Re: NGUIText.Prepare crash iOS
« on: September 11, 2015, 06:20:12 AM »

public UILabel txtScore;

Is connected thru Unity GUI.

When removing the line txtScore.text = "0"; it works all the time.

7
NGUI 3 Support / NGUIText.Prepare crash iOS
« on: September 04, 2015, 11:00:47 AM »
Unity 5.1.3p2
NGUI 3.9.2

Having issue that started to appear on iOS, not in Unity Editor. Any advice?
As you can see in the log the txtScore is set.

iOS Crash
-----------

set #1
 
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)

   val txt Score (UILabel)
 
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)

NullReferenceException: A null value was found where an object instance was required.
  at NGUIText.Prepare (System.String text) [0x00000] in <filename unknown>:0
  at UILabel.ProcessText (Boolean legacyMode, Boolean full) [0x00000] in <filename unknown>:0
  at UILabel.set_text (System.String value) [0x00000] in <filename unknown>:0
  at ScreenScore+<ShowNow>c__Iterator28.MoveNext () [0x00000] in <filename unknown>:0


Unity Code: ScreenScore.cs
------------
Debug.Log ("set #1");
Debug.Log ("   val "+ txtScore);
txtScore.text = "0";   <!-- seems to be crashing here
Debug.Log ("set #2 "+txtScoreTop);
txtScoreTop.text = "0";

8
in the DRAG Update I put this script to check if item is inside view, else hide it.

Note here that I tell the class to hide itself, the base gameobject cannot be hidden because that will mess upp the scroll.
The class hides things inside.

Maybe not a pretty solution but it seems to work for now.

  1. // calculate size and scale
  2.                         UIRoot mRoot = GameObject.FindObjectOfType (typeof(UIRoot)) as UIRoot;
  3.                         float ratio = (float)mRoot.activeHeight / Screen.height;
  4.                         int width = (int)Mathf.Ceil(Screen.width * ratio);
  5.                         int height = (int)Mathf.Ceil(Screen.height * ratio);
  6.  
  7.                         // item width
  8.                         float cWidth = ticketPlaceholder.GetComponent<UIGrid>().cellWidth;
  9.  
  10.                         // camera bounds
  11.                         float x = ticketScroll.GetComponent<UIPanel> ().clipOffset.x;
  12.                         float cLeft = x - (width/2f);
  13.                         float cRight = x + (width/2f);
  14.  
  15.                         int counter = 0;
  16.                         foreach (CardController card in ticketsCardList) {
  17.                                 // item bounds
  18.                                 float itemXCenter = ( cWidth * counter );
  19.                                 float itemLCenter = itemXCenter - (cWidth/2f);
  20.                                 float itemRCenter = itemXCenter + (cWidth/2f);
  21.                                 // is item visible, do not hide whole item, must leave base UIWidget, hide inside
  22.                                 bool isVis = (itemRCenter > cLeft && itemLCenter < cRight ) || (itemLCenter < cRight && itemRCenter > cLeft ) || (itemLCenter > cLeft && itemRCenter < cRight );
  23.                                 card.Show(isVis);
  24.                                 counter++;
  25.                         }

9
Each item around 150 labels, not many characters each (2-30chars).
Then around 120 uisprites that uses same atlas.

trying to optimize them but would really love a solution to hide each item when outside camera view.
Tried using this without success

widget.hideIfOffScreen = true;

10
Upgrading a companies old app, having only 42 child objects.
each object is a little more complex with a lot of UILabels.

tried putting a UIWrapContent but doesn't quite understand how it works, didn't work.

No idea on how to use logic with:
NGUITools.SetActive(gameObject, show);

11
Was there any solution for this?

I'm having the issue that getting error:
Too many vertices on one panel

So object outside camera view (and scroll) should be completely hidden.

  1. ticketScroll.GetComponent<UIScrollView> ().onDragStarted += onViewDragStart;
  2. ticketScroll.GetComponent<UIScrollView> ().onStoppedMoving += onViewDragFinish;
  3.  
  4. private void onViewDragFinish() {
  5.         isDraggning = false;
  6. }
  7.        
  8. private void onViewDragStart() {
  9.         isDraggning = true;
  10. }
  11.  
  12. void Update(){
  13.         if (isDraggning) {
  14.                 foreach (UIWidget card in cardList) {
  15.                         // HOW TO CHECK IF INSIDE VIEW?
  16.                 }
  17.         }
  18. }

12
NGUI 3 Support / Re: Feature: UIWidget - maxWidth/maxHeight
« on: December 18, 2014, 06:48:09 AM »
Didn't want to build in maxWidth / maxHeight into NGUI because of update issues. Did a small solution.

On Camera

  1. public class CameraRotation : MonoBehaviour {
  2.  
  3.         private Camera cam;
  4.         private UIRoot mRoot;
  5.         private bool isPortrait;
  6.         public delegate void OnRotationChange(bool isPortrait, int pixelWidth, int pixelHeight);
  7.         public OnRotationChange OnUpdate;
  8.  
  9.         void Start () {
  10.                 cam = GetComponent<Camera> ();
  11.                 mRoot = NGUITools.FindInParents<UIRoot>(gameObject);
  12.                 isPortrait = (cam.pixelWidth > cam.pixelHeight); // make false value at first so first update runs event
  13.         }
  14.  
  15.        
  16.  
  17.         void Update () {
  18.                 bool n_isPortrait = (cam.pixelWidth < cam.pixelHeight);
  19.                 if (n_isPortrait != isPortrait) {
  20.                         isPortrait = n_isPortrait;
  21.  
  22.                         // update
  23.                         float ratio = (float)mRoot.activeHeight / Screen.height;
  24.                         int width = (int)Mathf.Ceil(Screen.width * ratio);
  25.                         int height = (int)Mathf.Ceil(Screen.height * ratio);
  26.  
  27.                         if(OnUpdate!=null)
  28.                                 OnUpdate(isPortrait,width,height);
  29.                 }
  30.         }
  31. }

On a widget. Example set a
UIPanel
   UIWidget - holder <- place script here
        .... my content ....

  1. public class WidgetLimitSize : MonoBehaviour {
  2.  
  3.         private UIWidget widget;
  4.         public int maxWidth = 0;
  5.         public int maxHeight = 0;
  6.  
  7.         private int aLeft = 0;
  8.         private int aRight = 0;
  9.         private int aTop = 0;
  10.         private int aBottom = 0;
  11.  
  12.  
  13.         void Awake () {
  14.                 widget = GetComponent<UIWidget> ();
  15.                 aLeft = widget.leftAnchor.absolute;
  16.                 aRight = widget.rightAnchor.absolute;
  17.                 aTop = widget.topAnchor.absolute;
  18.                 aBottom = widget.bottomAnchor.absolute;
  19.  
  20.                 CameraRotation cam = Camera.main.GetComponent<CameraRotation> ();
  21.                 cam.OnUpdate += OnUpdate;
  22.         }
  23.  
  24.         private void OnUpdate(bool isPortrait, int width, int height){
  25.                 if (maxWidth != 0) {
  26.                         widget.leftAnchor.absolute = aLeft;
  27.                         widget.rightAnchor.absolute = aRight;
  28.                 }
  29.                 if (maxHeight != 0) {
  30.                         widget.topAnchor.absolute = aTop;
  31.                         widget.bottomAnchor.absolute = aBottom;
  32.                 }
  33.  
  34.                 widget.UpdateAnchors();
  35.         }
  36.  
  37.         void LateUpdate () {
  38.                 CheckBounds ();
  39.         }
  40.  
  41.         private void CheckBounds(){
  42.                 if (maxWidth != 0 && widget.width >= maxWidth) {
  43.                         widget.width = maxWidth;
  44.                 }
  45.                 if (maxHeight != 0 && widget.height >= maxHeight) {
  46.                         widget.height = maxHeight;
  47.                 }
  48.         }
  49. }

13
NGUI 3 Support / Re: Landscape & Portrait with animated panels.
« on: December 18, 2014, 06:43:41 AM »
Would be nice to have it possible to move, rotate, animate the panels. So that they aren't locked in camera view.

I put a script on camera to know about orientation change. Then the background images has a script that resizes.
In the back of my head a little warning bell sounds of about anchoring items inside the panel as well. That will be an issue for future me.

On the camera.
  1. public class CameraRotation : MonoBehaviour {
  2.  
  3.         private Camera cam;
  4.         private UIRoot mRoot;
  5.         private bool isPortrait;
  6.         public delegate void OnRotationChange(bool isPortrait, int pixelWidth, int pixelHeight);
  7.         public OnRotationChange OnUpdate;
  8.  
  9.         void Start () {
  10.                 cam = GetComponent<Camera> ();
  11.                 mRoot = NGUITools.FindInParents<UIRoot>(gameObject);
  12.                 isPortrait = (cam.pixelWidth > cam.pixelHeight); // make false value at first so first update runs event
  13.         }
  14.  
  15.        
  16.  
  17.         void Update () {
  18.                 bool n_isPortrait = (cam.pixelWidth < cam.pixelHeight);
  19.                 if (n_isPortrait != isPortrait) {
  20.                         isPortrait = n_isPortrait;
  21.  
  22.                         // update
  23.                         float ratio = (float)mRoot.activeHeight / Screen.height;
  24.                         int width = (int)Mathf.Ceil(Screen.width * ratio);
  25.                         int height = (int)Mathf.Ceil(Screen.height * ratio);
  26.  
  27.                         if(OnUpdate!=null)
  28.                                 OnUpdate(isPortrait,width,height);
  29.                 }
  30.         }
  31. }


Now I can set this on my backgrounds.

  1. public class BackgroundResizer : MonoBehaviour {
  2.  
  3.         private CameraRotation cameraRotation;
  4.         private UIWidget sprite;
  5.  
  6.  
  7.         void Awake () {
  8.                 sprite = GetComponent<UIWidget> ();
  9.  
  10.                 cameraRotation = GameObject.FindObjectOfType (typeof(CameraRotation)) as CameraRotation;
  11.                 cameraRotation.OnUpdate += OnUpdate;
  12.         }
  13.        
  14.  
  15.         private void OnUpdate (bool isPortrait, int width, int height) {
  16.                 sprite.width = width;
  17.                 sprite.height = height;
  18.         }
  19. }
  20.  

14
NGUI 3 Support / Landscape & Portrait with animated panels.
« on: December 16, 2014, 01:38:15 PM »
I'm trying to build an GUI that will work with both Landscape & Portrait mode, so when the user rotates the screen the layout will still work.

This would be simple to use anchors to fill the screen, but I'm using multiple UIPanel with their own backgrounds that are animated in/out.

I can have all UIPanels -> Background anchored and set to OnStart, this will set the Background for the specific panel to the device size. But the issue occurs when user switches to Landscape mode. Then the Background is at the wrong size.

If I change the background update to OnUpdate it will fill the screen. But when animate the UIPanel in/out it will mess up the view.

Hierarchy:
UI Root (2D)
 - Camera
   - ... some stuff ...
   - Views (UIPanel)
      - MyScreen (UIPanel)
          - text and images
          - Background (UITexture)  <! -- this one
      - MyOtherScreen (UIPanel)
          - text and images
          - Background (UITexture)  <! -- this one
   

How should I solve this problem?
Tried setting Background manually with Camera.pixelWidth or UIPanel.localCorners without success.

15
NGUI 3 Support / Feature: UIWidget - maxWidth/maxHeight
« on: December 16, 2014, 01:20:12 PM »
Would love to see feature for setting maxWidth/maxHeight for components. Maybe in the anchors?

For example.

I've a login view centered. I set anchors on the inputs (left/right) to resize with the different resolutions. Now the user rotates the screen to a landscape mode. If the inputs still stretches the whole way this will make the login screen look really weird. So if I set a maxWidth value it will only resize so far.

This value should of course default be 0 and ignored if not set.

thx for a excellent plugin

Pages: [1] 2