• QQ
  • nahooten@sina.com
  • 常州市九洲新世界花苑15-2

游戏开发

u33d给程序添加运用日期

原创内容,转载请注明原文网址:http://homeqin.cn/a/wenzhangboke/jishutiandi/youxikaifa/2019/1027/689.html

 
之前公司的常州微信公众平台项目要拿给他人演示,所以要加一个月的运用时间。意义就是,一个月后程序的某些功用就不能用了。
 
说下大致思绪:就是获取本地如今的时间比方2016年8月8日8点8分,然后设定一个月后的时间也就是2016年9月8日8点8分。
 
然后做一个判别,判别俩时间是不是一样,一样就是到期了。然后执行你的某些避免程序运转的代码就行。
 
我加的是到期后到重要功用页面就是不跳转,怎样都不会进入下一页面,就在这个页面卡着,只能退出程序。
 
using UnityEngine;
using System.Collections;
//using System.d
public class ToSecondScene : MonoBehaviour {
    private bool m_bpress; //能否点击
    public UILabel main_label;//label
    public GameObject mianban;//正告框面板
    public GameObject StandByScene;
   // public GameObject StartScene;
    public GameObject ThirdScene;
    public play myplay;
    //获得如今的时间
    System.DateTime now = System.DateTime.Now;
    //得到恣意时间的DateTime(年月日时分秒)
    System.DateTime date = new System.DateTime(2016, 9, 8, 12, 0, 0, System.DateTimeKind.Local);
    //判别能否超时
    private bool overtime;
    void OnClick() {
        print("into second scene");
        if (overtime == true)
        {
            StandByScene.SetActive(true);
            ThirdScene.SetActive(false);
            main_label.text = "程序已超时,无法运用!";
            mianban.SetActive(true);
        }
        else
        {
            StandByScene.SetActive(false);
            ThirdScene.SetActive(true);
            myplay.m_bpress = false;
        }
    }
// Use this for initialization
void Start () {
        overtime = false;
        print("Time:  " + now);
        print("date:  " + date);
}
// Update is called once per frame
void Update () {
        if (now > date)
        {
            overtime = true;
            print("超时了");
        }
}
}
 

上篇:上一篇:unity3d中上下左右键控制挪动
下篇:下一篇:Cocos2d-X之触摸事情