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

Pages: [1] 2
1
NGUI 3 Support / Re: Right To Left UIGrid?
« on: June 24, 2014, 06:13:55 PM »
Specify a negative cell width, and there you go.

This isn't perfect, since it's a bit of work to figure out where to put the pivot, but it works. Thanks!

Edit: Actually it works fine. I'm not quite sure why, probably because of the negative math, but switching the UIGrid 'pivot' (not the containing widget's pivot) to Top Left makes the grid behave exactly how I was expecting it to.

2
NGUI 3 Support / Re: Right To Left UIGrid?
« on: June 23, 2014, 04:10:19 PM »
That's not ideal because that flips the contents of the grid as well, making any graphics and text render backwards. Also, the scale values in the inspector are disabled by NGUI.

3
NGUI 3 Support / Re: Add Delay to UIEventTrigger
« on: June 23, 2014, 03:16:48 PM »
You should be able to delay the commands in that script. Invoke(Application.LoadLevel("Play"), 1.0f); should work. You wouldn't need to move anything into separate scripts.

4
NGUI 3 Support / Re: Add Delay to UIEventTrigger
« on: June 23, 2014, 12:11:06 PM »
I'm not sure exactly what you mean, but if you're trying to load a scene at a button press, but want the animation and sound to finish before doing so, you could try an Update loop or a coroutine WaitForSeconds(); you can look up how to do coroutines in the Unity documentation. Although that might be a little elaborate for your needs.

The simpler solution might be the update loop. It's probably not ideal, since coroutines are probably more efficient, but it's easier to implement:
  1. Update ()
  2. {
  3.    if (Time.time > nextTime)
  4.    {
  5.       Application.LoadLevel(levelToLoad);
  6.    }
  7. }
  8.  
  9. Button ()
  10. {
  11.    nextTime = Time.time + 1.0f; //delay in seconds
  12.    levelToLoad = 0; //level you want to load
  13. }
  14.  

Just set your delay as long as you need to complete the tween and audio. :)

5
NGUI 3 Support / Right To Left UIGrid?
« on: June 23, 2014, 11:25:00 AM »
Is there any way to make the UIGrid organize its contents in RTL? Setting the pivot to Top Right is half way there, but each row still organizes itself in LTR.

6
NGUI 3 Support / Re: UIGrid questions
« on: June 11, 2014, 12:08:37 PM »
Thanks, that worked. They're behaving much more rationally now.
I still wish the grid could be organized right to left, and that might even make sense as an extension to localization for right to left languages. I thought about flipping them the grid object over but that's a tacky solution and rotation on other axes is disabled for NGUI objects. I may (attempt to) add the functionally myself, but that'll make updating NGUI tricky, so it would be nice to see as an official feature.

7
NGUI 3 Support / Re: iOS Build Error 3.6.3 UnityEditor
« on: June 11, 2014, 11:58:59 AM »
Go to the offending line of code and make it look like this:
  1. #if UNITY_EDITOR
  2.         Unity.Undo.RegisterCreatedObjectUndo()
  3. #endif
  4.  
Don't replace the Unity.Undo thing though, just add the other two lines, exactly as typed above.
This is supposedly fixed in an update, but I haven't updated yet.

8
NGUI 3 Support / UIGrid questions
« on: June 10, 2014, 07:21:30 PM »
Although it's possible to set the Pivot to 'Top Right', I'm wondering if there's a way to force a UIGrid to organize the items from right to left, rather than left to right. Using alphabetical ordering and adjusting names of the children accordingly won't work; that merely reorganizes the children, left to right, but with the children in the opposite order. What I am trying to accomplish is a row of health icons attached to the right side of the screen, limited to 6 per column. The problem is, the new column starts at the left end of the new row.

Besides my problems with left to right, I'm having some anomalous behavior where the 6th icon on the second row decides to start it's own new row. I'm not manually adjusting anything, I'm leaving everything up to the UIGrid component, so I'm not sure what's causing it. Below is the entire code that interfaces with the UIGrid, I add and remove icons by enabling or disabling their UISprite to make them invisible. I am renaming them so that Alphabetic sorting will organize them according to their index in the list of UISprites to show/hide; however, this causes even more unusual behavior including random gaps in the rows.

  1. public void CreateIcons (int current, int maximum)
  2. {
  3.         grid = GetComponent<UIGrid>();
  4.  
  5.         for (int i = 0; i < maximum; i++)
  6.         {
  7.                 GameObject newIcon = NGUITools.AddChild(transform.gameObject, armorIcon);
  8.                 icons.Add(newIcon.GetComponent<UISprite>());
  9.                 newIcon.name = i.ToString();
  10.                 grid.AddChild(newIcon.transform);
  11.         }
  12.         DisplayIcons(current);
  13. }
  14.  

Edit: I believe I've solved the problem with mysterious alphabetical sorting order; there are twelve icons. 10 comes after 1. The sorting is strictly alphabetical, not lexicographical. I'll need to prefix extra 0's before single digit numbers.

9
NGUI 3 Support / Re: Tween Play On Awake?
« on: June 10, 2014, 06:54:18 PM »
Solved: Disabling (component checkbox) the tween and using the UIPlayTween script with the setting If target is disabled set to 'Enable Then Play' is a clean solution for Play on awake. Also, in order to play a tween from the beginning without reversing, the necessary code was ResetToBeginning().

10
NGUI 3 Support / Re: bug uiinput 3.5.7
« on: June 10, 2014, 01:23:17 PM »
I haven't used UIInput yet, but the first screenshot looks like you're missing the font, or the font's material is wrong. That's what happens when the quads for the letters get rendered without the material. I've seen this happen with the Unity Text Mesh component when the material is changed at runtime from the special dynamic 'Font Material'. Hopefully that helps?

11
This sounds like something explained in one of the new tutorial videos on scroll views. In the example he constrains the direction, so that when panning the scroll view, clicking on a dragdrop item in the list doesn't prevent you from scrolling. I'm not sure if you could apply this to the nested accordion scroll view, but it might help?

12
You can accomplish that in the exact same way I described above.
Just make a wrapper function for Instantiate() named something like 'Shoot', so instead of calling Instantiate() you call Shoot() and that calls Instantiate() with the parameters you would normally set. Then, if Shoot() is public, you can assign it to the on click event of your NGUI button... However, you might want to take a look at some tutorials for the basics of C# programming, since using functions (aka Methods) is a fairly basic and critical component to writing code.

You can check my code from the previous post for reference on what this description would actually look like, except instead of 'DoSomething' we're calling it 'Shoot'.

13
I edited my earlier post, since I realized I'd misunderstood your original post.

A vague example, based on what you said:
  1. public class YourClass : MonoBehaviour
  2. {
  3.    void Update ()
  4.    {
  5.       if (Input.GetKeyDown(KeyCode.Y)) DoSomething();
  6.    }
  7.    public void DoSomething ()
  8.    {
  9.       //whatever is currently happening when 'Y' is pressed
  10.    }
  11. }
  12.  

Then your UIButton calls DoSomething() as well, and you can use a UIKeyBinding to make the button be a shortcut for the Y button, so that you don't need the Update() code to be redundant, but only if your virtual 'Y' button will be enabled even when there is a keyboard.

14
NGUI 3 Support / Bugs in NGUITools
« on: June 10, 2014, 11:39:57 AM »
When using NGUITools.AddChild(); the project will not successfully build, because the '#if UNITY_EDITOR' is missing from before 'Unity.Undo.RegisterCreatedObjectUndo()' in one of the variations of the function. I fixed it, so now I'm unable to find where.

Also, when using Web Player, NGUITools produces a mysterious error during runtime if the Prefab Toolbar is open. Commenting out 'comp.SendMessage(funcName, SendMessageOptions.DontRequireReceiver);' stops the error, but prevents NGUI from rendering prefab icons. Closing the toolbar also prevents the error.

15
NGUI 3 Support / Tween Play On Awake?
« on: June 10, 2014, 11:30:56 AM »
There isn't an option on tweens (that I can find) for Play On Awake like on Unity's Audio Source component. I could just disable the component and re-enable it in code, but that's a lot more work than just having the ability for Tweens to not automatically play.

Edit: Another tweening question; how do you make a tween repeatable but play only once? With the Play Style property set to 'Once', I call PlayForward(), and it works, but the next time I call it, it seems to do nothing.

Pages: [1] 2