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 JSBinding + SharpKit generates JavaScript bindings

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

Share

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

This article will explain in detail about JSBinding + SharpKit how to generate JavaScript binding, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Export the code for UnityEngine to JavaScript. You can use the functions of Unity in JavaScript.

How to export?

Add the classes you need to export to the JSBindingSetting.classes array, and then run the menu [JSB | Generate JS and CS Bindings].

The suggestion is to write all the classes of UnityEngine.dll and export them all at once, so that you don't need to add them one by one in the future.

However, if it is really applied to the project in the future, it may need to be maintained separately, because the requirements of each project may be different.

Additional reflection calls will be considered in the future, which will be useful if the game is released and you need to use classes that have not been exported before.

(here is an example to add only a small number of categories.)

/ JSBindingSettings.cs// public static Type [] classes = new Type [] {typeof (System.Diagnostics.Stopwatch), typeof (Vector2), typeof (Vector3), typeof (GameObject), typeof (UnityEngine.Object), typeof (UnityEngine.MonoBehaviour), typeof (UnityEngine.Behaviour), typeof (UnityEngine.Component), typeof (Debug), typeof (Input) / /. }

Click the following menu to automatically generate JS bindings:

After the generation is complete, two parts of the code are generated.

Part of it is the C # code, in the folder Assets/JSBinding/Generated/ (specified by the JSBindingSettings.csGeneratedDir variable). Can be modified by yourself)

As shown below

The other part is the JS code, which is all in this file (close to 1m):

StreamingAssets/JavaScript/GeneratedFiles.javascript

This file is loaded when the JS engine starts.

On JSBinding + SharpKit how to generate JavaScript binding to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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