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 Fbary · Mar 07, 2013 at 07:02 PM · gunlaser

Barcode reader using Laser Gun

Hi all, I've to interface my project with a laser gun hardware to read an existing barcode.

I've seen that it's very simple to create a barcode scanner using camera in mobile apps, but i need to use my program on PC, using this USB hardware.

Before I proceed on purchase that laser gun I'd like to ask if anyone tried to do this before, and can tell me how difficult can be. I looked in the asset store, but I didn't find anything I can use.

So, how can Unity3d interface with this kind of hardware?

Looking forward to answers, Thanks for attention!

Comment
Add comment · Show 1
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 Benoit Dufresne · Jan 14, 2014 at 08:21 PM 0
Share

Have you had any luck? I'm looking into this myself at the moment. Haven't bought the actual scanner yet tho.

$$anonymous$$y first guess is we'll have to open a serial port and poke into it.

6 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Benoit Dufresne · Jan 16, 2014 at 07:29 PM

If your gun is like mine, it is treated like a keyboard (e.g. writes decoded data in notepad). Then reading data is trivial using Input.inputString:

     public UILabel barCode;
     public float timeDelay = 0.1f;
     private string currentCode;
     private float lastReceivedInput = 0f;
     // Use this for initialization
     void Start () {
         currentCode = "";
     }
     
     // Update is called once per frame
     void Update () {
         if (Time.time > lastReceivedInput + timeDelay){
             currentCode = "";
         }
         if (Input.inputString != ""){
             currentCode += Input.inputString;
             lastReceivedInput = Time.time;
         }
         if (currentCode!="" && (currentCode[currentCode.Length-1] == '\n' || currentCode[currentCode.Length-1] == '\r')){
             barCode.text = currentCode;
         }
 
     }


Edit: some more in-depth wisdom after testing parameters...

  • Has to be in "Keyboard wedge" mode to be read from Input.inputString

  • Transmission speed is an issue. From my big booklet o' settings were 2 barcodes for transmission speed settings (under Interface - KBW). Options were 0 and 25 and 25 fixed the problem. I'm not 100% certain what caused it (I suspect dropped bytes [eg only half character getting there in time]) but characters would appear randomly capitalized or not, and numbers would either be numbers or their corresponding symbols on the keyboard. These are NOT reading errors as readings are 100% accurate outside Unity. With the 25 speed setting, readings are accurate inside Unity as well.

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
avatar image
-1

Answer by Pangamini · Jan 14, 2014 at 08:31 PM

This is not an unity related question in any way, ask on forums related to .Net / C# / forums related to this hardware (does it come with some API?) , because that's how you are going to access it.

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
avatar image Benoit Dufresne · Jan 16, 2014 at 07:17 PM 0
Share

It IS related to Unity if you take the simplest route, which is Input.inputString

avatar image
-1

Answer by gulink · Jun 03, 2014 at 03:42 AM

if you want to create a barcode scanner, why don't you go to some barcode reader creation website. you will find easy way to create a barcode reader in Visual Studio with a few steps.

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
avatar image
-1

Answer by fenden · Apr 02, 2015 at 12:35 PM

I think you may refer to some .net bar code reader websites, or another one is Zxing bar code, which I've heard recently.

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
avatar image
-1

Answer by royallauker · Oct 09, 2018 at 04:37 AM

Is this what you're looking for? Use a barcode scanner sdk to read an existing barcode like reading QR code c# etc.

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
  • 1
  • 2
  • ›

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

18 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

Related Questions

how to do a laser pointer 1 Answer

How to get a LineRenderer to shoot from Gun Point to Mouse Position 1 Answer

How do I make a line render always be pointing at the center of the canvas/gui 1 Answer

what is the best way of making a laser gun that shoots long ray of la 3 Answers

Creating laser gun effect. 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