纳金网

标题: 用圆柱模仿一个按钮效果 [打印本页]

作者: may    时间: 2015-8-31 06:49
标题: 用圆柱模仿一个按钮效果

用圆柱模仿一个按钮效果
  1. using UnityEngine;
  2. using System.Collections;

  3. public class vir_btn : MonoBehaviour {

  4.         // Use this for initialization
  5.         void Start () {
  6.        
  7.         }
  8.        
  9.         // Update is called once per frame
  10.         void Update () {
  11.         Vir();
  12.         }

  13.     void Vir()
  14.     {
  15.         if (Input.GetMouseButtonDown(0))
  16.         {
  17.             transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1f);
  18.         } if (Input.GetMouseButtonUp(0))
  19.         {
  20.             transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1f);
  21.         }
  22.     }
  23. }
复制代码





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5