Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile Cs into Js with JSBinding + SharpKit

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how JSBinding + SharpKit compiles Cs into Js. The content of the article is of high quality, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.

The compilation symbols passed to skc5.exe can be found in Compiler.cs. Notice that the symbol contains Unity_Editor, and here's why. First of all, Js distinguishes overloaded functions by adding suffixes to functions, such as having a class

1 class A2 {3 public void f(int i){}4 public void f(string s){}5 }

The generated Js function names are

1 f$$Int322 f$$String

When you run JSB| Generate JS and CS Bindings], the code is executed under the editor, so there must be a definition of UNITY_EDITOR at that time. Let's change the definition of A:

class A{#if UNITY_EDITOR public void f(int i){}#endif public void f(string s){}}

The names of these two functions are still generated.

f$$Int32f$$String

If the Js compiler does not define Unity_EDITOR, when you call a.f(""), it generates Js code that is

a.f("") //No suffix, call failed!

Because he thinks that f is not overloaded, he will not add suffixes to it. The result was that the call failed!

I don't know if this situation exists at present, but there is a certain risk ~!

About JSBinding + SharpKit how to compile Cs into Js to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report