2016-02-05 5 views
0

Я хочу играть в свою игру Unity в режиме ввода Mouse (мой скрипт теперь является сенсорным вводом), могут ли все помочь мне конвертировать мой скрипт в Mouse input? использованием если unity_editor, ENDIF:КАК ПЕРЕЗАГРУЗИТЬ Touch Input To Mouse Input C# unity?

#if UNITY_EDITOR 

//some code for mouse input 

#endif 

мой сценарий здесь: http://pastebin.com/HJwbEzy4

благодарит вас так много, кто помогает мне !! :)

или здесь:

using UnityEngine; 
using System.Collections; 

public class Main_Menu_02 : MonoBehaviour 
{ 
    public GameObject InstructionContainer; 
    public GameObject Buttons; 
    public GameObject AW; 
    public GameObject Instruction; 
    public GameObject Exit; 
    public Texture Active; 
    public Texture nonActive; 



    public AudioClip SFX_select; 

    // Update is called once per frame 
    void Update() 
    { 
     if (Input.touches.Length <=0) 
     { 
      this.guiTexture.texture = nonActive; 
     } 
     else 
     { 
      if(Input.touches.Length == 1) 
      { 
       if(this.guiTexture.HitTest(Input.GetTouch(0).position)) 
       { 
        if(Input.GetTouch(0).phase == TouchPhase.Began) 
        { 
         audio.PlayOneShot(SFX_select); 
         this.guiTexture.texture = Active; 
        } 
        if(Input.GetTouch(0).phase == TouchPhase.Ended) 
        { 
         if(this.gameObject == AW) 
          Application.LoadLevel("LoadingAW"); 
         else if(this.gameObject == Instruction) 
         { 
          InstructionContainer.SetActive(true); 
          Buttons.SetActive(false); 
         } 
         else if (this.gameObject == Exit) 
         { 
          Application.Quit(); 
         } 
        } 
       } 
      } 
     } 
    } 
} 

ответ

3

Нет необходимости прикосновений. Вы можете использовать Input.GetMouseButton, будет работать на обоих.

Input.GetMouseButtonDown(0) для касания начало.

Input.GetMouseButtonUp(0) для контакта завершено.

Input.GetMouseButton(0) для прикосновения начать и двигаться.

void Update(){ 
    if (Input.GetMouseButtonDown(0)) 
     print("Touch begin"); 
    // So on.... 

}

+0

спасибо братан, я попробую :) – Blazingr