纳金网

标题: 模仿狙击枪开镜的代码 [打印本页]

作者: may    时间: 2015-8-31 07:07
标题: 模仿狙击枪开镜的代码

模仿狙击枪开镜的代码
  1. using UnityEngine;
  2. using System.Collections;

  3. public class Scope : MonoBehaviour {
  4.      public bool click = false;
  5.          // Use this for initialization
  6.          void Start () {
  7.          GetComponent<Camera>();
  8.          }

  9.      void OnClicks() {
  10.          if (Input.GetMouseButtonDown(1))
  11.          {
  12.              click = !click;
  13.          }
  14.          if (click)
  15.          {
  16.             camera.depth = -1;
  17.          }
  18.          else
  19.          {
  20.             camera.depth = 1;
  21.          }
  22.      }

  23.          // Update is called once per frame
  24.          void Update () {
  25.          OnClicks();
  26.          
  27.          }
  28. }
复制代码





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