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

Pages: [1]
1
NGUI 3 Support / Re: Problem with BB-code in UILabel
« on: August 19, 2014, 08:31:01 AM »
You mean the black [ that comes after the 17?  I copy pasted that into a UILabel here and I can see it just fine?  Try creating a new label perhaps?

2
NGUI 3 Support / Can NGUI use system fonts?
« on: August 15, 2014, 02:52:51 PM »
For reasons that would require a lot of explaining, I need to use the built-in iOS and Android system fonts for an app,  Without having those fonts as part of the app itself.  I managed to find this, which works quite well aside from the 4 year old NGUI portion no longer compiling against current NGUI...
https://github.com/imkira/unity-sysfont/tree/unity4x

So we can attach a SysFont component to a gameObject at runtime on the device, and properly use any iOS fonts that exist.  Looks really crisp too!  The problem is that we need to do per-word highlighting within a string, which this does not support. 

I've been unable to find anything concrete about NGUI's support for these system fonts, so I suspect it is not possible, but figured I'd at least ask if it might be supported in the future?  Seems like quite a neat feature for a wide range of uses, no?

3
NGUI 3 Support / Re: Input stops working on device only
« on: August 14, 2014, 07:32:17 AM »
OH $%&^*, that's the exact version of Unity that i'm using!  Man, I gotta start keeping things more up-to-date, I guess!  Thanks so much for that, I hadn't even thought of upgrading...

4
NGUI 3 Support / Re: Input stops working on device only
« on: August 13, 2014, 10:43:41 AM »
They were actually already using 3D colliders.  Since it was at least something to try, I changed them to 2D colliders, and they would no longer receive mouse input in the editor either!  This is perhaps an interesting hint, anyway!

edit/update: I tried throwing a little testing script in the second scene, as seen here:
http://www.tasharen.com/forum/index.php?topic=4683.0

So my UICamera touches and events are at least actually happening, but it's not hitting my colliders, it's hitting the "nothing"

Another possible caveat that I don't think I've mentioned...  My app starts in portrait mode, for the bookshelf view.  When a book is tapped, it loads a new scene and switches to landscape mode.  Within the editor, I just keep the Game view in landscape for the most part and deal with the ugly library view in favour of seeing the books while I'm working on that part.  The collider positions/sizes reported in the editor do correspond to what i'm getting as output on the device, so I don't THINK that's the problem, but maybe NGUI does something I don't know about when switching from portrait to landscape?  I've tried doing the switch to landscape mode before the new scene load, after scene load, and before/after the sprites are actually created after the scene load, but other than the last one that really screws things up, none of those made a difference for my lack of input.  :(

5
NGUI 3 Support / Input stops working on device only
« on: August 12, 2014, 11:09:37 AM »
I'm working on a book library app, for now the first scene is a bookshelf filled with a grid of book covers that are UI2DSprite with colliders and a script attached to process OnClick.  That works fine, clicking/tapping a book is no problem, then it loads a new scene to display the book itself.  More UI2DSprites are created using downloaded images from Application.persistentDataPath.  These sprites also have a collider and another script attached to process OnClick.  There are also some NGUI buttons for page forward/back/exit.  This part works fine in Editor only, but on an iOS devices, no input is processed. 

So I discovered the NGUIDebug.DrawBounds function that will draw the bounds of my colliders, just to ensure they exist.  That doesn't seem to work on iOS, ok fine. So I just Debug.Log'd the bounds, and the colliders are there, in the correct locations, but still not processing the OnClick method.  Well, maybe it's actually just locked up for whatever reason?  These sprites are technically animations that I process when tapped, but since they aren't animating, I suppose it could just be locked... 

So I added this Console script to my camera, it uses OnGUI methods, and isn't even related to NGUI at all, other than being attached to the same camera, I suppose... 
http://pastebin.com/NrFpiRDB

That console displays a log window and an FPS display with a couple buttons to toggle each.  The console and the buttons work fine, in both scenes, in the editor!  On device, it works fine in the first scene, but when the book is loaded, I can only enable/disable the console itself (via 5-finger-touch), but I can't tap the toggle buttons at all.  So the app isn't locked, it's processing my 5-finger-touch input on device, but other OnGUI input, and all NGUI input is not getting through, again only on device. 

I am surely missing something completely trivial, but the past few hours of attempts have yielded no results.  :(

NGUI version 3.6.9

edit: I should add that touch input is indeed enabled on the UICamera in both scenes.  Also all gameobjects that exist in scene, even those created at runtime, are on the NGUI layer.  At least they are in the editor, where I can see that.  :)

6
NGUI 3 Support / Re: Why ? (some weird things that appends sometime)
« on: August 08, 2014, 11:27:33 AM »
As someone who had that same problem before, with game view hidden behind scene view...  Is there some way you can determine that is happening, and throw a warning into the console or something? 

7
NGUI 3 Support / Re: Prefabs "resetting" when hitting Apply
« on: July 30, 2014, 11:48:12 AM »
I'm using NGUI 3.6.0, haven't kept up on any updates in a month or so, but I think it's still fairly new?? 

It would take me a while to try and repro from scratch vs just using the current prefabs I have, but I'll try to get that soon! 

8
NGUI 3 Support / Prefabs "resetting" when hitting Apply
« on: July 29, 2014, 07:27:14 AM »
I'm making my NGUI UI out of various prefabbed panels.  I have always just duplicated a previous panel and used that to start on the next one.  Now however, I have to create new panels, sprites, and buttons from scratch because of an odd prefab issue.  If I duplicate prefab-1 and rename it prefab-2, then make various changes that break the prefab connection in the process.  Then I drag prefab-2 into my Resources folder to ensure it becomes a "new" prefab, right?  Well both that drag and drop, and any subsequent clicks on the Apply button for that prefab will reset any sprite associations on the child GameObjects.  (edit: I should mention that the sprites are reset to their old sprites from prefab-1)  Their sizing and positioning changes remain intact, just the sprite graphic itself reverts to what it was on prefab-1.  Any ideas?

9
NGUI 3 Support / screen coordinates in editor
« on: July 25, 2014, 09:41:56 AM »
I'm reading in some "legacy" animated storybooks, made in a different engine, but with assets that I can at least mess with in Unity.  For now we'll assume only the iPhone 5 resolution of 1136x640, as I can get the assets at other resolutions as well, but I'm prototyping with the iPhone 5. 

For a given book, I pull down some data from a SQL server (via PHP to JSON) that gives me web addresses to download the assets .zip file and data .plist file.  I have handled the extraction and local device storing of this stuff.  So I'm loading book pages and animations using the WWW interface from persistentDataPath, creating NGUI 2D Sprites for them, and dropping them on the screen.  I'm also reading in the .plist into my own internal class structure.  The issue I'm having, in the editor at least, is with the screen coordinates for animations, which are based on this 1136x640 screen resolution.  The editor does not report Screen.width and height at those dimensions, and fullscreen anchored NGUI sprites are also at strange dimensions.  Rather than pulling out the Game window and running it fullscreen on another monitor, I'd like to just do some calculations on current screen width/height vs expected 1136x640, and modify my animation coordinates accordingly, probably just a single floating point scale value?  Where do I get this value, if it exists?  Do I need to have a fullscreen sprite that is anchored to all 4 sides and use the dimensions of that sprite for my screen dimensions?  Surely that value is obtainable by some other means within NGUI?

TLDR: If a sprite needs to be positioned at 100,100 on an 1136x640 screen, how can I ensure it's positioned properly regardless of current screen width/height in the editor's Game view?

10
NGUI 3 Support / Scene view for portrait mode UI?
« on: June 17, 2014, 08:34:27 AM »
I'm making a "storybook library" type app in portrait mode, and I thought my scene view would display the UI properly, but it's almost as though NGUI defaults to a landscape mode UI in scene view, is that the case?  Anchoring something like a background image to the top and sides of the UI Root object ends up looking something like this in scene view, and only appears properly when I play the app:

http://puu.sh/9xuNb/7f789ebad1.png

Could I be missing an NGUI setting somewhere to switch to "portrait-mode scene-view" or something?  The "Shrink portrait UI" checkbox seems to do nothing in this case.

11
NGUI 3 Support / Re: bug in UILabel?
« on: April 09, 2014, 02:56:08 PM »
Hah, look at that!  I don't always check for my plugin updates, but when I do, they overwrite changes I made to them!  /DosEquis

12
NGUI 3 Support / Re: bug in UILabel?
« on: April 08, 2014, 08:33:23 AM »
Yep, that works of course!  Will you be including it in the next update?

13
NGUI 3 Support / bug in UILabel?
« on: April 04, 2014, 07:41:10 AM »
I was trying to make individual words in a label tappable, for the purposes of highlighting them as they are tapped, and playing the audio for that word.  Colour me amazed to find NGUI already had a function for this!  However, it seems to throw exceptions when you tap on spaces in the label.  I was able to get around it with a dirty try/catch, but perhaps it needs fixing, or I am just missing something?  I'll paste my function for reference, if you're interested! (heavily commented for some new-to-Unity devs joining me soon.)  I'm not sure I can post any code from UILabel.cs where I believe the problem is, so I'll leave that out.  :)


  1.         public void NarrationTapped()
  2.         {
  3.                 HighlightWord(-1);//passing -1 for the word index should clear any highlighting on the string.
  4.                 Vector2 screenPos = Input.mousePosition; //grab screen coords where you tapped
  5.                 Camera cam = NGUITools.FindCameraForLayer (gameObject.layer);
  6.                 Vector3 worldPos = cam.ScreenToWorldPoint (screenPos);//fancy unity convert screen coords to world coords
  7.                 int charIndex;
  8.                 try{ //have to wrap this whole thing in a try/catch because NGUI throws exceptions when tapping on space characters...
  9.                         charIndex = narrationTextLbl.GetCharacterIndexAtPosition(worldPos);//get the index into the string for the character you tapped.
  10.                         string oldText = narrationTextLbl.text;//copy the page text locally so we can mess with it.
  11.                         if(charIndex != -1 && charIndex < oldText.Length)
  12.                         {
  13.                                 if(narrationTextLbl.GetWordAtCharacterIndex(charIndex) != " ")
  14.                                 {
  15.                                         string hexBlue = @"[0000ff]";
  16.                                         string endColorTag = "[-]";
  17.                                         int linkStart = oldText.LastIndexOf(' ', charIndex) + 1; //find the char index for the first character of the selected word
  18.                                         if(linkStart==0) linkStart+= hexBlue.Length;//if you hit the first word, we have to skip the initial bit of BBcode that makes the text black.
  19.                                         int linkEnd = oldText.IndexOf(' ', charIndex);//gets the char index for the end of the selected word.
  20.                                         if (linkEnd == -1) linkEnd = oldText.Length;
  21.                                        
  22.                                         if (linkStart != linkEnd)
  23.                                         {
  24.                                                 oldText = oldText.Insert(linkStart, hexBlue);//insert the blue BBcode before the word.
  25.                                                 oldText = oldText.Insert((linkEnd+hexBlue.Length), "[-]");//and close the BBcode tag
  26.                                         }
  27.                                         narrationTextLbl.text = oldText;//then set the text back to the label
  28.                                         string word = narrationTextLbl.GetWordAtCharacterIndex(charIndex).ToUpper();//get the word now, and uppercase it for the filename.
  29.                                         string fileName = System.Text.RegularExpressions.Regex.Replace(word, "[?!,.;:]", "");//remove punctuations (add to that array if we missed a punctuation type!)
  30.                                         AudioClip snd = (AudioClip)Resources.Load("Words/" + fileName, typeof(AudioClip));//load the sound clip for the word
  31.                                         narrationAudio.clip = snd;//set it
  32.                                         narrationAudio.Play();//play it!
  33.                                 }
  34.                         }
  35.                 }
  36.                 catch{
  37.                         Debug.Log ("you probably clicked on a space");
  38.                 }
  39.         }


edit: here is the exception thrown as well:

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
System.String.Substring (Int32 startIndex, Int32 length) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/String.cs:348)
UILabel.GetWordAtCharacterIndex (Int32 characterIndex) (at Assets/NGUI/Scripts/UI/UILabel.cs:1286)
NarrationLoader.NarrationTapped () (at Assets/Scripts/NarrationLoader.cs:115)

Pages: [1]