Unity Basics


Folder structure

graph LR A[Unity] --> B(Hierachy); B --> D(Game scene objects); A --> C(Inspector); B -->|select affects| C; A --> E(Project); E --> F(Assets); F --> G(Scenes); F --> H(Prefabs); F --> I(Materials); F --> J(Scripts); F --> P(PhysMaterials); G --> B;

Operations

  1. At Hierarchy, you can create any simple game objects via right click.
  2. Select game object affects whats shown in Inspector.
  3. z-axis: forward and backward, x-axis: left and right, y-axis: up and down.
  4. alt+left key: rotate, middle key: translate, e: rotation tool, r: scaling tool, w: move tool for object, these tools affect transform in inspector.
  5. Rename F2 either in Inspector or SampleScene.
  6. Can create any thing in assets, materials, scripts, etc.
  7. To apply a property like material to an object in scene, you can drag it to Hierarchy object or object in the scene.
  8. Shift+F : Focus on your object selected.
  9. Ctrl+D: Duplicate object.
  10. Making an object a child of another object: drag the child to the parent in hierarchy.
  11. Materials: store color material, Prefabs: store reusable objects which can be changed easily, Scenes: store all samplescenes, .
  12. Drag object from hierarchy to prefab to create a storage of reusable objects.
  13. Create empty object, it acts like an empty folder to store all objects.
  14. Edit → Preferences → External Tools #&8594 External Script Editor: vscode.
  15. Add Component: can add behavior scripts and physics to the object.
  16. Rigid body component: can apply force like gravity.
  17. Script component: make sure your script class name is matching your object name.
  18. 
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class Player : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            
        }
    
        // Update is called once per frame
        void Update()
        {
            
        }
    }
        
  19. Edit → Project settings → Input Manager: It shows the inputs can be used by player.
  20. Useful built-in methods in C# script,
  21. 
    void Start()
    void Update()
    void FixedUpdate()
    void OnCollisionEnter(Collision collision)
    void OnCollisionExit(Collision collision)
    void OnTriggerEnter(Collision other)
        
  22. public (/SerializeField private) variable (/field) in the script will export to Unity. Can drag an empty object to connect with it.
  23. 
    public datatype dataname;
    [SerializeField] private datatype dataname;
        
  24. Layer Filtering: Click object → Add Layer named Player → Change Layer to Player → Edit → Project settings → Physics uncheck Player layer
  25. In order to import meshes from blender, you need to scale it in blender and import it and set scale as 1 1 1. Remove the box collider and add component again as well, so the collider becomes the right shape.
  26. Remember to export from blender as fbx.
  27. Remember to import color scheme as new material.

    

References


  1. Welcome to the Unity Scripting Reference!
  2. LEARN UNITY - The Most BASIC TUTORIAL I'll Ever Make
  3. Make Your FIRST COMPLETE Game in Unity | BEGINNERS