简体   繁体   English

Unity3d插件是用C#编写的,我想使用UnityScript与之交互

[英]Unity3d plugin is written in c#, I'd like to interact with it using UnityScript

I made a little android game in unity. 我统一制作了一个小机器人游戏。 I used UnityScript. 我使用UnityScript。

Most of the unity plugins I've come across are written in mostly in c#; 我遇到的大多数统一插件都是用c#编写的; this one, for example: https://github.com/playgameservices/play-games-plugin-for-unity . 例如: https : //github.com/playgameservices/play-games-plugin-for-unity I can make simple changes (commenting out stuff), but for the most part I can't tell the difference between c# and the potholes on my street. 我可以进行简单的更改(注释掉东西),但是在大多数情况下,我无法分辨c#和街道上的坑洼之间的区别。 This has limited me to the default setting of a very basic advertising plugin. 这使我只能使用非常基本的广告插件的默认设置。

If it's possible, I'd like to make whatever calls I need to from a UnityScript, but I haven't been able to figure that out on my own. 如果可能的话,我想通过UnityScript进行所需的任何调用,但是我无法自己弄清楚。

Failing this, I'd need to get a good starting point for learning c#, in the context of unity3D development. 否则,我需要在unity3D开发的背景下为学习c#提供一个良好的起点。

You have to take Unity3D's file compilation order into account, which is well documented at Special Folders and Script Compilation Order 您必须考虑Unity3D的文件编译顺序,这在“ 特殊文件夹”和“脚本编译顺序”中有详细记录

This is significant in cases where a script must refer to classes defined in other scripts. 这在脚本必须引用其他脚本中定义的类的情况下非常重要。 The basic rule is that anything that will be compiled in a phase after the current one cannot be referenced. 基本规则是,不能引用将在当前阶段之后的阶段中编译的任何内容。 Anything that is compiled in the current phase or an earlier phase is fully available. 在当前阶段或更早的阶段中编译的所有内容都是完全可用的。

and

A common example is where a UnityScript file needs to reference a class defined in a C# file. 一个常见的示例是UnityScript文件需要引用C#文件中定义的类。 You can achieve this by placing the C# file inside a Plugins folder and the UnityScript file in a non-special folder. 您可以通过将C#文件放在Plugins文件夹中,将UnityScript文件放在非特殊文件夹中来实现此目的。 If you don't do this, you will get an error saying the C# class cannot be found. 如果您不这样做,则会收到一条错误消息,提示找不到C#类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM