Unity 添加加密功能

这篇博客介绍了如何在Unity场景中实现简单的加密功能,通过Jiami脚本监控日期,当达到特定条件(2019年11月13日后)会自动退出程序。脚本展示了如何使用 PlayerPrefs进行状态跟踪和日期检查。
摘要由CSDN通过智能技术生成

Unity 项目程序需要加密功能

在unity 场景中有点时候项目程序需要加密功能

新建 Jiami.cs 脚本,挂载在场景中。

脚本内容:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Jiami : MonoBehaviour
{
int i = 0;

// Use this for initialization
void Awake()
{
    Debug.Log("加密");
    i = PlayerPrefs.GetInt("miwen");
    if (i > 20)
    {
     //   Application.Quit();
    }
   
    i++;
    PlayerPrefs.SetInt("miwen", i);
}
// Update is called once per frame
void Update()
{
   
    Debug.Log("加密");
    if (System.DateTime.Today.Year>=2019)
    {
      
        if (System.DateTime.Today.Month>=11)
        {
          
            if (System.DateTime.Today.Day>=13)
            {
                                 
                    Application.Quit();
               
            }
        }
    }
    //if (System.DateTime.Today.Year > 2019 && System.DateTime.Today.Month > 11 && System.DateTime.Today.Day > 10)//限制使用日期2018.09.10日
    //{
     
    //   // Application.Quit();
    //}
}

}

点咱关注加收藏哦 博主有实时的更新

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值