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

Pages: [1] 2
1
NGUI 3 Support / Re: Pic does not show up after mainTexture assigned.
« on: April 28, 2014, 04:27:40 AM »
Version 3.0.6 f7
It shouldn't be the flipping of a bool value...So I better rephase the issue:

UITexture's mainTexture assigned successfully (by checking the mainTexture width), but the texture not draw and remain the old one.

Is it because callback is from other application outside unity (Android Photo Library)..
Is it because I am clicking the cloned version of a gameObject including all button and sprite..

The behavior really very strange....difficult to believe ..that's why I enclose the pic with step by step debug message.
Actaully event I called OnClick from other script, it wont show up. only when the Onclick is called by the UICamera event, then it show.

2
NGUI 3 Support / Re: Pic does not show up after mainTexture assigned.
« on: April 25, 2014, 10:28:12 PM »
To demonstrate it:
I modified the code with debug message and took some screen shot for comparison:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class test : MonoBehaviour {
  5.  
  6.         // Use this for initialization 
  7.         public UITexture uiTexture;    
  8.         public bool  PicReady = false;
  9.  
  10.         void Start() {
  11.                 NGUIDebug.Log(Time.frameCount + "Before Assignement mainTexture Width is" + uiTexture.mainTexture.height);
  12.                 StartCoroutine(UpdateImage());
  13.         }
  14.  
  15.         public void OnClick() {
  16.                 NGUIDebug.Log(Time.frameCount + " I clicked the button");
  17.                 PicReady = true;               
  18.         }
  19.  
  20.         public void ChangePicReady() {
  21.                 NGUIDebug.Log(Time.frameCount + " I changed the PicReady from other script");
  22.                 PicReady = true;
  23.         }
  24.  
  25.         IEnumerator UpdateImage() {
  26.                 while (true) {
  27.                         yield return new WaitForSeconds(5);
  28.                         if (PicReady) {                        
  29.                                 string url = "file://" + PlayerPrefs.GetString("PicPath");
  30.                                 NGUIDebug.Log(Time.frameCount + " PicReady: " + PicReady + " url " + url);
  31.                                 WWW www = new WWW(url);
  32.                                 yield return www;                              
  33.                                 uiTexture.mainTexture = www.texture;
  34.                                 NGUIDebug.Log(Time.frameCount + " After Assigned mainTexture " + uiTexture.mainTexture.height);
  35.                         }
  36.                 }
  37.         }
  38. }
  39.  

You can see from my attachement pic. I first called ChangePicReady(), at frame 616. Then, UpdateImage() called three times, you can see the mainTexture width changed from 302 (at frame 1) to 427 (at frame 693). Which means texture assigned sucessfully but it does not draw. And then I click the test button which contains this test script at frame 1260. The Little Pong Texture show up after the next UpdateImage() called.

3
NGUI 3 Support / Re: Strange behavior
« on: April 25, 2014, 06:27:25 PM »
But calling both function directly the new texture wont draw. Only I click the button and let the UICamera event listener system fire the onClick then, the texture change.

I NGUIDebug.Logged the width of the texture in both case right after I assigned the www.texture to the mainTexture, and the mainTexture show a value of 600, meaning the texture are correctly assigned. I called the ChangePicReady() function from other class which is basically class is initiated by an Android Image Picker Plugin. It save a texture from the Photo Library and return a path. I physically confirmed that the file are there. So it is nothing wrong to with the picker plugin,(The path are the same in both case anyway). I also tried to call the onclick function directly from the picker plugin, again, function is called, UpdateImage() function runned smoothyly, maintexture changed. But it just wont show up until I physically click it. I was stuck for two days already and without any clue.....

4
NGUI 3 Support / Pic does not show up after mainTexture assigned.
« on: April 25, 2014, 09:17:02 AM »
If I click the button, the texture show.
But if I change the PicReady from its own class, the texture not show....

Is it any hidden function inside the OnClick event that need to update or redraw the pic. Any other function I need to call if I update the texture outside the on click event?


  1.         public UITexture uiTexture;    
  2.         public MyPicPick MyPic;
  3.  
  4.         void Start() {
  5.                 StartCoroutine(UpdateImage());
  6.         }
  7.  
  8.         void OnClick() {
  9.                 NGUIDebug.Log("Call From On Click");
  10.                 MyPic.PicReady = true;         
  11.         }
  12.  
  13.         public void ChangePicReady() {
  14.                 NGUIDebug.Log("Call From Other");
  15.                 MyPic.PicReady = true;
  16.         }
  17.  
  18.         IEnumerator UpdateImage() {
  19.                 while (true) {
  20.                         yield return new WaitForSeconds(4);
  21.                         if (MyPic.PicReady) {                          
  22.                                 string url = "file://" + PlayerPrefs.GetString("PicPath");
  23.                                 WWW www = new WWW(url);
  24.                                 yield return www;
  25.                                 uiTexture.mainTexture = www.texture;
  26.                         }
  27.                 }
  28.         }

5
NGUI 3 Support / Re: ClipRange Dislocated After moving the panel...
« on: January 15, 2014, 10:52:17 PM »
Thx a lot, glad to hear that we can move the scroll view..I should have checked the functions in UIScrollView...and Google how to reset position....Turn out the following works for me:
Method 1 SpringPanel.Begin(ScrollViewGO, new Vector3(ScrollViewGO.transform.localPosition.x, -1240, 0), 999999999);
Method 2 ScrollViewGO.GetComponent<UIScrollView>().MoveRelative(new Vector3(0, - ScrollViewGO.transform.localPosition.y - 1240, 0));
But the following not work for me:
ScrollViewGO.GetComponent<UIScrollView>().ResetPosition();

SpringPanel method can do the trick but...is kind of urgly, I don't need spring effect and movement, I just need reposition...MoveRelative is much elegant but it need me to recalculate the difference of the position in order to move, Should it be some function like scrollTo,scrollToTop,scrollToBottom function in uiscrollview..? To keep it consistent, hope there will be MoveTo(), MoveToBottom(), MoveToTop() function in uiscrollview in the future. NGUI is the greatest plugin in unity! Really thx a lot!

6
NGUI 3 Support / Re: ClipRange Dislocated After moving the panel
« on: January 15, 2014, 03:11:28 PM »
In short, to reproduce, make a vertical scroll view, scroll it, clip region doesn't change, but the transform local position y of the panel will change. If we type a different value to the local position y in the inspector. So this some how tell me that if I change the transform local position y, clip range will move together..(.I don't wanna offset it back...it is urgly...)

Clip Region move together..so how can I change the scroll view back to the first row while not moving the clip range...

7
NGUI 3 Support / ClipRange Dislocated After moving the panel...
« on: January 15, 2014, 02:38:50 PM »
I have a vertical scroll view with about 200 item, when user scroll to item 160-180, clicked a back button, changed their location, all of the scroll item are then removed and another 200 items are added from the database. Everything work smoothly.

However, all item disappear from the screen..I checked the scrollview, it is find that the scrollview is still in its old position (at item 16(making item 1-20 far away from the screen) ...so I reset it mannually:
  1. ScrollViewGO.transform.localPosition= new Vector3(ScrollViewGO.transform.localPosition.x,OriginalScrollViewY, 0);
now the location is correct but I still cannot see the item and I find that the clip range positions is moved....I think it is not the good way to reset like this....

Is it anyway to easily reset the scrollview, once all the items inside are replaced by a new set of items?

8
NGUI 3 Support / Re: UITexture Memory Leak
« on: January 14, 2014, 12:04:21 PM »
Thx for letting me know it is a common problem of unity texture. It is fixed with the following code:
  1. DestroyImmediate(uitextureComp.mainTexture,true);
Just find out from google that texture will not be dumped by GC even not more reference and must destroy it mannually.

9
NGUI 3 Support / Re: UITexture Memory Leak
« on: January 11, 2014, 05:52:28 AM »
  1.         IEnumerator LoadPic(UITexture uitextureComp, string filename) {
  2.  
  3.                 string url = "file://" + Application.persistentDataPath + "/tips_image/" + filename;   
  4.                 WWW www = new WWW(url);
  5.                 yield return www;
  6.                 if (www.error == null) {               
  7.                         uitextureComp.mainTexture = www.texture;
  8.                         ScrollViewGO.GetComponent<UIPanel>().Refresh();
  9.                 } else {
  10.                         Debug.Log(www.error);
  11.                 }
  12.                  StartCoroutine(LoadPic(uitextureComp,"abc.jpg"));
  13.  
  14.  
  15.         }

 



That is UITexture Component..sorry for my bad naming. But even I do not alter the material but just the mainTexture like the above code, every pic memory and texture count still cumulative.
 To reproduce, keep assigning photo to the same gameObject's uitextureComp.mainTexture, loop for 100 times, look at the memory usage.

Once again I cannot destroy the gameObject and create a new one when user scrolling. the gameOjbect need to be recycled. So I cannot use destroy immediate method..

10
NGUI 3 Support / UITexture Memory Leak
« on: January 08, 2014, 08:11:11 PM »
  1. UItextureGO.material.mainTexture = www.texture;
  2.                         ScrollViewGO.GetComponent<UIPanel>().Refresh();

I have a 1000 row each row have a UITexture downloaded from internet.
Of course I wont make a 1000 scroll item, instead, I only made 20, I will reposition them, reuse them, when user rolling the scroll view. so item 1 will beceom item 21...item 2 become 22, when scrolling down. It will fine.
But I find that, when I keep scrolling down the memory keep rising up..to 2.0GB and crashed unity....So I guess the uitexture replaced still inside the memory event a new www.texture is assigned...
I tried Resourced.UnloadAsset..but it seems it cannot unload a texture, it can only unload a gameobject...Since the gameobject is to be reused and cannot be destoyed.....

11
Anyway, it is not difficult to calculate that by code...just wanna ask if there is some already exist. it is fine if there isn't .Ngui is great!

12
Sorry my title should be " How to adjust size of a parent to fit its chidren?"

The new UIRect Anchor is powerful, but it can only adjust child positions and size according to its parent container, cannot vice versa. as Now, I want to adjust the parent size to tightly fit all its children and the parent is actually a scroll-able row item ..(think of a facebook wall posts every post have a different height, depending on the post length)..If I anchor the parent top to the child top, the parent and all children will move upward forever...infinite loop happen. I guess all children position some how is actually depend on its parents..

Basically, It just something like: parent scrollable row Height = child title height + child paragraph height. (title anchor to the row top, paragraph anchor to the title bottom)...So cannot anchor scollable row bottom back to child paragraph bottom...it will cause infinite loop...

In addition.I tried to use the new anchor system, but once I upgrade my ngui, all my child sprite alpha value inherited from parents sprite. Which is not the case in the previous version.
Let's say I have a half transparent background sprite with alpha 0.5, which contains a few labels, like title and paragraph. Then All those label will become half transparent as well......That's why I don't want to upgrade to the latest version.....

13
NGUI 3 Support / How to adjust size of a background to fit its chidren?
« on: January 04, 2014, 05:12:31 PM »
I have a background (UISprite), which have two children, one is call title (UILabel) another call paragraph (UILabel).
Because the paragraph have multiline, the height is varied. How can I adjust the height of the background to fit this? I tried UIStretch, but it only allow resizing the background according to one child object but not all children.
Because this background is an scroll item inside a scroll view. The height of the background will be used to make all of them position correctly in a scrollview. So I cannot simply separate the background for title and paragraph......

14
Thx a lot! It work well with UIStretch.
Just add UIstretch in the UISprite (The alert background), target it reference to the child UILabel (the alert text) and then set a negative padding no to the UIStretch.

15
NGUI 3 Support / Re: vertical scrollview with 1000+ row item
« on: December 31, 2013, 04:47:56 AM »
Thx a lot. Nicki, ArenMook!
I tried Plan A, it work perfectly!

Pages: [1] 2