Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by nurul-shuhadah · Oct 26, 2016 at 02:26 PM · inputfieldpasswordfield

Unlock game with provided password / serial key

Hi. I want to unlock a mobile game with provided password / serial key. Below is the script that i used. I want to make the game unlocked using one password for one device. But i do not know how..

     public void GetInput (string guess) {
     if ((guess == "pass122") ||(guess == "pass133"))
     {
         Application.LoadLevel("Eat");
     } 

     else if (guess == "") 
     {
         OutputText.text = "Please enter your key";
     } 
     
     else 
     {
         OutputText.text = "Wrong key";
     }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by akisrn · Oct 27, 2016 at 01:50 AM

You're not calling your function anywhere so you it wouldn't really work. Also, all GUIs should be called inside the OnGUI function. I modified your code a little. I've tested this one and it works fine with me. Let me know how it will go. xx

 using UnityEngine;
 using System.Collections;
 
 public class Test : MonoBehaviour {
 
     public string levelCode;
     public bool isBlank;
     public bool isWrongKey;
 
     void OnGUI()
     {
 
         levelCode = GUI.TextField(new Rect(100, 100, 250, 30), levelCode);
 
         GUI.Label(new Rect(200, 60, 300, 40), "Enter Level");
 
         if (GUI.Button(new Rect(100,  140, 250, 30), "OK!"))
          {
             GetInput(levelCode);
          }
 
         if(isBlank)
         {
             GUI.Label(new Rect(200, 200, 300, 40), "Invalid Key!");
         }
 
         if(isWrongKey)
         {
             GUI.Label(new Rect(200, 200, 300, 40), "Wrong Key!");
         }
     }
 
     public void GetInput (string guess)
      {
      if ((guess == "pass122") ||(guess == "pass133"))
      {
          Application.LoadLevel("Eat");
           isBlank = false;
          isWrongKey = false;
         //Debug.Log("Load level Eat");
      } 
      else if (guess == "") 
      {
         isBlank = true;
         isWrongKey = false;
         Debug.Log("Invalid Key!");
      } 
      
      else 
      {
         isWrongKey = true;
         isBlank = false;
         Debug.Log("Wrong Key!");
      }
 }
 
 }
 
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 nurul-shuhadah · Oct 27, 2016 at 03:56 AM 0
Share

Thanks @akisrn. It works fine. But as i mentioned earlier, i want to make the game unlocked using one time password for one device. Similar concept as activation code for an application.

avatar image akisrn · Oct 27, 2016 at 09:27 AM 0
Share

@nurul-shuhadah maybe you can store the password in PlayerPrefs. Something like PlayerPrefs.SetString("myPassword", myPassword); where myPassword is where your password is stored. Then, at the start function, you can use something like if (PlayerPrefs.Has$$anonymous$$ey("myPassword") { //load level } else { // do what needs to be done if user hasnt saved the password }

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

77 People are following this question.

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

Related Questions

How to set up a password to be used in the password input field? 1 Answer

Input Field Problem 0 Answers

Unity UI InputField can't type Chinese in iOS by speed dial type keyboard 1 Answer

how to make inputfield "*" asterisk without drawing GUI? 0 Answers

How to have rich text in an input field? 0 Answers


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