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

Pages: [1]
1
thanks, I'm trying this now. But UICamera.hoveredObject is not "null" even when I hover over Unity game object that have colliders.
And it sets the same as genericEventHandler (Main Camera in this case)

2
Hi, I got everything done from another my topic (and it works fine) http://www.tasharen.com/forum/index.php?topic=10012.msg47221#msg47221
I have script on my camera to pan with mouse clicked/finger tapped, by the way it's very buggy on android(clipping) :(
  1. private Vector3 startpoint; // startpoint
  2. private Vector3 endpoint; // endpoint
  3. private bool  panning=false;
  4. public float minPosX = 10;
  5. public float maxPosX =10;
  6.         //GameObject CO;
  7. public float minPosZ=-10;
  8. public float maxPosZ=10;
  9. float dist;
  10. bool MouseUse= true;
  11.  
  12. // mainloop
  13. void  Update (){
  14. Ray ray1 = Camera.main.ScreenPointToRay (Input.mousePosition);
  15. Ray ray2 = Camera.main.ScreenPointToRay (Input.mousePosition);
  16. if (Input.touchCount == 1) {
  17.  
  18.         // starts here, left mousebutton is pressed down
  19.         if(Input.GetMouseButtonDown(0))
  20.         {
  21.                 // make ray
  22.                 startpoint = ray1.GetPoint (10) ; // Returns a point at distance units along the ray
  23.                 startpoint.y = 0; // fix z to 0
  24.                 panning = true;
  25.         }
  26.  
  27.         // then left mousebutton is released
  28.         if(panning){
  29.         dist = Mathf.Clamp((Vector3.Distance(endpoint, startpoint)),0,1.0f);
  30.                 endpoint = ray2.GetPoint (10) ; // Returns a point at distance units along the ray
  31.                 endpoint.y = 0; // fix z, somehow its not always 0?
  32.                
  33.                 // Panning
  34.                 if(dist >= 0.1f){
  35.                 transform.position += startpoint-endpoint;
  36.                 Vector3 pos = transform.position;
  37.                 pos.x =Mathf.Clamp(pos.x, minPosX, maxPosX);
  38. pos.z =Mathf.Clamp(pos.z, minPosZ, maxPosZ);
  39.                                         transform.position = pos;
  40. }
  41. }
  42.  
  43.        
  44.         if(Input.GetMouseButtonUp(0)) // release button, stop pan
  45.         {
  46.                 panning = false;
  47.         }
  48.         }
  49. if (MouseUse == true)
  50. {
  51. if(Input.GetMouseButtonDown(0))
  52.         {
  53.                 // make ray
  54.                 startpoint = ray1.GetPoint (10) ; // Returns a point at distance units along the ray
  55.                 startpoint.y = 0; // fix z to 0
  56.                 panning = true;
  57.         }
  58.  
  59.         // then left mousebutton is released
  60.         if(panning){
  61.         dist = Mathf.Clamp((Vector3.Distance(endpoint, startpoint)),0,1.0f);
  62.                 endpoint = ray2.GetPoint (10) ; // Returns a point at distance units along the ray
  63.                 endpoint.y = 0; // fix z, somehow its not always 0?
  64.                
  65.                 // Panning
  66.                 if(dist >= 0.1f){
  67.                 transform.position+=startpoint-endpoint;
  68.                 Vector3 pos = transform.position;
  69.                 pos.x =Mathf.Clamp(pos.x, minPosX, maxPosX);
  70. pos.z =Mathf.Clamp(pos.z, minPosZ, maxPosZ);
  71.                                         transform.position = pos;
  72. }
  73. }
  74.  
  75.        
  76.         if(Input.GetMouseButtonUp(0)) // release button, stop pan
  77.         {
  78.                 panning = false;
  79.         }
  80. }
  81. }
I want that script somehow to know "mouse clicked (or at least is over) ngui, so don't pan"
Now it checks in Update function that mouse is clicked with these lines:
  1. if (Input.touchCount == 1) {
  2.  
  3.         // starts here, left mousebutton is pressed down
  4.         if(Input.GetMouseButtonDown(0))

Is there a way in ngui to check if mouse is clicked? Or detect that mouse is over/clicked ngui?
It's hard for me mostly because of that it must be in update (or there's a better way?)

3
NGUI 3 Support / Re: Prevent interaction behind the ngui objects
« on: June 22, 2014, 01:33:53 AM »
I attached UICamera script to main camera. In that script (UICamera) I set event type to "UI"(also tried "World") and event mask to "nothing".
But game objects that have colliders (box, mesh and etc) still don't respond OnClick, OnHover and I think all the rest functions.
Do I miss something?
I test that with
  1. void OnHover () {
  2.                 Debug.Log("Clicked");
  3.         }

4
NGUI 3 Support / Re: Prevent interaction behind the ngui objects
« on: June 21, 2014, 05:45:44 AM »
Remember -- having a UICamera attached to the game camera is all it takes for it to send out NGUI events like OnHover, OnPress, OnClick, etc.
Did it, but after this mouse doesn't interact with non-NGUI game objects
as I understand I need somehow to work with UICamera.fallThrough but how can I set the hovered object to it, if it doesn't respond to Input functions like OnMouseOver?

5
NGUI 3 Support / Re: Prevent interaction behind the ngui objects
« on: June 20, 2014, 02:08:39 AM »
Well then about 1st NGUI object(sprite) when clicked influencing 2-nd NGUI object which is behind the first <-- about this were the words about container? I still don't get it
the first picture show without container and the second with. But the second doesn't allow to work with them
(the button is blue when the mouse is over it)

UPD:
Ohhh, that was stupid from my side) I just didn't mention that this container should be attached to the needed object (not to the entire root) thanks a lot

6
NGUI 3 Support / Re: Prevent interaction behind the ngui objects
« on: June 19, 2014, 02:43:54 AM »
thanks for advice but it still influence not-NGUI objects when I click on NGUI objects. Also, collider on container, resized to cover my screen. doesn't allow to work with other NGUI objects (which are in container's collider). I think I did it incorrectly. Here's the pic:

7
NGUI 3 Support / Prevent interaction behind the ngui objects
« on: June 18, 2014, 02:16:50 PM »
I know that this question was asked many times but I didn't figure that out
I have buttons, sprites and etc. When I click them - I usually interact with them and every thing which is behind the button, sprite and etc. How to prevent this? (I've seen 1 video on YouTube, where it was shown but I can't find it anymore and seems that browser's history doesn't contain it)

8
NGUI 3 Support / Re: Access NGUI button's notify(OnClick)
« on: June 03, 2014, 02:05:02 AM »
thanks, that helped)

9
NGUI 3 Support / Access NGUI button's notify(OnClick)
« on: June 02, 2014, 07:44:26 AM »
In old NGUI version I had UIButtonMessage script on my button. Button's target was changeable - when I clicked on some object, it became the button's target. But now I try to access NGUI button Notify when OnClick. I haven't found it in button's script, so how can I change the button's Notify (OnClick) through my script? And just to be clear - I need to change the button's notify(target), not the function
 

10
NGUI 3 Support / Re: Event trigger, notify and so on
« on: May 29, 2014, 08:45:46 AM »
Oh, thank you very much. It all looks more easy now, and thanks for optimizing my script :)

11
NGUI 3 Support / Event trigger, notify and so on
« on: May 29, 2014, 06:56:03 AM »
Watched a video tutorial about Event Delegates but still can't get on with it.
I have a Popup List. In previous old NGUI versions I simply had to set some object on Event Receiver and Function Name.
But now, as I understand, I need to set the same object  in Notify in OnValueChange section of Popup List, and set Method (which is function, right?). I made the needed function public but there appeared Arg 0 and I don't know what to set there.
Here's the code:

  1. public static string MyselectedItem;
  2.  
  3.         public void OnSelectionChange (string selectedItem) {
  4.                 UILabel lbl = GameObject.Find("MainBuildPriceText").GetComponent<UILabel>();
  5.                 UISprite sprite = GameObject.Find("MainBuildPicture").GetComponent<UISprite>();
  6.                 if (selectedItem == "[FF6633]Kiosk")
  7.       {
  8.                         MyselectedItem  = selectedItem;
  9. //print ("selectedItem = " + selectedItem);
  10.                         sprite.spriteName = "KIOSK";
  11.                         lbl.text = BuildMain.build1_price.ToString();
  12.       }
  13.                 if (selectedItem == "Store")
  14.       {
  15.                         MyselectedItem  = selectedItem;
  16. //print ("selectedItem = " + selectedItem);
  17.                         sprite.spriteName = "kramnytsia";
  18.                         lbl.text = BuildMain.build2_price.ToString();
  19.       }

With nothing set on Arg 0 it says:
failed to convert parameters
Expected: System.String selectedItem


Edit: Put code in [ code ] tag. -Nicki.

12
NGUI 3 Support / Re: Clip center moves with scroll bar
« on: May 14, 2014, 06:10:39 AM »
But author of this topic http://www.tasharen.com/forum/index.php?topic=3771.0 worked with the 95$ version of NGUI, so it doesn't depend on version(?)

13
NGUI 3 Support / Clip center moves with scroll bar
« on: May 13, 2014, 01:27:01 PM »
I try to make a scroll view that will display at least 2 items. I did as in the NGUI-example and it works. But it when I scroll - clipping center moves as well. In Ngui-example clipping center doesn't move however. It happens with every type if clipping and both with scroll bar or just dragging that panel. Any solutions?

14
NGUI 3 Support / Re: Soft clip center moves with scroll bar
« on: May 13, 2014, 01:59:17 AM »
I have the same issue as the author. How to prevent this problem when clipping center moves?
It happens with every type if clipping

Pages: [1]