unity
unity 本地设置软件使用天数
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class TimeControl : MonoBehaviour { // 原有时间 private string originalDateStr = "3/19/2018"; // 设置软件初始使用时间 // 时间差 private int number = 0; private void Awake() { number = DateDiff(originalDateStr, DateTime.Now); Debug.Log(number); } private static int DateDiff(string dateStart, DateTime dateEnd) { DateTime start = Convert.ToDateTime(dateStart); DateTime end = Convert.ToDateTime(dateEnd.ToShortDateString()); TimeSpan sp = end.Subtract(start); return sp.Days; } private void Update() { if(number>=280) // 可以使用天数为280天 { Application.Quit(); } } } 理论上还是服务器的方法好些,不用到期再发布。