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

Pages: [1] 2
1
NGUI 3 Support / Re: Multiple widgets on one gameobject possible bug
« on: October 15, 2013, 02:06:47 AM »
It's under menu [NGUI] => [Attach] => [Collider].

Or you can use the hotkey by pressing  [Alt]+[Shift]+[C]

2
I'm using 3.0.2

reproduce step:
  • Create a new scene.
  • Through menu [NGUI] -> [Create] -> [Texture]
  • Assign "Fantasy Atlas" material provided from NGUI package to UITexture's material
  • Attach the code below
  • Hit Play

In my game, I use a custom shader to mask the texture, so I can't use UITexture's UV setting.
I tried MarkAsChanged(), it didn't work.
Disable/Enable UITexture or panel.Refresh() work, but I think I should not do that at runtime.
How do I make it work in 3.0.2 ?

Thanks.

  1. using UnityEngine;
  2. public class UITextureOffset : MonoBehaviour
  3. {
  4.         float offset;
  5.         UITexture tex;
  6.         void Start()
  7.         {
  8.                 tex = GetComponent<UITexture>();
  9.         }
  10.         void Update()
  11.         {
  12.                 offset += Time.deltaTime;
  13.                 if (offset > 1)
  14.                         offset = 0;
  15.                 tex.material.mainTextureOffset = new Vector2(offset, 0);
  16.         }
  17. }
  18.  

3
NGUI 3 Support / Re: NGUI Performance questions
« on: August 20, 2012, 12:39:45 AM »
Simon129, can you explain to me that works?

I upload a picture, and hope you can understand what I mean.

4
NGUI 3 Support / Re: Tweening multiple gameobjects with one tween event
« on: August 16, 2012, 10:16:34 PM »
Using UITweener.tweenGroup property ?

It can trigger multiple tweens

5
NGUI 3 Support / Re: NGUI Performance questions
« on: August 12, 2012, 09:40:34 PM »
(3) UIDraggablePanel

The DraggablePanel works by having all the items in the draggable panel present and as you drab the panel they pop in and out of view. By my thinking, if I have 10 or 1000, if only 10 are shown in the window at any one time then surely there is no performance by having 1000? Problem is, deleting objects and creating them on the fly is surely going to bad for garbage collection. My question is basically, if I create 100 objects as my max and even if I am only using about 10 or so at a time on screen, is there a performance hit for having so many in the panel. This is of course in relation to UIDraggablePanel seemingly being quite slow on the iPhone4.

I have a draggable panel with clipping and instantiate about 150 items on it, it's very slow.
I optimize my code with the idea of "object pool", only create 5 items, and shift/un-shift the item to bottom/top of the draggable panel when it's out of visible area.
No more instantiating and destroying at runtime.

6
NGUI 3 Support / Re: Label Effects.
« on: August 09, 2012, 09:12:25 PM »
Is there any tutorial that bake fonts in PS and output BMFont format data ?

Thanks.

7
NGUI 3 Support / Re: Clip non NGUI objects
« on: August 08, 2012, 04:08:13 AM »
2D clipped shader can't be used in 3D objects.

But, you can use another camera like "Example 8 - Scroll View (Camera)" did.

8
check out the quest example

http://www.tasharen.com/ngui/example9.html

9
NGUI 3 Support / Re: UITexture MakePixelPerfect() may need pixelSize
« on: August 06, 2012, 09:15:24 PM »
Everything under UIRoot is pixel-based.

Local scale X/Y = pixel width/pixel height.

Just adjust local scale.

10
NGUI 3 Support / Re: Cropping and Offset of Simple Texture
« on: August 02, 2012, 09:36:04 PM »
I made my own UITextureUV based on UITexture.

UITextureUV.cs
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [ExecuteInEditMode]
  5. [AddComponentMenu("NGUI/UI/TextureUV")]
  6. public class UITextureUV : UITexture
  7. {
  8.     public Rect UV = new Rect(0, 0, 1, 1);
  9.  
  10.     override public void OnFill(BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color> cols)
  11.     {
  12.         Vector2 uv0 = new Vector2(UV.xMin, UV.yMin);
  13.         Vector2 uv1 = new Vector2(UV.xMax, UV.yMax);
  14.  
  15.         verts.Add(new Vector3(1f, 0f, 0f));
  16.         verts.Add(new Vector3(1f, -1f, 0f));
  17.         verts.Add(new Vector3(0f, -1f, 0f));
  18.         verts.Add(new Vector3(0f, 0f, 0f));
  19.  
  20.         uvs.Add(uv1);
  21.         uvs.Add(new Vector2(uv1.x, uv0.y));
  22.         uvs.Add(uv0);
  23.         uvs.Add(new Vector2(uv0.x, uv1.y));
  24.  
  25.         cols.Add(color);
  26.         cols.Add(color);
  27.         cols.Add(color);
  28.         cols.Add(color);
  29.     }
  30. }
  31.  


UITextureUVInspector.cs
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections.Generic;
  4.  
  5. /// <summary>
  6. /// Inspector class used to edit UITextureUV.
  7. /// </summary>
  8.  
  9. [CustomEditor(typeof(UITextureUV))]
  10. public class UITextureUVInspector : UITextureInspector
  11. {
  12.     private Rect mUV;
  13.  
  14.     public override void OnInspectorGUI()
  15.     {
  16.         UITextureUV texture = target as UITextureUV;
  17.        
  18.         GUILayout.BeginHorizontal();
  19.         GUILayout.Space(40f);
  20.         mUV = EditorGUILayout.RectField("UV", texture.UV);
  21.         GUILayout.EndHorizontal();
  22.  
  23.         texture.UV = mUV;
  24.  
  25.         base.OnInspectorGUI();
  26.     }
  27.  
  28.     override protected void OnDrawTexture()
  29.     {
  30.         Texture2D tex = mWidget.mainTexture as Texture2D;
  31.  
  32.         if (tex != null)
  33.         {
  34.             // Draw the atlas
  35.             EditorGUILayout.Separator();
  36.             Rect r = NGUIEditorTools.DrawSprite(tex, new Rect(0F, 0F, 1F, 1F), null);
  37.  
  38.             // Draw the selection
  39.             NGUIEditorTools.DrawOutline(r, mUV, new Color(0.4f, 1f, 0f, 1f));
  40.  
  41.             // Sprite size label
  42.             Rect rect = GUILayoutUtility.GetRect(Screen.width, 18f);
  43.             EditorGUI.DropShadowLabel(rect, "Texture Size: " + tex.width + "x" + tex.height);
  44.         }
  45.     }
  46. }
  47.  

11
NGUI 3 Support / Re: 123ms UIPanel.LateUpdate!?
« on: August 01, 2012, 01:22:34 AM »
If I have a large UIPanel and have about 50 widgets on it, only 1 of them with a looped color tween and others are static buttons, should I isolate that widget to it's own UIPanel to avoid the whole UIPanel to rebuild the buffer on every update to gain better performance ?

Thanks

12
NGUI 3 Support / Re: 123ms UIPanel.LateUpdate!?
« on: August 01, 2012, 01:13:38 AM »
That's way excessive. You need to move your animated widgets into their own panel, if possible. Them changing every frame means that the draw buffer used for them must be re-created every frame -- and if they have 44 other widgets under the same panel that means 44 others also get affected.

Are tween color and tween scale also "animated widgets" and cause UIPanel to rebuild the buffer, or just position related tween ?

thanks

13
Everything NGUI should be under UIRoot, and their scale should be based on pixel.

you can box ur sprits with an empty gameobject with local scale (1,1,1), and after u instantiate and parent it to UIRoot/Anchor/UIPanel/,  make sure it's local scale is (1,1,1)

14
NGUI 3 Support / Re: Draggable UIPanel not seeing added widgets
« on: July 11, 2012, 09:56:07 PM »
after moving in/out clipped panel, call UIWidget.CheckParent(), I fixed it in my project.

15
NGUI 3 Support / Re: UIButton's color in DraggablePanel problem
« on: July 11, 2012, 05:50:26 AM »
I have a situation like yours, here is how I do,

I try to mimic how UICamera.ProcessTouch(bool, bool) does on OnDrag and OnClick

  1. public UICamera mCam;
  2. void OnDrag(Vector2 delta)
  3. {
  4.     if (UICamera.currentTouch.totalDelta.magnitude > mCam.touchClickThreshold)
  5.     {
  6.         tween off
  7.     }
  8. }
  9.  

Pages: [1] 2