最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Unity實(shí)現(xiàn)鼠標(biāo)或者手指點(diǎn)擊模型播放動(dòng)畫

 更新時(shí)間:2020年01月20日 15:30:48   作者:liang_704959721  
這篇文章主要為大家詳細(xì)介紹了Unity實(shí)現(xiàn)鼠標(biāo)或者手指點(diǎn)擊模型播放動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了unity鼠標(biāo)或者手指點(diǎn)擊模型播放動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下

using UnityEngine;
using System.Collections;
 
public class ClickPlayAnimation : MonoBehaviour {
  /// <summary>
  /// 實(shí)現(xiàn)功能為點(diǎn)擊模型播放動(dòng)畫
  /// 使用方法,給模型添加碰撞,添加腳本
  /// </summary>
  
  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.ScreenPointToRay(new Vector3(touch.position.x, touch.position.y, 0));
          RaycastHit hit;
 
          if (Physics.Raycast(ray, out hit))
          {
            // Debug.DrawLine(ray.origin, hit.point);
            if (hit.collider.gameObject.name == gameObject.name)
            {
              isPlayAnim = true;
              print("123");
            }
          }
        }
      }
    }
    else 
    {
      if (Input.GetMouseButtonDown(0))
      {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
 
        if (Physics.Raycast(ray, out hit))
        {
          Debug.DrawLine(ray.origin, hit.point);
          //print(hit.collider.gameObject.name);
 
          //curObject = hit.collider.gameObject;
          if (hit.collider.gameObject.name == gameObject.name)
          {
            isPlayAnim = true;
            print("123");
          }
          // 顯示當(dāng)前選中對(duì)象的名稱
         // print(hit.collider.gameObject);
        }
 
      }
    }
    
    if(isPlayAnim)
    {
      animation.Play();
      isPlayAnim = false;
    }
 
 }
  
}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

贵定县| 临漳县| 霸州市| 师宗县| 萍乡市| 桦甸市| 印江| 焦作市| 错那县| 成安县| 饶阳县| 望江县| 青阳县| 永安市| 富锦市| 五莲县| 平顺县| 土默特右旗| 临沭县| 衡阳县| 保靖县| 清涧县| 甘谷县| 玉溪市| 穆棱市| 天水市| 鄂托克前旗| 叙永县| 清水河县| 即墨市| 湾仔区| 班玛县| 息烽县| 阿图什市| 林口县| 芦溪县| 寿宁县| 长子县| 兴义市| 嘉定区| 宁城县|