Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by NIMBLE_JIM · Apr 27, 2015 at 10:24 PM · password

How do I implement an 'Expire after 30 days' system to a game developed in Unity?

Hi all,

I am making an educational game in Unity for a client, the client wishes the file to be password protected and then lock after 30 days, so anyone leaving the company cannot continue to use it if they have it on their machine (it is a training tool for internal use only).

Password protecting the file is not really a problem, I can use either a password protect on the file itself or implement one in-game (with the UI tools) when you start it.

The problem is getting it to 'expire' and then lock the user out.

So my question is, how do I get the game to know when 30 days have passed since the user first opened the file? I'm guessing it would need to read the system time to determine what the date was, or something similar? Or maybe have some kind of timer going, that will essentially count down to the expiry time.

Essentially I just need to be able to trigger a UI popup that tells the user they cannot use the application any more (and at the same time just deactivate the play button or something similar).

I am more of an artist than a programmer, so this sort of thing is a little above me, so I would really appreciate some pointers.

Is there a quick and easy way to do this or is it something that is going to be really complicated to set up?

If it is not possible, if anyone has any ideas of alternatives it would be much appreciated!

Thanks in advance

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by AlwaysSunny · Apr 27, 2015 at 10:23 PM

A rudimentary solution involves measuring changes in the System.DateTime.

Store the Date the application first ran, and check against this value each time it's run.

This may lead to issues with users who change time zones.

Also, this measure can be foiled by purging the registry values created by the program, or by manipulating the system's date and time settings.

The "right" way to overcome this is by linking access to a user account, and handling all login / access requests through your company server. The application waits for your web service to verify the login and passage of time, then allows or rejects the access attempt based on whatever criteria e.g. bad password or 30 days expired.

Assuming nobody hacks into your server and messes with these values, average users will have much greater difficulty circumventing the lockout.

As an additional protective measure, (to discourage desperate parties from using various "hacking" tools to "spoof" a login) your application and server might exchange some kind of key, on which mathematical operations are performed and verified, to allow or disallow access.

There's a whole industry built around creating these security measures. I expect you may get better, more cost-effective results by purchasing some kind of turnkey solution. In any case, UA is not the place to continue such a line of questioning.

Best,

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Apr 27, 2015 at 10:47 PM 0
Share

As i said in my answer, in Unity you can't really implement security due to .NET / mono. You would have to use native code dlls for the most important things and have the security inside that dll to make it half way safe. Server communication is often said to be the best solution, but if the client can that easily be cracked it's not worth the server development / hosting ^^.

avatar image NIMBLE_JIM · Apr 28, 2015 at 12:23 AM 0
Share

Hi AlwaysSunny,

Thank you very much for your detailed response. I only need something very basic, the client doesn't need anything too sophisticated, just a simple time check and popup when a specific time is reached.
Therefore I'm not worried about how easily it can be hacked or anything like that, the target audience is highly unlikely to be bothered doing that, nor would they be likely to know how to do it.

The first option you suggest sounds ideal, do you know of any example scripts I could look at for this action? I'm quite new to the program$$anonymous$$g side of things, so any pointers to write such a script would be much appreciated.

Thanks once again.

avatar image
2

Answer by Bunny83 · Apr 27, 2015 at 10:43 PM

You could also use a simple self-checked serial key which you hand out to a user. Something like this:
http://answers.unity3d.com/questions/813827/looking-for-a-way-to-limit-software-use-to-weeks-t.html

However you might want to additionally keep track of the time "already passed" or use a web-time source in case the user tries to spoof the system time.

Keep in mind that all those security things are pointless if your users are intermediate / professional programmers. Unity compiles the scripts to .NET / mono assemblies which can easily be decompiled / manipulated. It also doesn't matter which platform your tool runs on. Even a webbuild or android app can be cracked without much efford.

If your users are "just users" any kind of time check (that doesn't store the timestamp as plain text next to the application or in the registry) will do.

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NIMBLE_JIM · Apr 28, 2015 at 12:31 AM 0
Share

Hi Bunny83,

Thank you very much for your response. $$anonymous$$y users are very much "just users" and are unlikely to have the knowledge or the interest the try and hack it. As I mentioned to AlwaysSunny, if you know of any examples of a script to do a simple time check it would be much appreciated, or even just some pointers to write one. I have until Thursday to do it, so am running out of time a little!

Thanks again.

avatar image Bunny83 · Apr 28, 2015 at 01:24 AM 2
Share

Here I just setup a simple class with a "two time stamp" system. This script just has to be attached to a gameobject somewhere in your scene.

When you start the application the first time it will remember the current timestamp. Every 30 sec while the application is running it updates the "last" timestamp (which is used to detect if the system time got set back to a previous time) and checks if we are still within the set trial period (hardcoded to 30days (the value is given in seconds so it's 3600*24*30)).

If the trial period has expired it simply shows a GUI Label at the top of the screen and ter$$anonymous$$ates the application after 10 seconds. If it detects time spoofing it quits after 2 sec.

You might want to tweak the times or replace the OnGUI stuff with something made with the new UI, however that's up to you.

avatar image MirzaZee Bunny83 · Mar 12, 2019 at 08:00 AM 0
Share

Hi Bunny83! Your code is working perfectly, the only problem is when the trial period is over, and we copy the .exe file on another device you can say PC or laptop then it does not recognize the date. it starts counting time when the application copied in that PC. How we can do this. Like if Trail period is over on PC 1 then the same file must show the trial period is over on PC 2.
Waiting for your response Thanks in advance.

avatar image NIMBLE_JIM · Apr 28, 2015 at 10:45 PM 0
Share

Thank you very much, that script works perfectly and exactly what I needed! I really appreciate the help.

One quick question - in this line -

 long epochTicks = new System.DateTime(2015, 04, 23).Ticks;

Does it matter what date I put in the brackets? Does it have to be the date I make the build?

Thanks again :D

avatar image VRxMedical · Nov 13, 2018 at 09:29 AM 0
Share

@Bunny83 Can you please help me also. I am also trying to implement the same thing and i also got the idea how to do it but not able to compare date. Please help me. Thank you

avatar image Bunny83 VRxMedical · Nov 13, 2018 at 11:35 AM 1
Share

How am i supposed to help you? You posted a question as comment to somebody else's question that contains no information. If you have a question, ask a question and do not bump old questions like this one. I gave two code examples. Note that examples are not meant as "solutions" but as inspiration to create your own solution that fits your needs.


If you ask a question, be more specific. Show what you have done already and where you're stuck

avatar image Andergraw · Nov 27, 2018 at 12:42 PM 0
Share

Ey, @Bunny83 , thanks for your code. It was a perfect solution for me.

Cheers,

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can non-admin users change their own password using the Unity Asset server system? 0 Answers

Publishing Settings (keystore password) not saving 1 Answer

Is it feasible to hide the password and serial key when activating a license from the command line 1 Answer

error keeps looping (smartfox connection) even after I stop testing my game 1 Answer

Help connection to SQL via Json file 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges