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

Pages: [1]
1
NGUI 3 Support / Re: iOS compiler problem
« on: December 01, 2014, 10:57:33 PM »
Put your NGUI folder into Assets folder, not Assets/Plugins.

2
NGUI 3 Support / Re: NGUI & 2DToolkit Sprite Collections
« on: November 19, 2014, 05:35:05 AM »
I am doing same thing in my current project. I wrote a script which renders one or more tk2d sprites as one ngui object. You can find it in the attachment. I made it to be able programmatically create sprites and change shader at runtime.
Sprite type and Flip does not work.

3
NGUI 3 Support / Re: How to apply a shader effect on one sprite?
« on: October 28, 2014, 01:38:40 AM »
Nope, i'm not creating new material for each sprite, i'm creating new material for each shader and atlas, that's why there is a cache for materials.
If you put hundreds of different sprites with same shader and same atlas in one depth, they will add only one (or two) draw call.

4
NGUI 3 Support / Re: How to apply a shader effect on one sprite?
« on: October 27, 2014, 10:50:40 AM »
Here is my version of how it could be done. i'm going to use this in my current project.

UIShaderSprite.cs:
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class UIShaderSprite : UISprite {
  6.         Material mMaterial;
  7.         [HideInInspector][SerializeField] Shader mShader;
  8.  
  9.         // cache materials
  10.         static Dictionary<int, Dictionary<int, Material>> atlasMaterials = new Dictionary<int, Dictionary<int, Material>>();
  11.  
  12.         public override Material material {
  13.                 get {
  14.                         if (mShader != null) {
  15.                                 if (mMaterial == null || mChanged) {
  16.                                         Dictionary<int, Material> shaderMaterials;
  17.                                         if (!atlasMaterials.TryGetValue(atlas.GetInstanceID(), out shaderMaterials))
  18.                                                 atlasMaterials[atlas.GetInstanceID()] = shaderMaterials = new Dictionary<int, Material>();
  19.  
  20.                                         if (!shaderMaterials.TryGetValue(mShader.GetInstanceID(), out mMaterial) || mMaterial == null)
  21.                                                 shaderMaterials[mShader.GetInstanceID()] = mMaterial = new Material(base.material) {shader = mShader};
  22.                                 }
  23.                                 return mMaterial;
  24.                         }
  25.                         return base.material;
  26.                 }
  27.         }
  28. }
  29.  

Editor/UIShaderSpriteInspector.cs:
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4.  
  5. [CanEditMultipleObjects]
  6. [CustomEditor(typeof(UIShaderSprite), true)]
  7. public class UIShaderSpriteInspector : UISpriteInspector {
  8.  
  9.         protected override bool ShouldDrawProperties() {
  10.                 NGUIEditorTools.DrawProperty("Shader", serializedObject, "mShader", GUILayout.MinWidth(20f));
  11.                 return base.ShouldDrawProperties();
  12.         }
  13. }
  14.  

5
NGUI 3 Support / Re: high cpu-waits-gpu on iPad
« on: October 27, 2014, 12:01:13 AM »
I fixed motion lag by smoothing drag delta. I just did something like this:

  1. Vector2 totalDelta, targetTotalDelta;
  2.  
  3. void OnDragStart() {
  4.   totalDelta = Vector2.zero;
  5.   targetTotalDelta = Vector2.zero;
  6.   dragging = true;
  7. }
  8.  
  9. void OnDrag() {
  10.   targetTotalDelta = UICurrent.currentTouch.totalDelta;
  11. }
  12.  
  13. void Update() {
  14.   if (dragging) {
  15.     totalDelta = Vector2.Lerp(totalDelta, targetTotalDelta, 0.25f);
  16.     // ...
  17.   }
  18. }
  19.  

6
NGUI 3 Support / Re: help passing extra data using UIEventListener
« on: October 23, 2014, 11:31:28 AM »
Well, that throws an error, probably though due to my lack of knowlege on events and listeners.. appreciate the help, will continue to dig into it and google some more..

My bad, updated the code above.
You'll have more problems with anonymous functions, you'd better try this:
  1. void Init() {
  2.     var listener = UIEventListener.Get(fileItemWidgets[5].gameObject);
  3.     listener.parameter = 1234;
  4.     listener.onClick = OnAccountFileSelected;
  5. }
  6.  
  7. void OnAccountFileSelected(GameObject g) {
  8.     int ID = (int)UIEventListener.Get(g).parameter;
  9.     print("Clicked filename: " + ID.ToString());
  10. }
  11.  

7
NGUI 3 Support / Re: help passing extra data using UIEventListener
« on: October 23, 2014, 06:30:16 AM »
At least you can do:

  1. UIEventListener.Get(fileItemWidgets[5].gameObject).onClick = (go) => {
  2.         OnAccountFileSelected(go, 123);
  3. }
  4.  

8
There is no such setting via code. Have a look at Unity's TextureFormat enum. You need to specify the exact format. There is no "Automatic Truecolor". That's only in inspector.

NGUIEditorTools.cs
lines 447 and line 482:
settings.textureFormat = TextureImporterFormat.ARGB32;
can be changed to:
settings.textureFormat = TextureImporterFormat.AutomaticTruecolor;

i agree with Wisteso, it's better if format is automatic truecolor.

9
NGUI 3 Support / Re: high cpu-waits-gpu on iPad
« on: October 21, 2014, 09:12:53 PM »
Because your framerate is higher than 60 fps, and the device has to wait?

Nope, it is 60 fps, it's not higher.
I think it has some input lags, maybe touches priority is low. Because when i move objects with a tween, it moves smoothly, but when i drag objects by hand moves are not smooth.

As it is said on page http://docs.unity3d.com/Manual/iphone-iOS-Optimization.html
Quote
Conversely, you can increase the framerate to give the rendering priority over other activities such as touch input and accelerometer processing.

10
Yeah, always take the deep profiler's numbers with a huge grain of salt. I've explained it numerous times before. Think about it. Deep profiler adds a fixed amount of overhead to every function. So for example, say it adds 0.1 ms to every function call. Now say you have a function that takes 5 ms to execute, and is called once. You also have a function that takes 0.001 ms to execute, but is called 500 times. Let's do the math now:

(5 ms + 0.1 ms) * 1 = 5.1 ms for the big function
(0.001 ms + 0.1 ms) * 500 = 50.5 ms for the small functions.

See the problem?

Thank you for explanation!
I have to try it on device.

11
NGUI 3 Support / high cpu-waits-gpu on iPad
« on: October 20, 2014, 10:46:35 PM »
Hi,

I have a simple scene, all standard ngui sprites, 3 panels and 60-70 sprites, not so many draw calls and verts/tris, no special shaders, no post processing shaders, no clipping panels.
Why cpu-waits-gpu time is so high? Value changes over time, some times it is 0, some times it is 3-4.
On 60 fps, i can see some motion lags when cpu-waits-gpu is greater than 1. Testing on iPad mini 2, iOS 8.

----------------------------------------
iPhone Unity internal profiler stats:
cpu-player>    min:  8.4   max: 10.6   avg:  9.2
cpu-ogles-drv> min:  0.5   max:  1.3   avg:  0.5
cpu-present>   min:  4.5   max:  9.4   avg:  6.7
cpu-waits-gpu> min:  4.5   max:  9.4   avg:  6.7
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 14.2   max: 19.5   avg: 16.6
draw-call #>   min:  12    max:  12    avg:  12     | batched:     0
tris #>        min:   466  max:   466  avg:   466   | batched:     0
verts #>       min:   932  max:   932  avg:   932   | batched:     0
player-detail> physx:  0.2 animation:  0.0 culling  0.0 skinning:  0.0 batching:  0.0 render:  2.3 fixed-update-count: 0 .. 1
mono-scripts>  update:  3.4   fixedUpdate:  0.0 coroutines:  0.0
mono-memory>   used heap: 7618560 allocated heap: 8036352  max number of collections: 0 collection total duration:  0.0
----------------------------------------

12
Are you doing this with deep profile enabled? They are simple null checks.

Yes, i'm doing deep profile.
Here is profiler when it is
  1. [System.NonSerialized] public AnchorUpdate updateAnchors = AnchorUpdate.OnUpdate;


and profiler when it is
  1. [System.NonSerialized] public AnchorUpdate updateAnchors = AnchorUpdate.OnStart;

13
Hi,

Right now UIRect compares 4 transforms (leftAnchor.target, rightAnchor.target, ...) on each Update, even when it has no anchors.
In my case, UIRect.Update is using 28% of cpu time for 500 widgets without anchors, and it is using 12% of cpu time when i change default value to OnEnable.

14
NGUI 3 Support / Re: Problem with 3d model in NGUI
« on: October 15, 2014, 05:01:53 AM »
Создайте отдельную камеру которая рендерится поверх UI камеры, и в него положите модельку. Или, меняйте для модельки renderQueue либо sortingOrder вручную.

Pages: [1]