关于c#调用java脚本的问题。

相关文档:

file:///C:/Program%20Files/Unity3.5/Editor/Data/Documentation/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html

有中文文档,但是感觉还是先看英文的,如果怕理解不透测再参照中文文档看。个人感觉获益良多

http://game.ceeger.com/Script/Overview/Overview.Script_compilation.html

最近有个单子,是关于设置泛光效果的。因为泛光效果的脚本是java的。要做到功能很简单,其实就是获取脚本,然后enable。

关键的问题还是在C#里改如何获取java脚本。

其实很简单的,文档说的很清楚。

在unity3d里,脚本的存放位置将直接关系到编译的顺序。

for examle:要获取的脚本为java脚本,BloomAndLensFlares,这个脚本是attch在Main Camera上的。

这个脚本应该放在 "Standard Assets", "Pro Standard Assets" or "Plugins" ,因为【All scripts in "Standard Assets", "Pro Standard Assets" or "Plugins" are compiled first.

然后调用这个脚本的代码应该放在爱scripts里

然后我们可以直接BloomAndLensFlares bloom = new BloomAndLensFlares();

或者直接

if (COSGame.cameraMng.mainCamera != null)
 {
            if( MainCamera.GetComponent<BloomAndLensFlares>() != null)
            {
                MainCamera.GetComponent<BloomAndLensFlares>().enabled = _active;
            }      
        }

}

利用好文档。方法很重要!

原文地址:https://www.cnblogs.com/oldman/p/2800842.html