Unity – Unity By Example - Page 3

Free Camera Controller in Unity

Free camera controller can move freely during the game, just like in the scene. Steps Create script FreeCamera.cs Add script FreeCamera.cs to Main Camera Result Download

First Person Camera Controller in Unity

The first-person perspective combines the camera and the player model. It is used to control movement and look. Steps Create sripts FirstPersonCamera.cs Object hierarchy and properties Do the same as shown in the picture. Result Download

Unity Attributes That Make the Inspector Easier To Use

Attributes are markers that can be placed above a class, property or function in a script to indicate special behaviour. RequireComponent The RequireComponent attribute automatically adds required components as dependencies. When you add a script which uses RequireComponent to a GameObject, the required component is automatically added to the GameObject. This is useful to avoid ... Read More

How to Save and Load a Game in Unity

Unity provides various ways to save game data. One way involves Unity’s built-in PlayerPrefs system. Give a value to the key, call Save. Another way to save is JSON. Steps Create scritps Storage.cs, Building.cs, Construction.cs Create Building object in the Scene and attach Building.cs Create empty object in the Scene and attach Construction.cs Fill in ... Read More

How to Display FPS (Frames Per Second) in Unity

FPS (Frames Per Second) is a value that represents the number of frames that the computer renders in one second. Steps Create script FPS.cs Add Text Mesh Pro object to a Scene. Drag and drop FPS.cs to Text Mesh Pro in the Scene. Result Now FPS will be displayed on a screen. Download