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
1
Question by daivd.ramz · Oct 22, 2012 at 09:08 AM · splitstring.split

Problem About String.Split() Function

Hi, all! I am runnig this code in unity: var member_url = "http://localhost/search.php"; var ID="2"; var action = "show"; function Start(){ var form = new WWWForm(); form.AddField( "action", action); form.AddField( "id", ID); var download = new WWW( member_url, form ); yield download;

 if(download.error) {
     print( "Error downloading: " + download.error );
     return;
 } else {
     // show the data
     Debug.Log(download.text);
     var data = download.text;
     var values = data.Split(",");//pay attention to this part
     var v1 : float = parseInt(values[0]);
     var v2 : float = parseInt(values[1]);
     print(v1+v2);
 }

}

but unity show this error:
 BCE0023: No appropriate version of 'String.Split' for the argument list '(String)' was found.
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 daivd.ramz · Oct 22, 2012 at 10:54 AM 0
Share

Thanks a lot

1 Reply

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

Answer by Kryptos · Oct 22, 2012 at 09:40 AM

Take a look at the documentation before using a method. String.Split takes an array of char as parameter, not a string.

So the correct usage is (C#):

 data.Split(new char[]{','});

With UnityScript you need to use a workaround since ther are no character literals:

 var separator : char[] = [","[0]];
 data.Split(separator);


Comment
Add comment · Show 5 · 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 daivd.ramz · Oct 22, 2012 at 10:55 AM 0
Share

Thanks a lot

avatar image daivd.ramz · Oct 22, 2012 at 10:58 AM 0
Share

but what can ido with this?

var v1 : float = parseInt(values[0]); var v2 : float = parseInt(values[1]); unity error:FormatException: Input string was not in the correct format

avatar image daivd.ramz · Oct 22, 2012 at 11:05 AM 0
Share

Thanks a lot

avatar image Kryptos daivd.ramz · Oct 22, 2012 at 11:17 AM 0
Share

Please don't post comment as answers.

avatar image Kryptos · Oct 22, 2012 at 11:29 AM 0
Share

I don't know about parseInt. In .Net the method is named int.Parse (see: Int32.Parse $$anonymous$$ethod (String)).

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

10 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

Related Questions

What do you say the best way to store a string be? 2 Answers

String.Split With Backslash 2 Answers

split() for separators more than 1 characters 2 Answers

Split webplayer build into smaller files? 1 Answer

how can you split an object in half 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