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

Pages: 1 2 [3] 4
31
Are you talking about a combination between http://www.danielhanly.com/blog/tutorial/pinch-to-zoom-through-unity3d-on-ios/ and (non-Unity, but the math is the same) http://adtsai.blogspot.co.uk/2010/09/pinch-zooming-using-xna4-on-wp7-getting.html ?

So you can pinch-zoom around your finger coordinates instead of the texture's center?

32
NGUI 3 Support / Re: Script Question
« on: August 23, 2013, 12:27:26 PM »
  1. public UILabel label;
  2.  
  3. private int mScore = 0;
  4. public int score {
  5.    get {
  6.       return mScore;
  7.    }
  8.    set {
  9.       if (value != mScore) {
  10.          mScore = value;
  11.          label.text = mScore.ToString(); // Automatically updates the label any time the score gets updated :-)
  12.       }
  13.    }
  14. };
  15.  

  ;)

33
NGUI 3 Support / Re: UILabel Multiline help!
« on: August 21, 2013, 10:27:04 AM »
So someone else will be editing the text. Will they be doing that from within the Unity Inspector itself?

Or, can they save their text to a file somewhere and have you read it in via code, and assign it with 'myLabel.text = ...' ?

If they are going to be directly modifying the text from the Unity Inspector, then yes, you'll have to .Replace() like you mentioned. Because what your code sees is the escaped value of that: "... in \n order to..." would be "... in \\n order to" (double '\\' instead of a single '\').

All my developers save all their text into a text file, and I parse that file myself. Then all of their literal '\n' in text turn into natural newlines in the Inspector.

34
NGUI 3 Support / Re: UILabel Multiline help!
« on: August 20, 2013, 05:38:21 PM »
Are you putting a literal "\n" in the Editor? You shouldn't actually see "\n" in the Editor: you should see a literal newline in the Inspector box.

Take a snapshot of what you see in the Inspector if this isn't the case.

35
NGUI 3 Support / Re: UIEventListener vs OnClick
« on: August 20, 2013, 08:56:56 AM »
An example would be:

If you construct a button (MyStartGameButton.prefab) and child it under a UICamera hierarchy, that UICamera will try to pass it an OnClick event. If there is no component attached to it, nothing happens, as there is no receiver. But, if you define the 'void OnClick()' method in a new component, and attach that component to the MyStartGameButton, the UICamera will pass the OnClick event to it.

(As an aside, if you attach 20 different components to the same button, and each of them had its own OnClick method defined, then all of those components receive that OnClick event. That's a lot of clicks for a single button. ;) )

Alternately, let's say that you want to define a single component in your scene to handle all the buttons therein. You can create a single controller class and use the 'UIEventListener.Get(...)' subscription model to point to each of the buttons and subscribe to each of their OnClick events. Then all of the OnClick events passed from the UICamera are returned to that single component, and you can handle them all in one place (instead of having dozens of components all around your scene).

36
Is this "world space" option available on TweenPosition.cs itself, in its parent UITweener.cs, or its parent IgnoreTimeScale.cs ?

I've showing a Debug view of the Inspector, and I haven't found any mention of "world" or "local" in either of those files.  ???

37
NGUI 3 Support / Re: Is there a guide for creating custom widgets?
« on: August 13, 2013, 12:50:59 PM »
How would you define the borders on the image? Are the borders part of the original source image, or are they "tacked on" at runtime (as in, part of the same sprite atlas as the source image, but made up of a different image)?

If the borders are part of the source image, how would you define the width of the borders? Is it only the outside 1px, or 2px/5px/50px?

38
I've got multiple transforms positioned around my environment: some are sources (where the TweenPosition tween begins) and the others are destinations (where the TweenPosition tween ends). I randomly choose one source and one destination Transform, instantiate my object, and call:
  1. TweenPosition tween = TweenPosition.Begin(newMonster.gameObject, 5.0f, randomDest.transform.position);
  2. tween.from = randomSource.transform.position;
  3. tween.to = randomDest.transform.position;
  4.  
This appears to work correctly when the randomSource and randomDest are located under the same parent, with the same scale.

It does not work correctly if they are in different parents, with different scales.

If I modify NGUI/Scripts/Tweening/TweenPosition.cs to use '.position' instead of '.localPosition', it appears to work fine when this is the the case.

Is there a reason why '.localPosition' is being used instead of '.position' ?

39
NGUI 3 Support / Re: Scaling UI between resolutions
« on: July 22, 2013, 03:11:51 PM »
I'd like to ask for clarity: Do you want your UI to scale (stretch) or reposition (anchor/align)?

Something I quite like about both UIStretch and UIAnchor is that you can specify the panel or another UIWidget (like a UITexture, UISprite or UILabel) as the anchor reference point. That way, I have a small window that uses a UISprite as its background, and can put my "Close Window" button to be cemented against its top-right corner, regardless of the size of the entire window. It also means that my backgrounds can be stretched to exactly the size of that UIWidget if I don't want it to stretch across the entire UIPanel.

40
NGUI 3 Support / Re: Errors on importing NGUI
« on: July 19, 2013, 02:04:32 PM »
This seems similar to http://www.tasharen.com/forum/index.php?topic=4179.0

Do you have any other (3rd-party or your own) script that defines 'CharacterInfo' ?

41
NGUI 3 Support / Re: UILabel Rendering Bug
« on: July 17, 2013, 04:30:19 PM »
Can you loop through all your Labels, buttons, etc., and see that their Depth values are set correctly (none of them are reusing values that others need)?

When you return to Panel_1, what happens to Panel_2? Does it get destroyed? Does it get disabled? Is it still active but just moved off-camera?

42
NGUI 3 Support / Re: Moving buttons in game not based on mouse over.
« on: July 17, 2013, 04:25:48 PM »
If these are all the stock UIButton instances, they each have the UIButtonOffset component attached to them. You can grab that component and then call the OnHover() method directly whenever the key is pressed. You will need to store a reference to those UIButtons somewhere, though, so you can specify the 2nd weapon.

  1. UIButtonOffset bOffset = myWeapons[2].gameObject.GetComponent<UIButtonOffset>();
  2. if (bOffset != null) {
  3.    bOffset.OnHover(true); // or false to de-selected it
  4. }
  5.  

43
NGUI 3 Support / Request: UIButton alignment options
« on: July 17, 2013, 01:06:29 PM »
EDITED for clarity:

There are three UIWidget-derived objects in NGUI: UILabel, UISprite, and UITexture. The UIWidgetInspector class utilizes this fact and offers a pivot alignment control within the Unity Inspector, which is awesome for when I want to align these against one edge, then change my mind and align them against a different edge.

The UIButton and UIImageButton classes do NOT derive from UIWidget, however, and I wonder how difficult it would be to create the same kind of pivot alignment controls for those. I find myself resizing buttons (by resizing the UISprite and UILabels within them) in the editor, which requires adjustment to the parent GameObject and its BoxCollider each time.

In order to manually set a button's pivot to the bottom-right, I need to:
  • Scale the child UISprite to the desired size, then offset it by -1/2 its x scale and 1/2 its y scale (the sprite will appear too high and too far left)
  • Use the same x and y positions for the UILabel as the UISprite (the label should appear to be centered over the UISprite, which is up and left of the main UIButton's center point)
  • On the parent UIButton's BoxCollider, match both the UISprite's x and y positions as well as the x and y scales (the collider should now align over the top of the sprite)
  • Now, the button's pivot should be in the bottom-right corner of the button

.. ...
Once the button's pivot is in the bottom-right corner, if I decide to increase the offset from the edge of the panel, there's no need to recalculate the UISprite's dimensions (plus the edge offset) each time: I can simply set the GameObject's position directly to the desired offset.

But if I want to change the pivot (like if I decide the button should go in a different corner, or even centered in the panel), I have to repeat steps 1-4 again with the new offsets.

Could I request a similar "one-button solution" like we have with the UIWidgetInspector's alignment tools, for UIButtons an UIImageButtons? That would be awesome!

44
NGUI 3 Support / Re: Parenting NGUI widgets together
« on: July 17, 2013, 12:15:46 PM »
eyali: That is correct, an empty GameObject.

Create the main panel as normal.
Create a new (empty) GameObject
Create 3 buttons, as children to that new GameObject.

In the Project window of Unity, create a new prefab and drag the new GameObject with those 3 attached buttons into the new prefab instance.

Then if you have different scenes with their own panels, you can still instantiate the prefab you've just created and get the same button layout everywhere (good for consistency across screens, which players like).

45
NGUI 3 Support / Re: Fixed width UI
« on: July 17, 2013, 12:12:51 PM »
In my experience, all of the UI that I've created with NGUI have been fixed width, unless I specifically anchor (UIAnchor.cs) any parts of the HUD to a corner of the screen. So all my iPad, iPhone 4, iPhone 5, and Android ports get the same dimensions for the UI layout (so it sometimes looks "squished" in the middle for some devices like the iPad, and then as far too much screen real estate on other devices like the iPhone 5).

What are you seeing when you create your UI that it's NOT giving you a fixed width?

Pages: 1 2 [3] 4