码迷,mamicode.com
首页 > 其他好文 > 详细

EasyTouch 3.1中文翻译

时间:2014-05-24 08:00:45      阅读:564      评论:0      收藏:0      [点我收藏+]

标签:des   style   class   blog   c   code   

  Unity3D的Easy Touch 的手册最近寻找中文版本,google无果,自己动手。目前暂时只有c# ,javascript原理是一样的。

  

一、Quick Start

  1-Import EasyTouch Package.
    

     2-Create an empty gameObject, and name it EasyTouch.(You can choose another name)
  Step 1 & 2 can be replace by the option menu

  
  3-Add the EasyTouch.cs script on the EasyTouch gameObject that you just created.

  添加一个EasyTouch.cs 到你创建的这个物体
  4-Select the EasyTouch gameobject, and verifies that Broadcast messages is set to FALSE in the inspector.

  在检视面板中如下设置:

  bubuko.com,布布扣

  5-Create a new C# script MyFirstTouch

  
  6-Add these methods

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Subscribe to events
void OnEnable(){
EasyTouch.On_TouchStart += On_TouchStart;
}
// Unsubscribe
void OnDisable(){
EasyTouch.On_TouchStart -= On_TouchStart;
}
// Unsubscribe
void OnDestroy(){
EasyTouch.On_TouchStart -= On_TouchStart;
}
// Touch start event
public void On_TouchStart(Gesture gesture){
Debug.Log( "Touch in " + gesture.position);
}

   7-Create an empty gameObject, and name it Receiver.

  
  8- Add MyFirstTouch script to the gameObject Receiver.

  
  9- Run it in editor, and click on the screen

  This example will do nothing if you run it on your mobile devise, it‘s just to show you how use EasyTouch events with C#
  

     With C# events all script that are subscribed to an event will receive the event

  所有的订阅了这个事件的脚本都会接受到这个事件。

二、Quick Start with auto-select (C#)

  1-Do steps 1 to 4 of the Quick Start (C#)


   2-Select the EasyTouch gameobject , and add a pickable layers in the Auto-select properties in the inspector

  选择一个层,后面有用

  bubuko.com,布布扣

  3-Create a sphere and assign it a simple diffuse material

     4- Setting the auto-select on the sphere : Assign the same layer that you assign as parameter to the sphere. 

     给Sphere物体的分配你刚才选择的层(一定要分配同样的,如果不指定,则无效)

   5- Create a new C#

     6-Add these methods :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Subscribe to events
void OnEnable(){
EasyTouch.On_TouchStart += On_TouchStart;
}
// Unsubscribe
void OnDisable(){
EasyTouch.On_TouchStart -= On_TouchStart;
}
// Unsubscribe
void OnDestroy(){
EasyTouch.On_TouchStart -= On_TouchStart;
}
// At the touch beginning
public void On_TouchStart(Gesture gesture){
// Verification that the action on the object
if (gesture.pickObject == gameObject)
gameObject.renderer.material.color = new Color( Random.Range(0.0f,1.0f),
Random.Range(0.0f,1.0f), Random.Range(0.0f,1.0f));
}

   7-Add this script to the sphere

 8-Run it in editor mode or in your device. If you touch the sphere or click on it, it will change color.

 bubuko.com,布布扣

三、Concepts

  Event system
    When you make an action with the touch screen or mouse, EasyTouch raise an event corresponding to the current action. Each event will have a parameter of type Gesture.

    当你在接触屏幕或者使用鼠标的时候,EasyTouch会根据你的当前的行为发出一个时间。每一个Each event都有一个Gesture类型的参数。
    You only have to write the code according to the gesture, as in a motor GUI events.

    你只需要在事件中根据传过来的gesture写你的代码即可。

    Events can be raised in two different ways (look atgeneral properties inspector)

    事件的发出可以通过以下两种方法,我建议第一种。
- Event / Delegate system.
- Unity built-in Sending message system (SendMessage)

    

  Auto-Select

    When you perform an action on the touch screen or mouse, EasyTouch can detect if the action is performed on a gameobject.

    当你接触吗屏幕或者点击鼠标的时候,Easy Touch会检测这个行为是否会作用到某个物体。

    If gameobject is detected, it will be assign to the class memberpickedObject of the Gesture classwhich will be sent with the event.

     With the broadcast message mode(built in unity), the event itself will be sent to this object.
    This setting is enabled by default (Inpsector properties), you just indicate the layers that can be selected.

     这种设置默认是enable的,你只需要制定你选择的层即可。

    

  Warning:
    
With Event-Delegate mode, events are sent to all objects that have subscribed to the event, unlike the broadcast mode which sends the object itself.

    由于c#中的事件是群发的,所以你需要检测下自己。
  

    Even if the script that processes an event is attached to a selectable object, you need to test the pickedObject member.

1
2
3
4
5
public void On_TouchStart(Gesture gesture){
// Verification
if (gesture.pickObject == gameObject)
gameObject.renderer.material.color = Color.red;
}

 

 

三、 Inspector properties

  EasyTouch has different parameters that you can customize with the inspec
all mobile platforms.
  All these properties can be setting with script, look at :EasyTouch Class

  

  General properties

  bubuko.com,布布扣

  Enable EasyTouch:Enables ou disables EasyTouch
  Enable unity remote: Enables ou disables the support of Unity Remote

  Enable hover extention: To test if a touch is hover a virtual controller (joystick or
member isHoverController of Gesture class passed as parameter is egual to TRUE

  Broadcast messages :
? True = The events will be sent with then internal messaging function of Unity (Sen
Use this if you develop in Javascript (you can use in C# too, if you want)
? False =The events will be sent with events/Delegate C# system, never use this mod
Javascript
? Other receiver : Allows you to direct all messages to a gameobject
? Joysticks & buttons :  Enable this if you have joystick or button in your scene

  Enable NGUI compatibility:
  If a touch is hover a NGUI panel , Easytouch doesn‘t raise any event
? NGUICamera: All camera used by NGUI
? NGUILayers: all layer used by NGUI

 

  bubuko.com,布布扣

  Enable auto-select:Enables or disables the auto-select of game
  

  Add Camera: Bby default EasyTouch will take the camera with the main flag to raycast, but you can add other camera on set GUI to true, it‘s a camera for your GUI

  Pickable Layers: To set up all layer that EasyTouch must test

 

  bubuko.com,布布扣

  
   Stationnary tolerance: Distance below which a finger mouvemenst generate static touch, Act on this value if the tap are not detected correctly. The default value works well on a IPAD2
   Long tap time:Represents the maximum time to generate an event tap, or the minimum time to generate a long tap event

  Swipe tolerance : This value is used to detect the orientation of a gesture swipe or drag. It must be between 0 and 1

0 => Gesture imprecise 不精确
1 => Gesture very precise 精确

  

四、Classes

  Events

  Below is a list of all the events raised by EasyTouch. Look at_C#-Event-Template or _Jave—Event-Template folder on Plugins folder

    下面列出一些常用的事件,具体的可以参考官网http://www.blitz3dfr.com/Doc/ET3/annotated.html

 

  bubuko.com,布布扣

    bubuko.com,布布扣

    bubuko.com,布布扣

           bubuko.com,布布扣

    

  

EasyTouch 3.1中文翻译,布布扣,bubuko.com

EasyTouch 3.1中文翻译

标签:des   style   class   blog   c   code   

原文地址:http://www.cnblogs.com/chongxin/p/3746370.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!