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

Pages: 1 [2] 3 4
16
NGUI 3 Support / Re: OnClick issue
« on: May 26, 2014, 02:31:17 AM »
I think I almost got the problem here.

If something has collider is near the drag drop surface, it has difficulties to detect the valid surface if I want to drag and drop items on the surface. However I don't how to fix it and it is impossible to take out that something and its collider too. So it is the tough probelm.

17
NGUI 3 Support / Re: OnClick issue
« on: May 25, 2014, 11:40:27 PM »
However, I use the drag drop system on that too, I have tried to set the event type to be world but when I use the drag drop system, it seems that I can drag the icon only outside the grid. It is so strange.

Moreover, I have set a dragdropsurface on one place but I don't know why I can only drag and drop my items on only certain location of that surface. Quiet strange also. If I change my location and so drag and drop my items on the location of the surface that originally unable to drop the items on, it would successfully drop on the surface. It is very strange.

18
NGUI 3 Support / OnClick issue
« on: May 25, 2014, 04:30:28 AM »
How can I do if I want the onclick function happen on the gameobjects,

which means that if I click on one gameobject, that do something.

How can I implement onclick function on this.

It is because I have tried to add UIcamera on Main Camera, add box collider with trigger on the gameobject and put a script that has OnClick function inside, but it does not work properly, it seems that only a few location I clicked on and so the onclick event begin.

19
NGUI 3 Support / Drag Drop item issue
« on: May 22, 2014, 02:08:18 AM »
Is it possible to restrict the user to drag some items on certain surface only?

For example, if I put one dragdrop surface on the ground and another one on the ceiling , I want to let the user only can put some chairs on the ground surface but only can put some lights on the ceiling surface. Is it possible? If possible, how to implement it?

Thx.

20
NGUI 3 Support / Tweening problems
« on: May 18, 2014, 02:47:25 AM »
I have a situation here:

I have a gameobject that has two tween alpha scripts attached. One will start automatically at start and the another will run after finishing the first tween alpha script. In order to do this, I want to set when the first tween alpha script finished and the another tween alpha script runs and so I do it at OnFinished. However, when I want to select the method, I just can find one tween alpha script and select the relative actions. So it won't works. It seems that it can not identify multiple but same tween script all attached in one gameobject. How can I do?

21
NGUI 3 Support / Re: Question on PopUp List
« on: May 11, 2014, 05:25:17 AM »
I still do not understand how to listen the events of selecting one option.

How the OnValueChange can help me to do something that if I select different selection?

For example, if I simply want to Debug.Log("1") when selecting "First", and Debug.Log("2") when selecting "Second"......

How the OnValueChange can help me on this case?

Moreover, the default selection on start seems to follow by the setting on the inspector and so I can not take the default selection be null even if I use scripting that UIPopupList.value = null. I can not set it in the inspector too.

22
NGUI 3 Support / Question on PopUp List
« on: May 10, 2014, 08:46:04 AM »
Nearly I need to use popup list but I encounter some problems on using it.

1. How to listen the events of selecting one of the option in popup list? If I select one of them, then do something?

2. How to add and delete one option in runtime?

3. Can the default selection be null ?

Thanks for any kind of helps.

23
NGUI 3 Support / Will NGUI support Save & Load in GUI area?
« on: April 30, 2014, 08:50:44 AM »
Nearly I found a useful things for me to Save & Load is UnitySerializer. It provides some GUI for me to help me Save & Load the game.

However, I want to combine this function in my project that using NGUI because it looks really better than unity GUI.

Will it be supported?

Or creating a new system on NGUI for user to do the save & load function?

You could find this UnitySerializer in asset store and it is free of charge. Please take a look at it and thank you.

24
NGUI 3 Support / Re: Dimension with UI and Icon blocked by finger
« on: April 13, 2014, 11:47:58 AM »
Place this on your dragged object:
  1. void OnDrag (Vector2 delta)
  2. {
  3.     Debug.Log("Currently over " + UICamera.currentTouch.current.name);
  4. }
Replace the Debug.Log with something else, like GetComponent<UIWidget>().color = valid? Color.green : Color.red;

UICamera.currentTouch.current.name is only return the objects on UI layer but not the gameobjects in the scene.
I need to check the location is valid or not for me to drop the item on. If valid, return true, else return false. And this checking start on dragging and end on release.

25
NGUI 3 Support / Re: Dimension with UI and Icon blocked by finger
« on: April 11, 2014, 09:31:13 AM »
Why are you assigning the script's game object to be the generic event handler? You have it backwards. It should be:
  1. UICamera.genericEventHandler = targetGameObject;
...where 'targetGameObject' is the game object that has your custom script attached. So if you're doing it from your custom script, then it would be:
  1. UICamera.genericEventhandler = gameObject;
Inside this script have your OnDragOver function:
  1. void OnDragOver (GameObject dragged)
  2. {
  3.     Debug.Log("Dragged " + dragged.name + " over " + name);
  4. }
Foreword
As you said and so, I simply write a script and put it on the surface(cube) inside "Example dragdropitem" scene that you gave in the package.
And here is my script below I want to try
  1. void Start()
  2.         {
  3.                 UICamera.genericEventHandler = gameObject;
  4.         }
  5.  
  6.         void OnDragOver (GameObject dragged)
  7.         {
  8.                 Debug.Log("Dragged " + dragged.name + " over " + name);
  9.         }
  10.  
However, it has no any "Debug.Log" messages appear when I drag an item on the cube...
Main
Actually the main problem is not the above things. I believe that you know what I want to do on GUI. When I drag an item, some function would automatically run to detect the location is valid or not for me to drop the item on.

Simply I want to ask is if I want to return false when I drag an item on invalid surface and return true when I drag an item on valid surface in one boolean. What should I do? In my custom script?

Sorry because I still have a lot of questions on using this dragdrop system and cobining my custom script. I always ask me why I can't do this with one simple way. I hope you can help me with details. Thanks.

26
NGUI 3 Support / Re: Dimension with UI and Icon blocked by finger
« on: April 07, 2014, 09:37:02 AM »
Right and my previous reply stands. Use a script on the generic event handler.

I repeatly try to understand how UICamera.genericEventHandler work in this specific case but eventually unsuccessful.
I even do not know what the steps should I follow to fullfill this purpose.

Even if I get a gamebobject and set(this.gameobject = UICamera.genericEventHandler) this object be UICamera.genericEventHandler, what is the following? Do something in Ondragover() ? I can change icon inside this function?

Also, UICamera.genericEventHandler can be set on any object? Because I have a lot confusing on how to use these specific coding to get my job done. I really hope that you can explain to me in detail.

Maybe one of example appear to tell me when I drag one icon and this icon would change something continously and accordingly base on the different surface on screen, so I can take out my confusing.

Please! This is not because my scripting is not good. It is because I don't know how to use your script to mix on my other scripts.
I know how to change icon. I know how to use raycast to check what I touch. But I don't know how to do on dragging with certain situation.
Sorry, I hope this probelm would not disturb you a lot too. Thanks and hopefully you would use some time to help me solve this probelm.


27
NGUI 3 Support / Re: Dimension with UI and Icon blocked by finger
« on: April 06, 2014, 09:02:06 AM »
What's an "invalid surface"? If it's still an object of any kind, you will still get the same OnDragOver. But if you don't want to attach scripts to surfaces, then you can always just set up a UICamera.genericEventHandler to some object, and add a script to this object with OnDragOver on it. Generic event handler will receive a copy of all the NGUI events, whether they were handled or not. So if you wanted a single place to set your on drag over logic, this would be the way to do it.

In order to make you understand my situation and my question, here is my objective:

Soucre: http://imgbox.com/D4l9Qmvs

I hope that you can understand my work above and I believe that it may possible to do something on GUI.
Thanks for your help!

28
NGUI 3 Support / Re: Dimension with UI and Icon blocked by finger
« on: April 06, 2014, 12:24:08 AM »
OnDragOver is going to be triggered on your surface object.

The problem is that now I want when dragging the icon, if there are some invalid dragdrop surface and then change icon to remind user : you cannot drop the item on that surface. If valid, the icon would keep original and remind user : you can drop the item on that surface.

OnDragOver() is although telling me something when dragging item on valid surface, how about when dragging item on invalid surface then do something? I may think that it should be possible to do something on GUI to do this.

Thanks.

29
NGUI 3 Support / Re: Dimension with UI and Icon blocked by finger
« on: April 05, 2014, 06:24:27 AM »
UICamera.currentTouch.dragged tells you what's being dragged. So to check what's being dragged you can use this example:
  1. void OnDragOver ()
  2. {
  3.     Debug.Log("Dragged " + UICamera.currentTouch.dragged.name + " over " + name);
  4. }
http://www.tasharen.com/forum/index.php?topic=8828.0

Thank you. Now I can catch the item dragged variable.
But I still could not check if the dragdrop surface is vaild or not then change the icon.
Such as UIcamera.hoveredObject or UIdragdropsurface still could not help me to do it.
I hope that there is a simple and direct way to do this. Thanks.

30
NGUI 3 Support / Re: Dimension with UI and Icon blocked by finger
« on: April 01, 2014, 10:25:05 AM »

I try to explain clearly. Sorry for my poor English.

UncleAcid said "Use UICamera.hoveredObject in OnDrag(Vector2 delta)/OnDragEnd() to see if it intersects with a valid container and change the icon accordingly." So I try to know more about how UICamera.hoveredObject would really do in this case.

In my coding, I may try to use UICamera.hoveredObject to check the container are invalid or not. If valid, the icon certainly keep  unchanged.
If invalid, I should use mTrans(?) , which is the variable of the item dragged in runtime, to change the sprite in UIsprite script?

Above scripts would be added in OnDrag(Vector2 delta) inside UIDragDropitem.

Are these on the correct way? Or any more simple way to do?

Any advice would be greatly appreciated.
Thanks.


Pages: 1 [2] 3 4