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
0
Question by Xhanos · May 06, 2014 at 08:56 AM · textfield

Need Help regarding Barcodescanning

Hello,

I'm using a barcodescanner via USB to insert the numbers into a textfield in Unity

When Enter(Return) is pressed. I want to use Unity to acces data from a textfield on the GUI and check if it's above or below 900.000 . And then add 1 to either Can or Flask depending on the number.

When pressing "new scan" i want it to delete the data inside of the textfield without deleting the counted number of cans and flasks.

I've been using these links to make the code. Link Link 2

My Question is as follows: Am i doing it correctly? Am i even on the right track? how can i improve/make it work ? I only have to the 11th of May to get it done and working.

I'm fairly new to unity, so please try to explain what you are doing with the script the simplest way possible.

Thanks for reading!

The Code so far: using System; using UnityEngine; using System.Collections;

 public class ThisismyGUI : MonoBehaviour
 {
 
     private string BarcodeValue = "";
 
     bool UserHitReturn = false;
 
     public int Value;
     public int Can;
     public int Flask;
 
     void Start()
     {
         Can = 0;
         Flask = 0;
     }
 
     void Update ()
     {
         if (Input.GetButtonDown("Enter"))
         {
             try
             {
                 Value = int.Parse(BarcodeValue.text);
             }
             catch (Exception e)
             {
                 BarcodeValue.text = "0";
             }
         }
         if (Value > 900000)
         {
             Flask++;
         }
         else if (Value < 900000 && Value > 1)
         {
             Can++;
         }
     }
 
     void OnGUI()
     {
         Menu();
         Buttons();
         Barcode_Input();
     }
 
     private void Menu()
     {
         GUI.Box(new Rect(10, 10, 100, 200), "Menu");
     }
 
     private void Buttons()
     {
         if (GUI.Button(new Rect(20, 40, 80, 20), "New Scan"))
         {
             UserHitReturn = false;
             BarcodeValue = GUI.TextField(new Rect(200, 50, 100, 20), BarcodeValue);
         }
 
         if (GUI.Button(new Rect(20, 70, 80, 20), "Reset"))
         {
             Application.LoadLevel(0);
         }
     }
 
     private void Barcode_Input()
     {
         Event e = Event.current;
         if (e.keyCode == KeyCode.Return) UserHitReturn = true;
         else if (false == UserHitReturn) BarcodeValue = GUI.TextField(new Rect(200, 50, 100, 20), BarcodeValue);
     }
 }


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 fenden · Apr 13, 2015 at 01:13 PM

Difficult issue for me, did you try to add the bar code scanner library to Unity? I don't know how did you solve it ultimately, if you have better resolution, hope you can share it.

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

21 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

Related Questions

Multiple Cars not working 1 Answer

I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer

Capitalize first letter in Textfield Only? 5 Answers

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

Accessing Local Computer Files 2 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