[Unity]Basic Usage Notes
Keywords: Unity, Basic Usage
Assets
Import
Q: How to open .unitypackage file?
A: Menu: Assets
-> Import Package
-> Custom Package
.
Navigation
Q: How to address to asset directory from selected object?
A:
Address to Scene directory:
Address to Asset directory:
Prefab
Q: How to create a cube prefab asset?
A: The example script above won’t work until you assign a Prefab to the Block variable. To create a simple block Prefab:
- Choose
GameObject
>3D Object
>Cube
. - Drag the cube from the
Hierarchy
window into the Assets folder in theProject
window. This creates a Prefab Asset. - Rename your Prefab to
Block
. - Now that your
Block
Prefab exists as an Asset, you can safely delete the cube from your Hierarchy.
Reference:
https://docs.unity3d.com/Manual/InstantiatingPrefabs.html
Scene
Create Scene
Q: How to create scene?
A: Project Panel
-> Create
-> Scene
.
Scene asset file:
Or: Right click in Project Panel
-> Create
-> Scene
GameObject
Script
Q:How to create GameObject?
A:Hierarchy Panel
-> Creat
-> Create Empty
.
GameOjbect in scene:
Q:How to create C# script?
A:Project Panel
-> Create
-> C# Script
.
C# Script file:
Q:How to attach script on GameObject?
A:Select GameObject in Hierarchy
panel, then click Add Component
-> Scripts
-> Select C# script file.
Programming
Generate sln (Visual Studio) file
1, Edit -> Preferences -> External Tools -> External Script Editor -> Visual Studio.
2, Assets -> Open C# Project.
Debug in Visual Studio
Q:How to debug C# Script in Visual Studio?
A:
-
Install
Visual Studio Tools for Unity
: checkGame development with Unity
in installation detail window of Visual Studio.Microsoft Visual Studio Tools for Unity enabled
would be shown in Unity EditorAbout
panel when installation is finished. -
Edit
->Preferences
->External Tools
-> SetExternal Script Editor
asVisual Studio
. -
Click
Attach to Unity
, then run game in editor, breakpoint would be trigger in Visual Studio. Or you can clickAttach to Unity and Play
, game would be run from Visual Studio.
Use Visual Studio Tools for Unity
https://docs.microsoft.com/en-us/visualstudio/cross-platform/using-visual-studio-tools-for-unity?view=vs-2019
Get started with Visual Studio Tools for Unity
https://docs.microsoft.com/en-us/visualstudio/cross-platform/getting-started-with-visual-studio-tools-for-unity?view=vs-2019
Tutorials
Youtube Tutorials
100 UNITY TIPS!!! 🔥
https://www.youtube.com/watch?v=thA3zv0IoUM
No person deserves your tears, and who deserves them won't make you cry. ― Gabriel García Márquez