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

Pages: [1] 2
1
NGUI 3 Support / Re: Detect widget collision
« on: March 17, 2015, 03:33:54 AM »
Interesting. I think I will look for another way to design this.
Actually I tried something different and it works for now. My collisions are handled by the map objects invisible markers (on which NGUI anchors to) and my click/drag/etc by NGUI.

But I am curious about your idea to not use UIRoot at all. Is is a best practice with NGUI ??

2
NGUI 3 Support / Re: Detect widget collision
« on: March 15, 2015, 10:42:08 AM »
If I use a panel on each marker my draw calls number will explode because I could have a lot of markers on my map. (a panel = 1draw call, right ?)

I am at this point :

- _mapMarkersRoot
-- _playerMarker (UIWidget, rigidbody, 2D collider)
-- _itemMarker (UIWidget, 2D collider)
-- _itemMarker (UIWidget, 2D collider)
...

Now I get both collide and click detection, but very very strange behaviors happens with the marker players :
  • _markerPlayer hits the buttons (the squares at screen bottom) when I drag the marker vertically on them, but without hitting them.
  • the click event may be in conflict with another event. I have to click/drag several times on the _playerMaker to get the click event. This does not happen when I remove the rigidbody.


3
NGUI 3 Support / Re: Detect widget collision
« on: March 06, 2015, 03:52:19 AM »
Yes it is checked.

I manage to get the collision back by adding a rigidbody on my marker player. But now it spin around like a 2d physical object...

Is there any exemple for my case in your samples ? I am really stuck :/

4
NGUI 3 Support / Re: Detect widget collision
« on: March 04, 2015, 12:35:05 PM »
I cleaned this too. No parent with a rigidbody. But still not any collides.

Here is a screen :

The blue marker with a dagger is the player. I have attached a little script (Move) to drag it and simulate the player movement.

When the Widget collides a yellow one it should trigger the OnCollistionEnter2D function.

All my markers are the same except they don't have the Move script attached.

5
NGUI 3 Support / Re: Detect widget collision
« on: March 02, 2015, 04:27:24 AM »
Ok I clean this. Now all my UIWidget markers have a non trigger 2d collider.
The OnClick came back, but I have no more collision.

I change OnCollisionEnter to OnCollisionEnter2D in my UITriggerEvent-like component :

  1. void OnCollisionEnter2D (Collision2D collision)
  2. {
  3.         Debug.Log("collide");
  4.  
  5.         if (Current != null || BlockSending) return;
  6.  
  7.         Current = this;
  8.         CollisionEnterSignal.Dispatch(collision);
  9.         Current = null;
  10. }

6
NGUI 3 Support / Detect widget collision
« on: February 27, 2015, 05:00:14 PM »
Hello,

I have a map with UIWidget markers. I need to detect collision between them (eg : MarkerPlayer entering GruntPlayer) and detect click, drag, etc...

So each of my marker have a rigidbody and a collider. But it does not fire anymore any OnClick or other "regular" events.

Others infos :
-each collider has 0 on z size.
-I use a modified version of UITriggerEvent but it works well when I remove the rigidbody
-Does not work with UICamera set to 3D UI neither 3D world.
-All my markers are anchored to external gameobjects.
-collider's IsTrigger = true;

Where I am wrong ?

7
NGUI 3 Support / Re: SetAnchor without affecting scale.
« on: February 13, 2015, 06:07:19 PM »
I tried to do :
  1. Vector2 dummyPosOnScreen = _mapCamera.WorldToViewportPoint(_dummy.instance.transform.position);
  2. transform.position = new Vector3( dummyPosOnScreen[0], dummyPosOnScreen[1],0);

It almost do the job but the marker moves strangely. Like a parallax effect. I think there is a ratio problem to solve between the camera. Have you an idea on this ?

EDIT : Find out !!

  1. NGUIMath.OverlayPosition(transform, _dummy.instance.transform.position, _mapCamera, UICamera.currentCamera);
  2.  
  8)

8
NGUI 3 Support / Re: SetAnchor without affecting scale.
« on: February 13, 2015, 02:11:19 PM »
Yep, but the object in question (OnlineMaps component) can't be in UIRoot due to the scale transformation.

9
NGUI 3 Support / SetAnchor without affecting scale.
« on: February 12, 2015, 06:23:57 AM »
Hello,

I add ngui prefabs dynamically that I have to anchor on regular gameobject outside the UIRoot. (They are some map markers).
The problem is that this gameobject as a World scale of 1.
So when I do the Anchor, the UIWidget size go from 80 to 2.
I tried to reset the UIWidget size to 80 (the original size) after the anchoring, but this makes offset my UIWidget out of the Panel...

I read the doc and, indeed, the target affect the actual UIrectangle.

So, what is the correct way to anchor a object with a UIRoot outside GO without affecting its scale?
         

10
NGUI 3 Support / Re: Compute mesh inertia tensor failed with AddChild
« on: February 12, 2015, 04:36:50 AM »
It was due to the fact that I parent a non NGUI object (it is a OnlineMaps plugin, which display a googlemap) which does not like at all the scale manipulations.
I solve the probleme by parent it outside the actual UIRoot.
Thx

11
NGUI 3 Support / Compute mesh inertia tensor failed with AddChild
« on: February 11, 2015, 05:42:42 PM »
I have some exceptions that I don't understand.

  1. Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
  2.  

This is thrown by :

  1. MapUIRoot = Resources.Load("Components/com_map/Views/Templates/_mapUIRoot") as GameObject;
  2. GameObject MapLayer  = Resources.Load("Components/com_map/Views/Templates/_mapLayer") as GameObject;
  3.  
  4. MapLayer = NGUITools.AddChild(gameObject,MapLayer);

How can I solve this ?


12
NGUI 3 Documentation / Re: Property Binding (data binding)
« on: January 27, 2015, 05:14:54 PM »
Thx Coeing, looks like interesting, but I prefer to keep focus on my actual framework (StrangeIoC).

I have question for ArenMook : is it worth to worry about performance impact of PropertyReference since it uses reflection ? How many propertyref could we use at once ?

Thx,

13
NGUI 3 Documentation / Re: Property Binding (data binding)
« on: January 21, 2015, 05:30:50 PM »
Is there a way to bind to/from a non monobehaviour model property ?


14
NGUI 3 Support / Data binding on non monobehaviour
« on: December 18, 2014, 05:33:30 PM »
Hello,

I wonder how to do a data binding on a non behaviour class.

Ex :

  1.         public class Item{
  2.                 public int Id {get;set;}
  3.                 public Vector2 GeoCoord{get;set;}
  4.                 public string State{get;set;}
  5.                 public string Name{get;set;}
  6.                 public Type Type{get;set;}
  7.                 public string Icon{get;set;}
  8.                 public int Aura{get;set;}
  9.                 public Dictionary<string, int> GOInstanceId{get;set;}
  10.                 private int ownerId;
  11.                 public int OwnerId{
  12.                         get{
  13.                                 return ownerId;
  14.                         }
  15.                         set{
  16.                                 ownerId = value;
  17.                                 switch(ownerId){
  18.                                         case -1 :       State = "deleted";
  19.                                                                 break;
  20.                                         case 0  :       State = "invisible";
  21.                                                                 break;
  22.                                         case 1  :       State = "free";
  23.                                                                 break;
  24.                                         default :       State = "owned";
  25.                                                                 break;
  26.                                 }
  27.                         }
  28.                 }
  29.                 public Item (){
  30.                         GOInstanceId = new Dictionary<string,int>();
  31.                 }
  32.         }

Then I have some view elements : map markers, details info panels with input text, labels...

Is it possible to link this element with the model ?

15
NGUI 3 Support / Re: UICamera.onClick does not exist...i
« on: December 18, 2014, 03:32:27 AM »
I found my error. (Indeed, your code is my first version)

I simply put it in a OnEnable() so the Static Class were not loaded yet...

Pages: [1] 2