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 /
avatar image
0
Question by oblowery · Nov 26, 2017 at 12:04 AM · scripting problemlistspassword

trouble scripting a password list to access scene,Script to check UI Input Field against a list of passwords

I'm trying to create a script that compares a public list of passwords with the inputField text to see if the text matches one of 100 possible pre-defined passwords.

I'm really new to scripting. I've come a long way though.

I've created a working public list with a script public List passwords = new List();

I'm able to create a button action that gets me to the next scene SceneManager.LoadScene("Scene2_Hearts", LoadSceneMode.Single);

But for the life of me i can't figure out the IF statement that looks into my List of passwords and decides if the input field text matches one of the options in order to allow the button to trigger.

Anyone out there able to help? Thanks y'all. ,I'm trying to create a c# script where I have a public list of 100 predefined passwords. I'd like it so a person has to type a password into an input field, then click the "submit" button, and have that password match one of the ones in my list in order to access the next scene.

I've got down the public list: public List passwords = new List();

I've figured out the button calling up a scripted function to get to the next scene SceneManager.LoadScene("scene2", LoadSceneMode.Single);

but for the life of me i can't figure out an IF statement that sees if the GUI text field for inputfield matches one of the list items in my passwords script. It's driving me bonkers.

Anyone know a solve?

Thanks y'all.

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

Answer by smkmth · Nov 26, 2017 at 12:21 AM

the way i would do it is a public reference to the InputField, and then make a public method called somthing like GetPassword() which takes a string value taken from InputField.text - and then checks if that value is in the password list with .Contains(), then set the method to go when you click the submit button, by dragging the obejct which has the script to the OnClick() section in the passwords inspector so like public InputField passwordField;

public void GetPassword(){ string input = passwordField.text; if(passwords.Contains(input )){ SceneManager.LoadScene("scene2", LoadSceneMode.Single) } }

from there you can either have a lot of if statments - which say like - if (input == "specficpasswordA"){ SceneManager.LoadScene("SpecificLevelA", LoadSceneMode.Single);} if (input == "specificpasswordB"){ scneMananger.LoadScene("specficLevelB", LoadSceneMode.Single); } or just pass the input to the scenemanager directly, and name the scene the password you want to associtae with it. lets say you want the password for scene2 to be "Scene2Password". Change the name of scene 2, then in the method write SceneManager.LoadScene(input, LoadSceneMode.Single); - and it will try to load whatver scene you pass in to input. obviously you might need a check to see if that scene exists - it might just be easier to do it with the if statements, but whatever works man.

i am also new , but i feel this will work.

Comment
Add comment · Show 1 · 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

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

128 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 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

Public list are not reflecting in inspector. 1 Answer

My list is overwriting the data it was holding with the newest element added to the list. 2 Answers

Why is my list not filling 1 Answer

Access list storing custom class variables from another script 1 Answer

Temporary GameObject Movement 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