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.


Topics - Zophiel

Pages: [1] 2
1
NGUI 3 Support / Novint Falcon Controller; Raycast from sprite position
« on: October 28, 2013, 05:11:39 PM »
Hello,

I was given a Novint Falcon controller to play with in a unity project. Sadly the controller doesnt actually replace the regular mouse so i'm having to roll my own controller.
A sprite is functioning as a cursor that i move around using a delta given by the Falcon. I have also written a button handler but i can't seem to get the raycasting sorted.

Is there an easy way to get a raycast going in NGUI using a sprites position instead of the mouse?

  1. if( Haptics.isButton0Down() && !middleButtonPressed )
  2. {
  3.         middleButtonPressed = true;
  4.         //Raycast
  5.         RaycastHit hit = new RaycastHit();
  6.         if( UICamera.Raycast(  UICamera.mainCamera.WorldToScreenPoint( mTrans.localPosition ) , out hit ) )
  7.         {
  8.                 Debug.Log( hit.collider.name );
  9.                 //SendMessage( "OnClick");
  10.                 //SendMessage( "OnPress", true );
  11.         }
  12. }
  13. else if( !Haptics.isButton0Down() && middleButtonPressed )
  14. {
  15.         middleButtonPressed = false;
  16.         //SendMessage( "OnPress", false );
  17. }

2
Hello,

Ive created a timeline in Unity where you can drag and drop sprite into and then you can drag the sprites at the sides to increase/decrease the width.

It all works great except that i cant seem to determine the centerpoint and the start and end of the widget. Its built as follows:

Container - With a manager script for the objects interactions
      - Background sprite with collider for dragging
      - Arrows for resizing

The code can be seen here: http://pastebin.com/FfzRwKpq

Below is the code i use to see if a clips end or start point overlaps with that of another object in the time line
  1. !timeline.Any( o => o.ValueObject.start <= vo.end && o.ValueObject.end >= vo.start )

But this is giving me very inaccurate results for some reasons. The center point of the clip seems to be fine but any time i check the start and end points it gives very weird results as if the box is shifted over x-amount of pixels.

3
NGUI 3 Support / Drag from scrollview; Creating a copy of selected item
« on: October 08, 2013, 10:20:50 AM »
Hello,

I have a scrollview with a bunch of buttons you can press. What i want to do is if you press a button and drag off of it, a copy should be attached to the mouse that you are able to drop on some area.

I create the copy fine but two things happen. It doesn't react to OnPress( false ) when i release the mouse. And the scroll view keeps moving when i move the mouse up and down.

What would be a solution to fix the scroll view and let the object react to the mouse event sent?

4
NGUI 3 Support / Universal UI woes
« on: July 15, 2013, 07:22:02 AM »
Hello,

I'm having some headache getting my UI ready for a Universal build. The UI was designed for non-retina iPads and the artist has some questions i cant really answer. He was hoping we'd be able to just scale the UI down and make it fit on other resolutions but that doesnt seem to do the trick nice enough as we have some pretty wide or high UItextures and they just get clipped.

The screenshot below is for 768 x 1024


How can i make this correctly fit the other resolutions? Do i need to tell the artist to produce assets for all the various sizes or is there a quick way to scale it all down? I do use anchors for positioning.

Below is a screenshot of the level selection, which uses a lot of UITextures as they are quite big.



I've bought and tried using RetinaPro but that requires a lot of assets to be made and does weird things with positioning.

5
NGUI 3 Support / Spawning a sprite at a touch
« on: June 26, 2013, 09:25:36 AM »
I've been going through search trying to find an answer but i think i dont understand what some of the data under UICamera.currentTouch is for. Right now I use the following which doesnt seem to get me what i need:

  1.                         Ray ray = UICamera.mainCamera.ScreenPointToRay( UICamera.currentTouch.pos );
  2.                         RaycastHit hit;
  3.                         Physics.Raycast( ray, out hit );

I have a center anchor point where I parent the widgets and then i need to set their localPosition to the touch position.

6
Hello,

I have several scroll views, all setup the same. I fill the grid dynamically with sprites and use .Reposition() when i'm done adding to sort them. Something happend recently in the project in some of the views that if you click in the view, the grid floats down a few pixels.

Without posting all the code, anyone have any inkling of an idea as to why? Grid cells are 150 x 200 and the sprite inside it is 88 x 88.

7
NGUI 3 Support / Consuming/waiting for new touch
« on: April 04, 2013, 07:02:04 PM »
Hello,

I've written a spell casting system. Pressing a button will set a spell's state to ready. The spell then waits for a touch phase ended to trigger. But pressing a NGUI button also sends that event to the spell casting it when you let go of the NGUi button.

What's the best way to handle something like this?

  1. void OnPress( bool isPressed )
  2.         {
  3.                 if(!isPressed) EquipmentManager.Instance.UseRune( runeIndex );
  4.         }

  1. override public void Use()
  2.         {
  3.                 if( isReadyToCast ) base.OnEffectCancel();
  4.                 else isReadyToCast = true;
  5.         }
  6.  
  7. override public void Update()
  8.         {
  9.                 if( isReadyToCast )
  10.                 {
  11.                         Debug.Log( "Ready!" );
  12.  
  13.                         if( Input.touchCount > 0 && Input.touches[ 0 ].phase == TouchPhase.Ended )
  14.                                 Debug.Log( "Cast Spell!" );
  15.                 }
  16.         }

8
Hello,

I updated my NGUI scripts through the asset store and I am now getting the following error after i stop playing a scene in the editor: Scene is being destroyed while there are hidden renderers that are using it. This is likely an editor script creating objects with hideFlags and leaving them enabled.

I've also set up 4 sprites, who's spriteName i change through code but for some mystical reason the old sprite doesnt seem to disappear anymore. Prior it would update fine.

[Edit] after some toggling some things on and off it almost looks as if NGUI is caching the graphics or something silly. I toggle off a huge part of the UI and then on play, as if by magic, that part of the ui shows up again. But i can't select it in the editor.

[Edit 2] Turning more things off and deleting things while running it left something like a cached image that i couldnt select. It was even there after deleting everything in the scene which led me to assume it was a Unity error of some kind. A quick restart seems to have cleared it up.

When in doubt, reboot.

9
NGUI 3 Support / Touches and Event System
« on: December 05, 2012, 05:36:17 PM »
Hello,

I've been reading several threads on the NGUI event system but i'm unsure how to set it up correctly with multi touches. If i got this right i need to at least attached an instance of UICamera to my main game camera. But how do i convert the following code to correctly use the NGUi events?

  1. //Touch and drag
  2. if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
  3. //Pinch to zoom
  4. if (Input.touchCount > 1 && (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved))

Reason being that when i press a button in my scene the camera reacts to it.

Cheers

10
NGUI 3 Support / Grid with a lot of children crashes IOS Build
« on: December 03, 2012, 12:17:42 PM »
Hello,

I've created a draggable clipped panel as the documentation shows. But adding around 12 children will crash the IOS app but work fine in the editor. No errors show up in the XCode console either. I've reduced the children to about 4 and that seems to work fine.

I got 12 textures that i need to be fullscreen. Any idea why this is causing the crash?

11
NGUI 3 Support / panels/sprites outside of NGUI camera and LookAt()
« on: November 01, 2012, 08:01:19 AM »
I have an Effect Panel attached to a ship with a health sprite attached to it that i have looking at the camera.
But as the ship moves, the sprite get's distorted, which i think is due to the lookAt() code.

Any way to fix this?

12
NGUI 3 Support / Blurry sprite
« on: September 25, 2012, 09:37:00 AM »
Hello,

This problem occurs on SOME machines. Buttons will look sharp but any text will appear blurred.

How can i fix this?

13
NGUI 3 Support / Centering a label
« on: August 29, 2012, 10:07:18 AM »
Hello,

Is there a quick way to center a label? I would like to center my text on screen. So i added a UILabel and set it's line width to the size of the screen, but then noticed there is no center text option!

14
NGUI 3 Support / Spacing buttons evenly across screen width
« on: August 19, 2012, 03:18:58 AM »
I've recently been doing a unity to flash project where I had my UI made in Flash. Sadly, since that is in beta, i'm forced to port back fully to unity for a standalone (exe/app) project and am since converting the UI to NGUI.

In flash i would just space the buttons out evenly across the screen space but that is not so easy in NGUI. How would i go about setting this up correctly?

15
NGUI 3 Support / NGUI + Particles
« on: August 04, 2012, 11:50:50 AM »
I have some particle emitters in my scene i want to get rid of to reduce the drawcalls.

If posible, how do i go about using NGUI combined with the particle systems?

For bonus points: any way to reduce the drawcalls from trail renderers?

Pages: [1] 2