In the last one, we provide an introduction to the two main versions QFramework, and wrote the first QFramework script.
In this one, we learn QFramework in almost every project should be used and benefit functions: automatic generation of scripts and bindings, referred to as script generation.
In our first scenario, just create some parent-child structure GameObject, as follows:
They are empty nodes, and no real logic, just to demonstrate a normal parent-child structure.
Now GameRoot to write a script, but the script needs to get to the GameObject Player.
We generally will write in GameRoot in:
void Start()
{
var playerGameObj = transform.Find("Player").gameObject;
}
And the time to write this line, we need to spend about 10 seconds, but such an approach will have some risks, such as Player's name has changed.
And our "build scripts" feature is to solve this problem born.
Now we just need to do three things.
One is to put GameRoot ViewController, shortcut keys (Alt + V), as shown below:
Second, fill in the information component just added:
Here, you can fill in the name and generated script to generate scripts in which directory?
Thereafter, the assembly is Player GameObject hung Bind (shortcut key, alt + b), as shown below:
Player hung components as follows:
Then we can click on the Generate Code button to generate the code button, or the figures are ViewController of GameRoot, both of which are clicking.
After clicking, it will generate the code, wait compiled results are as follows:
Scripts directory:
GameRoot Screenplay:
We see, GameRoot automatically get a reference to the Player's.
Further, in the direct access to GameRoot.cs Player, as shown below:
So you can play happily drop programming, ha ha ha ha ha.
- Address reprint please specify: sandals notes: liangxiegame.com.
- Any questions welcome to QQ group: 623 597 263 exchange.