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.


Topics - r.pedra

Pages: [1]
1
NGUI 3 Support / UIGrid problem with new SqrMagnitude on low end devices
« on: August 11, 2016, 12:54:01 PM »
Hi Aren,
Second message of the day ahah.

We had some weird problem on our project with the new Vector3.SqrMagnitude you made in UIGrid.ResetPosition.

Here is our setup:

-UIGrid

-Transform
----Widget
----Widget
----Widget
----Widget

When we do our animation, we want each widget to be repositioned. To do so, we use the AddWidget from UIGrid to parent it to the grid.
After that we call UIGrid.Reposition().
Since we have checked animate smoothly, the widget is smoothly going to the Zero point under the grid.
Everything fine.
Then, 0.3 second after the first one have been add to the grid, we resize the grid and we add another widget and call reposition too.

Everything is fine when the framerate is stable.
But when it's not stable, the first widget almost always stays stuck in the center of the grid. Calling Reposition when the framerate is more stable doesn't replace it correctly.
The only way I made it to work is by disabling the Vector3.SqrMagnitude.
In our setup the grid have a width of 175, the widget is stuck in 0,0,0 and the SpringPosition wants to move it to x:-1750 instead of x:-350, but it doesn't move anyway.

This is our code calling doing the animation:
  1.         private IEnumerator DrawCardsAsync(){
  2.                 for (int i = 0; i < _result.bonusesActivated.Length; i++){
  3.                        
  4.                         cards[i].Init(_result.bonusesActivated[i],GridToRepositionAfterContentUpdate.transform);
  5.                         GridToUpdateWithBonuses.ExecuteUpdateAction();
  6.  
  7.                         GridToRepositionAfterContentUpdate.Reposition();
  8.                         yield return new WaitForSeconds(0.3f);
  9.                 }
  10.         }

ExcuteUpdateAction is in this script:
  1. using UnityEngine;
  2.  
  3. using System.Collections;
  4. using System.Collections.Generic;
  5.  
  6. [ExecuteInEditMode]
  7. public class UIGridFollowsResize : MonoBehaviour
  8. {
  9.         private UIWidget m_Widget;
  10.         private UIPanel m_Panel;
  11.         private UIGrid m_uiGrid;
  12.         public float numOfColumns = 4.0f;
  13.         public float numOfRows = 3.0f;
  14.  
  15.         private List<Transform> m_childList = new List<Transform>();
  16.  
  17.         void Start()
  18.         {
  19.                 m_Widget = GetComponent<UIWidget>();
  20.                 m_uiGrid = GetComponent<UIGrid>();
  21.         }
  22.  
  23.         public void updateGrid()
  24.         {
  25.                 if (m_uiGrid == null) return;
  26.  
  27.  
  28.                 float newHeight;
  29.                 float newWidth;
  30.                 float newScale;
  31.                 if (numOfRows > 0)
  32.                 {
  33.                         newHeight = m_Widget.height / numOfRows;
  34.                 }else{
  35.                         newHeight = 0;
  36.                 }
  37.                 newWidth = m_Widget.width / numOfColumns;
  38.  
  39.                 m_uiGrid.cellWidth = newWidth ;
  40.                 m_uiGrid.cellHeight = newHeight;
  41.  
  42.                 m_childList = m_uiGrid.GetChildList();
  43.                 foreach (Transform child in m_childList)
  44.                 {
  45.  
  46.                         UIWidget childWidget = child.GetComponent<UIWidget>();
  47.                         if((newWidth - (AMTools.isHD ? 80f : 40f)) / childWidget.width < (newHeight - (AMTools.isHD ? 60f : 30f)) / childWidget.height){
  48.                                 newScale = (newWidth - (AMTools.isHD ? 80f : 40f)) / childWidget.width;
  49.                         }else{
  50.                                 newScale = (newHeight - (AMTools.isHD ? 60f : 30f)) / childWidget.height;
  51.                         }
  52.  
  53.                         child.localScale = Vector3.one * newScale;
  54.                 }
  55.         }
  56.  
  57.         void Update()
  58.         {
  59.                 if (m_Panel == null) m_Panel = m_Widget.panel;
  60.         }
  61.  
  62.         public void ExecuteUpdateAction(){
  63.  
  64.                 updateGrid();
  65.         }
  66.  
  67.         public bool update = false;
  68.         void OnValidate(){
  69.                 if(update == true){
  70.                         updateGrid();
  71.                         update = false;
  72.                 }
  73.         }
  74. }
  75.  
Init is doing this with the transform(and other thing but not related to the transform):
  1.         public void Init(APIJSON.SHOP.CARDHOLDER.BonusesActivated bonus, Transform moveParentingTo){
  2.                 _bonus = bonus;
  3.                 Debug.Log("Bonus:" + JsonUtility.ToJson(_bonus));
  4.                 if(firstParent == null){
  5.                         firstParent = this.transform.parent;
  6.                 }
  7.                 moveParentingTo.GetComponent<UIGrid>().AddChild(this.transform);
  8.  
  9.                 this.gameObject.SetActive(true);
  10. }


To simulate the hiccups of the device we made a dirty function:
  1.         int nbLags = 0;
  2.         private IEnumerator LagsPeriodically()
  3.         {
  4.                 int i = 0;
  5.                 while (i < 1000)
  6.                 {
  7.                         Debug.Log("LOG");
  8.                         i++;
  9.                 }
  10.  
  11.                 nbLags++;
  12.                 yield return new WaitForSeconds(0.4f);
  13.                 if (nbLags < 5)
  14.                 {
  15.                         StartCoroutine(LagsPeriodically());
  16.                 }else{
  17.                         nbLags = 0;
  18.                 }
  19.         }

Can you take a look at it and tell us if you have the same problem?

2
NGUI 3 Support / High CPU in Editor-only on 3.10.0
« on: August 11, 2016, 07:58:59 AM »
Hi Aren,
We updated recently to the last NGUI update (we were 5 or 6 update behind).
Since this day, scene view is almost unusable because when we move some objects around, CPU increase to 100% during all the move.
We did a profile of the editor and linked the result to this topic.

At first we thought it was because you call Profiler.BeginSample in an ExecuteInEditMode script but after removing it we have the same problem.
We are on Unity 5.3.6p2 and this bug is very annoying because we can't place our widgets properly like before.

Do you have the same problem on your side?

3
NGUI 3 Support / Any way to optimize CalculateRelativeWidgetBounds ?
« on: July 29, 2016, 08:42:30 AM »
Hi,
We have a list of cards in our game.
These cards are displayed in an UIGrid with SmoothTween enabled.
We are trying to do a nice animation with these cards. Every time we add one to the grid(+0.4s), we reposition the grid:


The problem is that we have a scrollbar, and it triggers the CalculateRelativeWidgetBounds function. Since it's a recursive function on all the widgets underneath the panel, it is called 11 000 times !!!! (We have about 50 cards, with one background, an icon, the foreground, and 1 or 2 UILabel)

In our example, we tried to do it progressively, but it started with 0kb of garbage generated and ended with 6Mb of garbage during the last card animation. 6Mb !!!!!!!
We tried to do it instantly on all the cards by giving up the progressive effect (and loose a nice card distribution effect) but the frame still generates 6Mb of garbage.

Do you have an idea on how we can optimize this or change something in our setup to optimize it?

Thank you for your help.


EDIT: I would like to add that this is the GetComponent<UIPanel> on each widget that is generating so much garbage. Would it be possible to cache it and reuse it every time ?

4
Hi,
We have a problem in our project.
Some scrollbars are related to each other and does stuff when the others do stuff.
The problem is that when a Scrollbar have a value of 0, something is going wrong, and built in anchors are not refreshing correctly.

On the screenshot, the object container is the background of the UIScrollbar on Aff. You can see that the UISprite on Container have his anchors left property linked to an object named Sprite. This is the Sprite object below Eco.
But for some reason when the UIScrollbar start and that its value is setted to 0 in the code, even if we call ForceUpdate, UISprite is disabled(seems to be related to the 0 value) and the anchor doesn't refresh.
(I updated to the last version of NGUI but it didn't solved my problem).
So where does NGUI disable Widgets when Scrollbar value is 0 ?

5
NGUI 3 Support / NGUI Update Optimisation
« on: January 04, 2016, 10:06:32 AM »
Hi,
I saw an article on Unity Blog that could be useful to NGUI:
http://blogs.unity3d.com/2015/12/23/1k-update-calls/

Maybe you already did something more optimized that what he is explaining, I don't know. Are you planning to do something like that if it helps NGUI runs faster?

Moreover, did you ever thought about the ETC1 + alpha system with NGUI?
You know that on Android ETC1 is a great compression format but it does not use Alpha.
We did a little workaround in NGUI Shaders and UIDrawCall.cs to handle ETC1 atlas + Alpha8 mask. (For a 2K textures, we freed about 10Mb of memory on the disk for a similar render quality).

6
NGUI 3 Support / FontMaker loosing Font Info
« on: February 19, 2015, 08:44:22 AM »
Hi,
I have a problem with the FontMaker and GeneratedBitmap option.
Every time I create an UIFont from a Font, it works well.
But if I close Unity or compile, UIFont don't know anymore where the characters are in the Bitmap.

I'm able to reproduce it in my 2 projects.

Simple to reproduce:

1/ Download any TTF you want
2/ Generate Bitmap with FontMaker with this TTF
3/Create UILabel, affect UIFont
4/Right now, everything should be ok.
5/Close Unity
6/Launch Unity
7/UILabel is displaying parts of characters, UIFont lost characters infos.

Can you fix that?

EDIT: Using 3.7.9 on Unity 4.5.5p5

7
NGUI 3 Support / Bitmap Font + Prefab Problem
« on: February 03, 2015, 10:36:52 AM »
Hi,
We have the last version of NGUI (just downloaded it).
We have created Bitmap Font from Unity font using Font Maker in size 40 (Arial Bold).
We are then using the font in many labels in the app, including in prefabs instantiated at runtime.
When we set the font in UILabel, it prints 21 as fontSize and 40 as defaultSize.
But when we instantiate the prefab, it prints 21 as fontSize and 21 as defaultSize but the font is displayed on screen at size 40.
If I change the fontSize in the editor just by one size during runtime, (say 22), defaultSize goes back to 40 and the label is displayed at the right size(22).

I tried to do a hack by doing label.fontSize = label.fontSize but your setter is checking if the fontSize changed, and I'm affraid of killing perfs if I change this behaviour.

Before we were using dynamic font but Dynamic Font Arial is very buggy on Android, so we changed all the labels using Arial and Dynamic Font by Bitmap but it's now worse than before with this bug.

Can you help us?

8
NGUI 3 Support / Texture Mask and Meshes
« on: December 09, 2014, 05:47:47 AM »
Hi,
I want to mask meshes with Texture Mask feature of NGUI.
I tried to use the work of this guy:
http://www.tasharen.com/forum/index.php?topic=10223.msg48054#msg48054

But it seems that Texture Mask use a different way of masking.

I tried to do it with RenderTexture instead but it's heavy with mobile(because we want to achieve something like the attachment we need to use multiple RenderTexture if we do this that way)

Can someone help me?
Thank you.

9
NGUI 3 Support / Play ParticleSystem on Tween Finish
« on: November 12, 2014, 12:28:48 PM »
Hi,
I wanted to Play a ParticleSystem at the end of a Tween but it doesn't appear when I link my gameobject to the OnFinish event.
I know I can do it with a script called by OnFinish that will call the particle system but it would be nice to be able to do it directly on the finish event of the tween.
Is this something related to NGUI or related to Unity?

(I'm using NGUI 3.7.2, I don't remember that it was added in more recent versions)

Thank you.

10
NGUI 3 Support / What are you planning for 3.6 ?
« on: May 12, 2014, 06:29:56 AM »
Hi,
You are making an incredible work with NGUI and it's saving us a lot of time.
What are you planning to release for 3.6? Do you even know? :p
Are you considering it as a "Major" release?

Thank you :)

11
NGUI 3 Support / Atlas Maker Popup is a CPU eater?
« on: March 18, 2014, 05:17:11 AM »
Hi,
I noticed something with the Atlas Maker. I snapped it into the Unity main window and it is often displayed.
Everytime the Atlas Maker is displayed Unity needs 70% of CPU and when i switch on another tab of my layout in Unity, it gets back to a normal value.
I attached some screenshots to illustrates what I'm saying. (Same thing seems to happen with the Font maker)

Is this normal? Or is this something that you can optimize?

12
NGUI 3 Support / ScrollView + UISlider problem
« on: March 12, 2014, 01:52:20 PM »
Hi,
I updated NGUI on monday to the last version 3.5.3 but I have a problem I hadn't before.
I have an unrestricted UIScrollview that is linked to an UISlider.

Every time I scroll the panel by touch or click I got this error:
Quote
NullReferenceException: Object reference not set to an instance of an object
UIScrollView.UpdateScrollbars (.UIScrollBar sb, Single contentMin, Single contentMax, Single contentSize, Single viewSize, Boolean inverted) (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:494)
UIScrollView.UpdateScrollbars (Boolean recalculateBounds) (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:441)
UIScrollView.MoveRelative (Vector3 relative) (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:632)
UIScrollView.MoveAbsolute (Vector3 absolute) (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:643)
UIScrollView.LateUpdate () (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:874)
If I don't touch the ScrollView but I slide the UISlider, it does nothing.

I attached the configuration of the UIScrollView and UISlider to the topic.

Thank you.

EDIT: I did more tests and I debugged the variable 'sb' of the line throwing NullRefException
  1. Debug.Log ("HorizontalScrollBar:"+sb);
returns:
Quote
HorizontalScrollBar:
So the UIScrollbar seems to be NULL.
But when I debug it before the function call, it's not null...

EDIT2:
Little more test
  1. Debug.Log ("ScrollBar:"+ (horizontalScrollBar as UIScrollBar));
returns null. You're casting the UIProgressBar to UIScrollBar but it's breaking it... Can I remove the cast without breaking all NGUI?

13
NGUI 3 Support / 4K Atlas constantly crashing on Add/Update
« on: February 27, 2014, 06:11:28 AM »
Hi,
I'm fighting with a 4K atlas for 2 days. It contains lots of sprites at the moment(114). Everytime I try to add a sprite, i get an error:
Quote
MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
  at (wrapper managed-to-native) UnityEngine.Texture:Internal_GetWidth (UnityEngine.Texture)
  at UnityEngine.Texture.get_width () [0x00000] in <filename unknown>:0
  at UIAtlasMaker.PackTextures (UnityEngine.Texture2D tex, System.Collections.Generic.List`1 sprites) [0x000ec] in /Users/romainpedra/Git/AM2_Mobile/Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:144
  at UIAtlasMaker.UpdateTexture (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) [0x000b0] in /Users/romainpedra/Git/AM2_Mobile/Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:540
  at UIAtlasMaker.UpdateAtlas (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) [0x0000c] in /Users/romainpedra/Git/AM2_Mobile/Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:640
  at UIAtlasMaker.UpdateAtlas (System.Collections.Generic.List`1 textures, Boolean keepSprites) [0x00024] in /Users/romainpedra/Git/AM2_Mobile/Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:623
  at UIAtlasMaker.OnGUI () [0x00bb5] in /Users/romainpedra/Git/AM2_Mobile/Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:985
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d0] in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222

I have this error very often, but everytime I just retry and it's okay(more or less, I have to build the atlas 2 sprites by 2 sprites and Commit on Git between each update if I don't want to redo it everytime...)
It's not a size problem, because it's doing it with every sprite I want to add since I have 114 sprites.
The proof that there is still space in the atlas is attached to the topic.

Thank you.

14
NGUI 3 Support / UIScrollView + FixedSize problem 3.5.0
« on: February 20, 2014, 05:23:46 AM »
Hi,
In the last updates you introduced ContentOrigin on UIScrollView.
Some weird thing is happening when the camera is set to FixedSize.
All my panels are f***ed when I'm using FixedSize. But the thing really weird is that when I change the ContentOrigin to another and then go back to the one I wanted, everything is fine.
For example, to test my UI in iPad Retina definition, I set the camera to FixedSize and the height to 1536. Before the update, everything was fine but now everything is broken.

Cordially,
Romain Pedra

Pages: [1]