Easy touch uses playmaker to drag ngui objects

Source: Internet
Author: User

Easy touch uses playmaker to drag ngui objects

I recently learned several unity3d plug-ins. Easy touch, playmaker, ngui. The playmaker ngui scripts and easy touch addon 4 playmaker plug-ins were also created to enable several functions.

Recently, we made a 2d Object that requires touch to drag an ngui and wanted to use playmaker to control it. How can this be done. It seems like a cool-killing tool.

In the example of easy touch addon 4 playmaker, there is an example of how to drag a gui object. However, when I drag ngui, I find that it is always incorrect. Finally, I finally find the problem.

You cannot use the set position action of playmaker to set the position of the push object. You must use transform. postion =... in the script to set the position of the drag object.

 

The entire process is demonstrated below.

First, create an empty scenario and add an ngui 2dUI

 

Set the ui root according to the background size. This setting is required for work and does not affect drag.

 

The camera must pay attention to the Layer settings, because it must be associated with easytouch to be able to be dragged, because I have deleted the unity default camera, so we also need to set the ngui camera tag to MainCamera

 

Add a background (independent drag)

 

This is a 2d ngui object to be dragged. Pay attention to Layer and add a script written by yourself. Note that you must add Collider to be dragged.

 

Set easytouch. I will drag the parts in the example into a premade part and use it directly. The ngui camera must be added here. Select enable 2d coliider

 

Start to set up playmaker, which is basically a copy example.

 

Add variable

 

Set action

 

Continue to set the action. The actions in these two States are the same as those in the example.

 

This is the original action in the example. You can set the position through set position.

 

Here, you need to use a script instead. The script content is very 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 call the script.

 

OK, everything is fine. Now that person can be dragged.

 

The strange state in the state machine is a complete set event. The method to add it is as follows. You must add easytouch to the scenario to have these events.

 

Added status.

 

In addition, several statuses are running.

After running, the object stops in the wait for drag status,

When the touch starts, the system returns the wait for drag status after the get current status is changed.

When the drag occurs, it is switched to the on drag status.

Related Article

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.