Using Scripts
Last updated
Last updated
To make script that he can execute code from, its need to be attached to a GameObject. Before that we need to create script component for our GameObject. So COMPONENT -> CSharpScript do that. Or you can click on GameObject -> Components Menu and choose CsScriptComponent from there.
After that this component will be add to our GameObject:
And then we just need to drag the asset of the script from the browser, that we created Script early into the field for the item of selected GameObject. So when script is attached, it already create that instance that we discuss early and can be executable.
But basically now Force (0.4+) will automatically recompile all scripts when any script file will be modified, move, removed, added.
Debug.Log()
function called from utility class Debug, and its job is just log the input text in to Console Log window in editor.
Now press the Play button and see the results.
Before we write first line of script code,I wont to say that just like in Visual Studio, you can compile the script right here by clicking on button on the Gameplay Toolbar or by pressing Ctrl+F5. This very useful when you write script in simple notepad.