Easy Touch Drag Ngui object with playmaker

Source: Internet
Author: User

Recently in learning Unity3d several plugins. Easy Touch,playmaker,ngui. In order to make several can use together, also got playmaker Ngui scripts and easy touch addon 4 playmaker plugin.

A recent one requires touch to drag a Ngui 2d object and want to use playmaker to control it. How do you say this? Anyway, there is the felling of killing the chicken with slaughter sledgehammer.

In the easy touch Addon 4 playmaker example, there is an example of how to drag a GUI object, but when I drag the Ngui, I find it is always wrong and finally I find the problem.

You cannot use the set position action of playmaker to set the position of the push object, you must use the transform.postion= in the script ... The way to set the position of the dragged object.


Here's a demonstration of the whole process.

First create an empty scene, add a Ngui 2dUI



Depending on the background size, set the UI root, this setting is required for work and does not affect drag.



The camera must pay attention to the layer settings, because to be able to be dragged, to be associated with Easytouch, because I deleted the unity default camera, so, also to the Ngui camera's tag set to Maincamera



Add a background, (nothing to drag)



This is the 2d Ngui object to drag, note the layer, add a script of your own, and note that you want to add collider to be dragged



Setting the Easytouch, I use the example to drag into the precast parts directly. Be sure to add the Ngui camera here. Check Enable 2d Coliider



Start setting playmaker, Basic is copy example, Long Live cottage.



Add variable



Set action



Continue to set the action, as in the case of the two states.



This is the original action in the example, set the position via set position



Here, to use a script, the script content is simple

Using unityengine;using System.collections;public class Mytest:monobehaviour {public void World (Vector3 position) { Transform.position = position;}}


Then use the Send Message method to invoke the script.


OK, all right, the man can be dragged and dragged.



State machine that strange state is a complete set of events, add the following method. Easytouch must be added to the scene to have these events.



Add a later state.



In addition, say the next run, several states.

After running, the object stops at the wait for drag state,

When the touch starts, go to the get current state and return to the wait for drag state.

Occurs when dragging, go to the on drag state.


Easy Touch Drag Ngui object with playmaker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.