Step 1 Creating a New Library

Choose Tools -> Fast Compilation -> Create New and enter ”CameraEffects” as Library name, leave the rest on the default.

Press Create button at the bottom of the window.

You will notice  a new folder called ‘Camera Effects’ appears under the Assets folder.

“Assets -> Camera Effects -> VisualStudioFiles~ -> NonPlugins -> Runtime” is where you will put your source files.

Step 2 Creating Your Source File

You have two ways to add your source code, either in your operating system explorer or through visual studio if you have it installed.

Option 1 Through Visual Studio

Now in the Library press ‘Open Solution’, Visual Studio should open with a solution and a project called ‘FastCompileDLL’.
Right click the ‘FastCompileDLL’ project and choose ‘Add -> New Item’.

Adding Source to Unity Fast Compilation Library in Visual Studio

Adding Source to Unity Fast Compilation Library in Visual Studio

Then from ‘Visual C# Items’ choose ‘Class’ and name it CameraShake.cs

Option 2 In Explorer

Open the source folder for your new Unity Fast Compilation Library’s Runtime module by clicking ‘Project Folder’ in the ‘Libraries’ window of your newly created Fast Compilation Library.
From the popup menu choose ‘Runtime Source Folder’.

Adding Source to Unity Fast Compilation Library

Adding Source to Unity Fast Compilation Library

In the opened folder please create a new file called CameraShake.cs open it in the editor of your choice, or get back to unity and press ‘Open Solution’ from the Libraries window in the row of your newly created library and edit the source inside visual studio.

Pro Tips

The following files are automatically generated and update so you shouldn’t modify them manually.

“Assets -> Camera Effects -> VisualStudioFiles~ -> NonPlugins -> Runtime -> FastCompileDLL.csproj”

“Assets -> Camera Effects -> VisualStudioFiles~ -> FastCompileDLL.sln”

Step 3 Writing Your Source Code

Please write the following code in CameraShake.cs

using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

class CameraShake : MonoBehaviour {

 Vector3 startingPosition;

 void Start() {
     startingPosition = FindObjectOfType<Camera>().transform.position;

 void Update() {
     if(Input.GetKey(KeyCode.A)) {
         Vector3 randomVector = new Vector3(Random.Range(0.1f, 1.0f), Random.Range(0.1f, 1.0f),    Random.Range(0.1f, 1.0f));
         FindObjectOfType<Camera>().transform.position = startingPosition + randomVector;

Step 4 Compiling the Code

Press ‘Tools -> Fast Compilation -> Libraries List’ and press ‘Compile Solution’ for the ‘Camera Effects’ fast compilation library for unity.

Step 5 Testing Your Fast Compilation Library

From Game Object menu choose 3D Object -> Cube.

Choose your Main Camera from scene hierarchy and in the Inspector press ‘Add Component’  and search for ‘Camera Shake’ then add it.

Test play and hold ‘A’ to get the camera shaking.