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 SLIMEBASS · May 09, 2013 at 05:34 PM · c#wwwform

WWWForm in C#

Need to convert this into Javascript:

 var url = "http://www.slimebass.com/test.php";
 function Start() {
     var form = new WWWForm();
     form.AddField( "xp", Random.Range(0, 20));
     var download = new WWW( url, form );
     yield download;
     if(download.error) {
         print( "Error downloading: " + download.error );
         return;
     } else {
         Debug.Log(download.text);
     }
 }

//SLIMEBASS

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 robertbu · May 09, 2013 at 05:56 PM 0
Share

This is an easy conversion, and the ability to convert is a good (almost necessary if you follow UA) skill to have. Here is a link to the the differences between the two languages:

http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html

I highly recommend that you take a shot at doing the conversion yourself and post a new question if you get stuck.

avatar image SLIMEBASS · May 09, 2013 at 06:09 PM 0
Share

Thanks for the link. Still got 2 more error (7,22)(9,22) using UnityEngine; using System.Collections;

 public class Form : $$anonymous$$onoBehaviour {
 public int url = "http://www.slimebass.com/test.php";
     void  Start (){
         public int form = new WWWForm();
         form.AddField( "xp", Random.Range(0, 20));
         public int download = new WWW( url, form );
         yield return download;
         if(download.error) {
             print( "Error downloading: " + download.error );
             return;
         } else {
             Debug.Log(download.text);
         }
     }
 }

1 Reply

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

Answer by robertbu · May 09, 2013 at 06:24 PM

A few extra gotchas there I did not see on first read. Here is a untested conversion:

 using UnityEngine;
 using System.Collections;
 
 public class Form : MonoBehaviour {
 public string url = "http://www.slimebass.com/test.php";
     IEnumerator  Start (){
        WWWForm form = new WWWForm();
        form.AddField( "xp", Random.Range(0, 20));
        WWW download = new WWW( url, form );
        yield return download;
        if((!string.IsNullOrEmpty(download.error))) {
          print( "Error downloading: " + download.error );
        } else {
          Debug.Log(download.text);
        }
     }
 }
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 SLIMEBASS · May 09, 2013 at 06:54 PM 0
Share

Thank you :)

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

14 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Upload files to a remote form using C# in Unity 2 Answers

www.text + php + c# issue 2 Answers

Runtime Image Conversion (C#) .ICO to .PNG? (.ICO not supported; WWW.texture only accepts .PNG and .JPEG) 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