IntelliJ EmmyLua development debug Unity Xlua
You may get an error when running: Program [lua.exe] not found. What to do? The inadequacies of plug-ins do not have a built-in lua environment. You need to install "Lua for window" yourself. I hope the plug-in will be able to build in the future. According to the author's response, considering the size of the "at least two platforms 32 64, plus luasocket module, but also to consider the platform and version issues" built-in is impossible.
Portal:
Method One: Lua for Windows download (compared with the source code version will be behind some)
And comes with the editor SciTE , while the tools help us configure the environment variables (plug-in is lua.exe found through this environment variable )
Unzip to the place where you installed the software and configure the environment variables! (Note that lua .exe is my copy of lua 53.exe and renamed)
First, install the plug-in. Note that there is a requirement for the version of IDEA that cannot be lower than 2017.1
Theoretically, if you have installed any of these products, you can install the plugin as long as the version is high enough.
"IntelliJ IDEA, PhpStorm, WebStorm, PyCharm, RubyMine, AppCode, CLion, Gogland, DataGrip, Rider, Android Studio"
Take Rider 2017.1.1 as an example ( but IDEA is recommended , otherwise there may be no way to create a Lua project )
File -> Settings then
You can download the plug-in locally and then choose to install it from disk. You can also search for the installation in the IDEA tool (I'm this).
Then click Install on the right side and reboot.
Note: There may be problems with downloading . This is related to the network operator used. Can only be installed in another way! ! !
After the restart, create a new project (or open the project and select the folder where the Lua file is located!)
In the s rc directory, create a new main.lua file, enter
Print ( "Test main" )
Run, normal output, no error on OK !
Try Debug mode and set breakpoints are normal! !
To import the Unity project:
IDEA File -> New -> Module from Existing Sources Select Unity project Assets on the line.
How to debug lua code in the project ?
File -> Project Structure in (this is the source itself can add more!)
The problem I encountered was the process of setting up the Sources Root . For example, I was going to debug the LuaTestScript.lua.txt script in the xlua project .
Answers from administrators in the group: " root is the root directory of the lua file in your code. "
For example, your code is in src/lua/test/1.lua and your code is in 'test/1.lua'. Your lua directory is root . What does this kind of access mean in xlua?
For example , the second parameter luaEnv.DoString in Lua Behaviour.cs below !
Try attachto pid:39556 with x64 debugger.
Found allnecessary Lua functions [M:xlua.dll, V:530]
Debuggerattached to process.
Attachfinish.
[ ✘ ]File not found : Init
[ ✘ ]File not found : LuaBehaviour
Prompt that these two things did not find!
There is an error in the sample code. Change LuaEnv.DoString 's second parameter to LuaTestScript.lua.txt in Lua Behaviour.cs to find it. Even worse, Init doesn't know it.
Try attach to pid:39556 with x64 debugger.
Found all necessary Lua functions [M:xlua.dll, V:530]
Debugger attached to process.
Attach finish.
[ ✘ ] File not found : Init
[√] File was loaded by : LuaTestScript.lua.txt
VS in the global search " the Init " , Lua is as a string of cs , is LuaEnv .cs file! Change the parameter to " LuaEnv .cs " where he is Under the Xlua \Src folder, add this source. The result is not !
"If the lua code is not a separate file, but the string in cs can be debugged with breakpoints?" The answer is that follow-up may be supported and it is not possible now. But does not affect the normal debugging, lua script you want to debug is normally loaded on the line. do not care!
xlua default lua file name is .lua.txt actually .txt how to make this association IDEA .txt to Emmy Lua plug on the piece?
Code hints ignore case:
How does his code hints work ?
The so-called annotations! The EmmyLua annotation function is simply a helper editor code hint and other functions, and has nothing to do with the actual running logic of Lua code, because they are ordinary Lua annotations.
@class class declaration annotation
Full format: -- - @class {my_type}[ : parent_type] @comment string
@type type mark annotation
Full format: ---@type {my_type}[|other_type] @comment string
@param parameter type mark annotation
Full format: ---@param {param_name} {my_type}[|other_type]@comment string
@return function return value annotation
Full format: ---return {my_type}[|other_type] @comment string
@field property annotation
Full format: ---@fieldpublic|protected {my_field} {field_type}[|other_type] @comment string
Array type
Full format: ---@typeMY_TYPE[]
Dictionary type
Full format: ---@typetable<KEY_TYPE, VALUE_TYPE>
Function type
Full format: ---@typefun(param:MY_TYPE):RETURN_TYPE
So usually write their own lua code these comments are best added! As a norm, it is also easy to read!
Similar to this example code:
After the download is complete, copy to the path that will not be deleted. Lua can be installed in the environment variable location or in the lua project. Back to IDEA , File -> Project Structure
Or back to the main.lua script: enter
---@ type UnityEngine.GameObject
Local go
This will see his code hints when using the go variable!
For example, define the following function
Local function test( trans )
End
The cursor is positioned to trans on , the shortcut key "Alt the Enter"
Select "Create parameter annotation " to add a comment for the parameter, and the entered UnityEngine.Transform will have a code hint.
---@ param trans UnityEngine.Transform
Local function test( trans )
End
This way it is cool to access the trans variable within a function ! ! !
Http://blog.csdn.net/u010019717/article/details/77510066
Comments
Post a Comment