Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnityEngine导出文件放到Plugins后会引起扩展方法找不到的问题 #103

Closed
wlgys8 opened this issue Nov 20, 2015 · 12 comments
Closed

Comments

@wlgys8
Copy link
Contributor

wlgys8 commented Nov 20, 2015

例如对Sprite定义了一些扩展方法放到文件 SpriteExt.cs 中。

这个SpriteExt.cs是在Assembly-CSharp中的,而Lua_UnityEngine_Sprite是在Assembly-CSharp-firstpass中,引用不到SpriteExt.cs

@pangweiwei
Copy link
Owner

嗯,该了目录结构,这到是个问题了:(

@pangweiwei
Copy link
Owner

我刚才看到5.2.3发布了,貌似修复UNetWeaver的bug

@pangweiwei
Copy link
Owner

你可以考虑revert之前的目录结构,就不存在这个问题了

@wlgys8
Copy link
Contributor Author

wlgys8 commented Nov 20, 2015

我把generate code path改回到了之前的目录。
其他的还是遵循现在新的目录结构吧。

5.2.3 的release note里好像没看到关于UNetWeaver那个问题的说明?
只看到了(none) - Networking: Fix for UNetWeaver exception when making Metro builds这个,针对metro的

@pangweiwei
Copy link
Owner

Networking: Fixed code generation execption when using certain build-in unity types ...

这个估计是个fix,猜的

@wlgys8
Copy link
Contributor Author

wlgys8 commented Nov 20, 2015

还有一个问题:
Plugins/SLua_Managed/Editor 这个目录下的文件似乎会被编译到Assembly-CSharp-firstpass中 而不是Assembly-CSharp-Editor-firstpass,
build的时候会报错,引用了UnityEditor

Plugins/Editor 应该只能识别这个一级目录?

@Salada
Copy link
Contributor

Salada commented Nov 20, 2015

@wlgys8 I think this document is good reference
http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html

Phase 1 is compiled to Assembly-CSharp-firstpass.dll
Phase 2 is compiled to Assembly-CSharp-Editor-firstpass.dll ( depends Assembly-CSharp-firstpass.dll )
Phase 3 is compiled to Assembly-CSharp.dll ( depends Assembly-CSharp-firstpass.dll )
Phase 4 is compiled to Assembly-CSharp-Editor.dll ( depends above all )

this files is possibly checked in specific folder {UNITY_PROJECT}/Library/ScriptAssemblies/

@wlgys8
Copy link
Contributor Author

wlgys8 commented Nov 20, 2015

@Salada
I'v read this document. The issue is:
If we define some extension methods for UnityEngine.Sprite in SpriteExt.cs,
1.SpriteExt.cs will be compiled into Assembly-CSharp.dll
2.Lua_UnityEngine_Sprite.cs will be compiled into Assembly-CSharp-firstpass.dll

We can not access SpriteExt.cs in Lua_UnityEngine_Sprite.cs.
This will cause a compile error.

@Salada
Copy link
Contributor

Salada commented Nov 20, 2015

If want to use method extensions by class in UnityEngine.dll, I think need to 2 bind load phase and codegen phase. but changelist expect too many. and i have just idea. not attempt to implement this feature yet.

I turn off feature about extensions method in SLuaSetting.asset, couldn't catch this problem :(

I think Editor folder need to be located in /Editor not in /Plugins/Editor, Assembly-CSharp-Editor-firstpass.dll cannot access Assembly-CSharp.dll. then your needs is accomplished.

@wlgys8
Copy link
Contributor Author

wlgys8 commented Nov 20, 2015

@Salada
I agree with you

@wlgys8
Copy link
Contributor Author

wlgys8 commented Nov 20, 2015

If put folder Editor under Plugins
LuaCodeGen.InvokeEditorMethod will throw error below:

    System.IO.FileNotFoundException: Could not load file or assembly 'Assembly-CSharp-Editor' or one of its dependencies. The system cannot find the file specified.
    File name: 'Assembly-CSharp-Editor'

Should move folder editor back to Assets/Slua/Editor ?

@pangweiwei
Copy link
Owner

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants