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 Lance88 · Nov 30, 2010 at 03:16 PM · syntax-errorcs1525cs1526

errors with zxing barcode scanner

hey all, I get this parse error and some other errors when I want to implement the code for using the zxing barcode scanner.

this is the code I use:

using UnityEngine; using System.Collections;</p> <p>public class Scanner : MonoBehaviour {</p> <pre><code>// Use this for initialization void Start () { gameObject.Find("ScanBtn").setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); startActivityForResult(intent, 0); } }); } // Update is called once per frame void Update () { public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { if (resultCode == RESULT_OK) { String contents = intent.getStringExtra("SCAN_RESULT"); String format = intent.getStringExtra("SCAN_RESULT_FORMAT"); // Handle successful scan gameObject.Find("ScanBtn").Destroy(); } else if (resultCode == RESULT_CANCELED) { // Handle cancel } } } } </code></pre> <p>}

the errors that I get are these:

Assets/Scanner.cs(10,22): error CS1526: A new expression requires () or [] after type

Assets/Scanner.cs(10,42): error CS1525: Unexpected symbol `v'

Assets/Scanner.cs(15,18): error CS8025: Parsing error

any help would be greatly appreciated :)

Comment
Add comment · Show 2
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 vguruv · Jun 21, 2011 at 03:46 PM 0
Share

@Lance88 - Were you able to solve the view and intent problems? Could you please share your solution with me ? (vguruv at yahoo com)

avatar image nezwork · Feb 02, 2012 at 11:14 AM 0
Share

@Lance88 - Could you please share your solution with me ? (nezwork gmail com)

1 Reply

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

Answer by Mike 3 · Nov 30, 2010 at 03:21 PM

Your problem is with the code in start - you're trying to declare a new function instead of declaring a delegate

I would fix it like this:

void Start () { gameObject.Find("ScanBtn").setOnClickListener(onClick); }

void onClick(View v) { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); startActivityForResult(intent, 0); }

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 Lance88 · Nov 30, 2010 at 03:26 PM 0
Share

thanks a bunch, this helped me alot. Now I only need to figure out why it doesn't take view and intent...

avatar image DamienSturdy · Apr 17, 2012 at 02:18 PM 0
Share

This is handy for me too thanks- I do have a question for you, How on earth are you accessing Intents from C#? I'm pulling my hair out with code, searching the net etc, and in this snippet you're just using them straight off! Is there a library you're using? or have I completely missed what's going on here?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

error CS1525! having problems with Save scripts and following BurgZergArcade! 1 Answer

error CS1525: Unexpected symbol `)' 2 Answers

How To Read Error Messages CS1525 1 Answer

Need help on Transportation errors 1 Answer

Unable To Find Solution For Errors 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