• 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 Strece · Apr 16, 2012 at 03:48 PM · convert

Need help converting some JS to C#

Hey,

I need help with come script converting to C#. I have used .NET-Reflector to decompile the Assembly-UnityScript.dll. I get all the scripts in C# code, but with some errors I can't solve.

Maybe someone here know a solution.

The following methods are from JS, I don't know how to convert this to C#, with decompile I get errors.

 function Function(func : function(float) : float, x0 : float, x1 : float, col : Color32, stepSize : float, scaleY : float)
     {
     MoveTo(x0, func(x0) * scaleY);
     
     for (var x=x0; x<=x1; x+=stepSize)
         LineTo(x, func(x) * scaleY, col);
         
     if (x < x1)
         LineTo(x1, func(x1) * scaleY, col);
     }
     
 function Function(func : function(float) : float, x0 : float, x1 : float, col : Color32, stepSize : float)
     {
     this.Function(func, x0, x1, col, stepSize, 1.0);
     }
     
 function Function(func : function(float) : float, x0 : float, x1 : float, col : Color32)
     {
     this.Function(func, x0, x1, col, 0.1, 1.0);
     }
     
     
 function Function2(func : function(float, float) : float, p : float, x0 : float, x1 : float, col : Color32, stepSize : float, scaleY : float)
     {
     MoveTo(x0, func(x0, p) * scaleY);
     
     for (var x=x0; x<=x1; x+=stepSize)
         LineTo(x, func(x, p) * scaleY, col);
         
     if (x < x1)
         LineTo(x1, func(x1, p) * scaleY, col);
     }
     
 function Function2(func : function(float, float) : float, p : float, x0 : float, x1 : float, col : Color32, stepSize : float)
     {
     this.Function2(func, p, x0, x1, col, stepSize, 1.0);
     }
 
 function Function2(func : function(float, float) : float, p : float, x0 : float, x1 : float, col : Color32)
     {
     this.Function2(func, p, x0, x1, col, 0.1, 1.0);
     }

     
 
 function Function3(func : function(float, float, float) : float, p : float, q : float, x0 : float, x1 : float, col : Color32, stepSize : float, scaleY : float)
     {
     MoveTo(x0, func(x0, p, q) * scaleY);
     
     for (var x=x0; x<=x1; x+=stepSize)
         LineTo(x, func(x, p, q) * scaleY, col);
         
     if (x < x1)
         LineTo(x1, func(x1, p, q) * scaleY, col);
     }        

 function Function3(func : function(float, float, float) : float, p : float, q : float, x0 : float, x1 : float, col : Color32, stepSize : float)
     {
     this.Function3(func, p, q, x0, x1, col, stepSize, 1.0);
     }
 
 function Function3(func : function(float, float, float) : float, p : float, q : float, x0 : float, x1 : float, col : Color32)
     {
     this.Function3(func, p, q, x0, x1, col, 0.1, 1.0);
     }

This is the decompile result:

 public override void Function(CompilerGenerated.__GUICanvas_Function$callable0$372_34__ func, float x0, float x1, Color32 col, float stepSize, float scaleY)
 {
     this.MoveTo(x0, func(x0) * scaleY);
     float xn = x0;
     while (xn <= x1)
     {
         this.LineTo(xn, func(xn) * scaleY, col);
         xn += stepSize;
     }
     if (xn < x1)
     {
         this.LineTo(x1, func(x1) * scaleY, col);
     }
 }
 public override void Function(CompilerGenerated.__GUICanvas_Function$callable0$372_34__ func, float x0, float x1, Color32 col, float stepSize)
 {
     this.Function(func, x0, x1, col, stepSize, 1f);
 }

 public override void Function(CompilerGenerated.__GUICanvas_Function$callable0$372_34__ func, float x0, float x1, Color32 col)
 {
     this.Function(func, x0, x1, col, 0.1f, 1f);
 }

 public override void Function2(CompilerGenerated.__GUICanvas_Function2$callable1$396_35__ func, float p, float x0, float x1, Color32 col, float stepSize, float scaleY)
 {
     this.MoveTo(x0, func(x0, p) * scaleY);
     float xn = x0;
     while (xn <= x1)
     {
         this.LineTo(xn, func(xn, p) * scaleY, col);
         xn += stepSize;
     }
     if (xn < x1)
     {
         this.LineTo(x1, func(x1, p) * scaleY, col);
     }
 }

 public override void Function2(CompilerGenerated.__GUICanvas_Function2$callable1$396_35__ func, float p, float x0, float x1, Color32 col, float stepSize)
 {
     this.Function2(func, p, x0, x1, col, stepSize, 1f);
 }

 public override void Function2(CompilerGenerated.__GUICanvas_Function2$callable1$396_35__ func, float p, float x0, float x1, Color32 col)
 {
     this.Function2(func, p, x0, x1, col, 0.1f, 1f);
 }

 public override void Function3(CompilerGenerated.__GUICanvas_Function3$callable2$420_35__ func, float p, float q, float x0, float x1, Color32 col, float stepSize, float scaleY)
 {
     this.MoveTo(x0, func(x0, p, q) * scaleY);
     float xn = x0;
     while (xn <= x1)
     {
         this.LineTo(xn, func(xn, p, q) * scaleY, col);
         xn += stepSize;
     }
     if (xn < x1)
     {
         this.LineTo(x1, func(x1, p, q) * scaleY, col);
     }
 }

 public override void Function3(CompilerGenerated.__GUICanvas_Function3$callable2$420_35__ func, float p, float q, float x0, float x1, Color32 col, float stepSize)
 {
     this.Function3(func, p, q, x0, x1, col, stepSize, 1f);
 }

 public override void Function3(CompilerGenerated.__GUICanvas_Function3$callable2$420_35__ func, float p, float q, float x0, float x1, Color32 col)
 {
     this.Function3(func, p, q, x0, x1, col, 0.1f, 1f);
 }

I hope this is not too much.

Greetings,

Strece

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 Jessy · Apr 16, 2012 at 07:36 PM 1
Share

I think it was too much. Learn this stuff: http://msdn.microsoft.com/en-us/library/ms173171(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/018hxwa8.aspx http://msdn.microsoft.com/en-us/library/bb549151.aspx

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Particle circle HELP 1 Answer

Convert to C#,I don't know how to convert this 1 Answer

Convert vertical angle to horizontal angle (C#) 1 Answer

Convert From C# Into JavaScript Please? 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