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

Pages: 1 [2] 3 4 ... 11
16
NGUI 3 Support / Re: Offscreen object indicator [Almost solved]
« on: October 02, 2015, 02:16:19 AM »
I got to bump this, I need some help

17
NGUI 3 Support / Offscreen object indicator [Almost solved]
« on: October 01, 2015, 06:48:20 AM »
Hi I am trying to get offscreen object indicators to work...I know how to position them on the edge of the screen but I am not able to figure out how to rotate the indicator so it is both placed on the edge of the screen and at the same time points in the direction of the object that is offscreen.

Here is what I have:

Update loop


  1. //Converting to viewport point because it's easier to find point on the edge of the screen
  2. var worldToViewportPoint = _gameCamera.WorldToViewportPoint(Target.position);
  3. //Convert player position to screen point (this is constant because player is always centered, it is linked to game camera)
  4. var playerWorldToScreenPoint = _gameCamera.WorldToScreenPoint(GameController.Instance.Player.CharacterTransform.position);
  5.  
  6. //Clamp the target position to edge of the screen (take GetPixelSizeAdjustment  into account since i am not using pixel perfect)
  7. var screenPosClamped = new Vector3(Mathf.Clamp(worldToViewportPoint.x, 0f, 1f),Mathf.Clamp(worldToViewportPoint.y, 0f, 1f), 0);
  8. var position = new Vector3((screenPosClamped.x * Screen.width - HalfScreenWidth) * UIRoot.GetPixelSizeAdjustment(_indicator.gameObject),
  9.                                         (screenPosClamped.y * Screen.height - HalfScreenHeight) * UIRoot.GetPixelSizeAdjustment(_indicator.gameObject), 0);
  10.  
  11. //This gives me for one point something like this: (427.0, 191.6, 8.7) (-455.1, 360.0, 0.0)
  12. //So I suspect this is something that is causing trouble
  13. Debug.Log(playerWorldToScreenPoint.ToString() + " " + position.ToString());
  14.  
  15. //Set indicator prefab position at the edge of the screen (THIS IS WORKING CORRECTLY
  16. _indicator.localPosition = position;
  17.  

My question is what I need to do so that indicator rotates towards the player? I tried all kinds of combinations looking at the direction from those two points and
using LookAt and Slerp but no solution gives me good result. What is the proper way of doing this?

Thanks!


18
NGUI 3 Support / Re: Where should I get the latest v3.9.1?
« on: July 22, 2015, 02:18:12 AM »
I am interested in new version as well

19
NGUI 3 Support / Lots of UIPanels in the scene proble
« on: July 19, 2015, 05:56:43 AM »
Hi!

I have a lot of UIPanels in the scene which all gets disabled in runtime, and only one that is needed is visible and that is fine, but editing panels in editor is somewhat slow. Is there any trick or editor script that will enable UIPanel when gizmo or icon in the scene view is clicked or something like that?

Thanks!

20
NGUI 3 Support / Two ScrollView questions
« on: February 04, 2015, 07:39:02 AM »
Hi!

I am more than happy user of NGUI and I use scrollview component a lot, but I frequently encounter two things with it that I would like to resolve finally.
1.) I usually have structure like this:

UIScrollView
   UITable
    (dynamically created items -> for example UISPrite)

so if I at one point have enough items to make table scrollable it scrolls fine but next time when there isn't enough items in the scrollview/table that will cause to scroll it will scroll (even if "Cancel drag if it fits" is set to true)...this happens if I use drag before clicking on the scrollview...I tried everything that I could to reset position,clipping, to reposition table,etc....but no luck. Question is what is the proper way to reseting the scrollview after populating dynamically contents?

2.) When I slide scrollview, for example from left to center of the screen, elements in the scrollview appear to slide more than scrollview and then snap back to proper place. Also when scaling scrollview from 0.1 to 1 for example, for visual effect, often elements in the scroll view doesn't properly position themselves, they snap back when scrollview is clicked/dragged. Is there any workaround for this?

Thanks a lot!

21
NGUI 3 Support / UIEventListener subscribe/unsubscribe
« on: January 29, 2015, 04:37:58 AM »
I was wondering if it is needed to unsubscribe onClick event for example that is subscribe to with UIEventListener?

here is what i am doing

  1. UIEventListener.Get(Button).onClick += go =>
  2.                     {
  3.                         Debug.Log(go.name);
  4.                     };
  5.  
  6. ...
  7.  
  8. UIEventListener.Get(Button).onClick -= go =>
  9.                     {
  10.                         Debug.Log(go.name);
  11.                     };
  12.  

Unsubscribe part gives me warning in Visual Studio...what is the proper way of doing this? Thanks!

22
NGUI 3 Support / Re: Render panel over 3d object?
« on: January 26, 2015, 03:42:30 AM »
Hey, thanks man for this neat explanation! Finally somebody to sort it out!
I managed to get it working, except the part with separate camera. I am not sure how do you mean that you "position camera appropriately"? Does it need to match UI camera? and is this possible with perspective camera?

Thanks again!

23
NGUI 3 Support / Re: UIPanel with soft clipping on nested skinned mesh
« on: December 26, 2014, 04:00:13 AM »
I would appreciate some help with this :)

24
Don't destroy/disable objects in OnTriggerEnter/OnCollisionEnter, make a coroutine to destroy/disable them instead...I believe simple method will work too.

25
NGUI 3 Support / Re: UIPanel with soft clipping on nested skinned mesh
« on: December 25, 2014, 11:29:45 AM »
I was banging my head with this all day and I can't figure out where what goes? Can somebody give steps how to setup this please! Thanks!
edit:
where should panels go? When I place the shader to 3d model (simple cube for testing) it dissapears

26
NGUI 3 Support / Re: Using widget rect to be used in OnGUI?
« on: December 23, 2014, 12:16:55 PM »
i encountered one more thing, and i think this is the last one to solve so that i can say i get it! :)

unfortunately the plugin i am using (UniWebView, for displaying web pages for mobile devices) uses some kind of inset structure to define on what area
it will render, it is defined like this inset(left,top,right,bottom) so if it's defined like this inset(5,5,5,5) it means that it will render to rect that is 5px from edge of the screen (left,top,right,botom). so to get the rect i got from the widget i tried using something like this:

  1. _webView.insets = new UniWebViewEdgeInsets((int)rect.y,
  2.                                                         Screen.width - (int)rect.width - (int)rect.x,
  3.                                                         (int)rect.y,
  4.                                                         Screen.width - (int)rect.width - (int)rect.x);
  5.  

where rect is defined using widgets dimensions like this:

  1.         rect.Set(Screen.width - cam.WorldToScreenPoint(Widget.worldCorners[2]).x,
  2.                  Screen.height - cam.WorldToScreenPoint(Widget.worldCorners[2]).y,
  3.                  cam.WorldToScreenPoint(Widget.worldCorners[2]).x - cam.WorldToScreenPoint(Widget.worldCorners[1]).x,
  4.                  cam.WorldToScreenPoint(Widget.worldCorners[1]).y - cam.WorldToScreenPoint(Widget.worldCorners[0]).y);
  5.  

this works well if wigder is centered, so insets for top and bottom are the same but i have situation where i need to move widget slightly down to make room
for navigation and in that case i can't get insets for top and bottom right!

i tried using local poisition on the widget,converting it to world coords and subtructing from Widget.worldCorners[0].y but couldn't work it out the proper way.

help!

27
NGUI 3 Support / Re: Using widget rect to be used in OnGUI?
« on: December 23, 2014, 05:34:00 AM »
Just to answer my own question :)

this should be enough:

  1.         rect.Set(Screen.width - cam.WorldToScreenPoint(Widget.worldCorners[2]).x,
  2.                  Screen.height - cam.WorldToScreenPoint(Widget.worldCorners[2]).y,
  3.                  cam.WorldToScreenPoint(Widget.worldCorners[2]).x - cam.WorldToScreenPoint(Widget.worldCorners[1]).x,
  4.                  cam.WorldToScreenPoint(Widget.worldCorners[1]).y - cam.WorldToScreenPoint(Widget.worldCorners[0]).y);

28
NGUI 3 Support / Using widget rect to be used in OnGUI?
« on: December 23, 2014, 05:14:52 AM »
Hi! I am using plugin that displays web pages in OnGUI loop and requires Rect to be defined. I want to position a ngui widget (or sprite it doesn't matter) so that I can
render OnGUI content on that widget's rect. I have trouble converting ngui's left-top-right-bottom to rect... it should be fairly simple...furthermore, on non pixel perfect setups is it needed to be used UIRoot.GetPixelAdjustments?

Thanks!!

29
Hi!

i have scrollview with table that positions bunch of buttons horizontaly and i want clipping to work from left to right edge of the screen for every resolution and it should fairly easy to setup...I am a bit frustrated with this since i couldn't manage to make it right. currently i have setup for lowest resolution and let it work that way on higher resolutions (it doesn't stretch to the edge of the screen entirely)

i tried anchoring the scroll view but clipping region is wrong.

checkout the photo and please help, it seems that i am missing something...thanks!

30
NGUI 3 Support / Re: controling sprite tiling?
« on: December 05, 2014, 05:45:44 AM »
i was thinking about scale or repeat of tile

Pages: 1 [2] 3 4 ... 11