unity在android中点击模型,Unity实现鼠标或者手指点击模型播放动画

本文实例为大家分享了unity鼠标或者手指点击模型播放动的具体代码,供大家参考,具体内容如下 using UnityEngine; using System.

本文实例为大家分享了unity鼠标或者手指点击模型播放动的具体代码,供大家参考,具体内容如下

using UnityEngine;

using System.Collections;

public class ClickPlayAnimation : MonoBehaviour {

///

/// 实现功能为点击模型播放动画

/// 使用方法,给模型添加碰撞,添加脚本

///

bool isPlayAnim = false;

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

//animation.Play();

if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android)

{

foreach (Touch touch in Input.touches)

{

if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began || Input.GetTouch(0).phase == TouchPhase.Moved)

{

Ray ray = Camera.main.ScreenPointToRa