Unity
Information
-
Unity is a versatile cross-platform engine used for creating games, applications, and interactive animations across desktop, mobile, console, and virtual/augmented reality platforms. Unity’s engine provides a highly adaptable environment that supports both 2D and 3D development, making it ideal for a wide range of projects, from simple indie games to complex, enterprise-level applications. Furthermore, the engine’s compatibility spans across major operating systems and gaming consoles, including Windows, macOS, Linux, iOS, Android, PlayStation, Xbox, and Nintendo Switch. With built-in features like real-time rendering, physics simulation, and animation tools, Unity serves as an all-in-one solution for developers. Additionally, its support for AR and VR development empowers creators to produce immersive experiences with robust performance and seamless integration. Finally, our goal with this document is to provide as much information as we can for the Unity engine, its plugins, concepts and more!
-
The engine primarily utilizes C# for scripting and offers extensive support for custom development through a variety of libraries, plugins, and asset packages. With C# at its core, Unity provides a robust framework for implementing gameplay logic, managing data structures, and interacting with the engine’s extensive API. Developers can enhance and extend Unity’s capabilities using third-party libraries, Unity Asset Store packages, and custom plugins written in C#. Furthermore, Unity supports scripting in the form of MonoBehaviour scripts, which provide easy-to-use methods for handling core events like Start(), Update(), and more. This flexibility enables the development of complex systems, such as AI behaviors, procedural content generation, and real-time multiplayer features.
Services
There are several products that Unity offers ontop of their game engine, including DevOps, Advertising and Hosting services.
Header
- Right click and create empty
- Name it below : (Replace HeaderName with the name you would want)
---> HeaderName
Scene
Every project starts with a scene and are a fundamental concept in Unity game / application development. They are self-contained units that contain all of the game objects, components, and data for a particular game level. Scenes can be loaded and unloaded at runtime, which allows developers to create games with multiple levels or to create games that can be customized by the player.
When you create a new Unity project, you are given a default scene that contains a camera and a directional light. You can add additional game objects to this scene by dragging them from the Assets window into the Scene view. Furthermore, you can also create new game objects by using the Create menu in the Hierarchy window.
Once you have created your game objects, you can add components to them. Components are scripts that add functionality to game objects. For example, you can add a Rigidbody component to a game object to make it move around in the world. You can also add a Collider component to a game object to make it collide with other game objects.
When you are finished creating your game objects and adding components to them, you can save your scene by clicking the Save button in the top-left corner of the Unity Editor.
You can also save your scene by pressing Ctrl+S
.
Async Scene
When switching between the scenes or loading multiple scenes, we recommend utilizing the asynchronous scene loader through a custom management script. This will allow you to load complex levels while not impacting performance too greatly.
WebGL
A breakdown of WebGL for the Unity game engine!
WebGL Information
When converting a project over to WebGL, there are a couple extremely important steps that you might have to take to prepare for an automated pipeline and distribution.
The most important step is to make sure that you have the HTML5/WebGL module for the specific Unity version installed and ready.
After that check the resolution, an example would be 800 x 600 but you can set it to your project’s desired scope.
Next you want to make sure to check the box, Run in background
, and save it. This should change the runInBackground
inside of ProjectSettings\ProjectSettings.asset
from 0 (false) to 1 (true).
Finally double check that you have the right compression methods enabled or in some cases, like Github Pages, disabled completely.
Pipeline
Unity has three core concepts for their render / build pipeline, which takes all your source code within your project and builds a finished product for various operating systems.
CICD
For continous integration and continous development within the Unity Pipeline, we recommend going to our git for information.
The notes for Github Actions / Circle CI within Unity and the general scope of the project have been migrated to the Git documentation.
API
Part of building out the game and the multiplayer is to have a reference point for each player, we decided the best way to do that would be through JWTs / web tokens.
Multiplayer
These are our notes and information regarding multiplayer
-
Colyseus.io seems like the first engine of choice that we might use.
-
Reference Links
Strapi
Here is a custom function to help you integrate Strapi
into your application.
Hint: Since the function is an IEnumerator, we suggest wrapping it inside of a coroutine.
private IEnumerator LoginEnumProcess() // [VOID] -> {LoginEnumProcess()}
{
var user = new UserLoginData(); user.identifier = _text_Username.text; user.password = _text_Password.text;
//* {Request Header}
string jsonData = JsonUtility.ToJson(user);
var request = new UnityWebRequest(LoginURL, "POST");
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(jsonData);
request.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
request.method = "POST";
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("Accept", "application/json");
yield return request.SendWebRequest();
//? {y} -> Error
if(request.result != UnityWebRequest.Result.Success) { Debug.Log(request.error); yield break; }
else {
//! {y} -> Success -> #NEXT -> #WIP
JSONNode userData = JSON.Parse(request.downloadHandler.text);
Debug.Log(userData);
GlobalValue.PlayerJWT = userData["jwt"];
GlobalValue.PlayerEmail = userData["user"]["email"];
GlobalValue.PlayerUsername = userData["user"]["username"];
// PlayerPrefs.SetString("jwt", userData["jwt"]);
// PlayerPrefs.SetString("username", userData["user"]["username"]);
// PlayerPrefs.SetString("email", userData["user"]["email"]);
// PlayerPrefs.Save();
//? {y} -> Migrate load to Global Values?
Debug.Log(PlayerPrefs.GetString("username"));
SceneManager.LoadScene("Base", LoadSceneMode.Single);
yield break;
}
}
AppWrite
Another API
that you can use inside of Unity is AppWrite but there is only an unofficial plugin for the integration.
Thus we suggest being careful if using it in a production environment.
The unofficial plugin repo is hosted on Github
The prerequisites for the plugin are UniTask and JSON.NET, information on both can be found further down in this guide.
Firebase
Firebase integration with Unity makes it easy for developers to add these features to their games without sacrificing security. For example, developers can use Firebase Authentication to allow users to sign in to their games with their Google, Facebook, or Apple accounts. They can also use Firebase Realtime Database to store data in real time, such as the player’s score or the current state of the game. There are a couple other cool features included in the Firebase integration, such as using Firebase Cloud Messaging to send push notifications to players, such as notifications about new levels or in-game events.
The three core benefits with using Firebase are the Ease of use
, Scalability
and Security
:
- Ease of use: Firebase is designed to be easy to use, even for developers who are new to cloud services.
- Scalability: Firebase can scale to support even the most demanding games.
- Security: Firebase is a secure platform that uses industry-standard security measures to protect your data.
The repository for the Firebase Unity SDK is located here
Further documentation and information can be found at the Google Firebase Docs for Unity
Firebase Setup
The setup has a couple prerequisites
that you will need to ensure before going deeper into the integration.
-
Unity prerequisities for Firebase.
-
- KBVE recommends 2021.3 LTS or higher.
-
- Make sure that your unity project is Unity 2021.1 LTS or higher, while it does support 2019.1 LTS, in 2024, it will become deprecated.
-
Apple -> Unity prerequisites for Firebase.
-
- KBVE recommends xCode 14.x or higher.
-
- xCode 13.3.1 or higher.
-
- CocoaPods 1.10.x or higher.
-
- iOS target of v11 or higher.
-
- tvOS target of v12 or higher.
-
Android
-
- Android API level 19 or higher.
-
- KBVE Recommends 23 or higher, if you are using cryptography.
Steam
These notes are still a work in progress, but I will try my best to continue to improve them as I am building out the Steam API for the Unity/React Project. Official Repo
Steam Setup
It seems that before you start to integrate SteamWorks / Steam API / SteamWorksNET , you need an active SteamWorks developer account. You can create the account here
Legal Name
Steam Defines it as
This is really, really important to enter correctly. Carefully read all instructions below. You will be unable to release your product via Steam until this name matches all records. The name you enter below must be the legal entity that owns or has rights to publish the game, software or video (“content”) and is the legal entity that will be signing the Steam Distribution Agreement. The legal name you enter here must match the name as written on official documents with your bank and on United States IRS tax documents or foreign tax documents if applicable. You will need to enter this name again as your bank account holder and the legal name associated with a tax payer identification number in the following steps. If you don’t have a company name and you are the sole owner of your content, please fill in your full name as the Legal Name and your own address as Street Address. If you co-own the content with other individuals, you must form a legal entity to own and receive payments for your content. The Legal Name here is for internal use. If you have a DBA or ‘friendly name’ that you wish to show to customers on your store page, you will be able to enter that separately when creating your store page.
This is an extremely important step, we advise that you consult with your legal parties if there are any major issues.
We recommend that, if you are a US Citizen, have all our personal information (Tax, Bank, KYC, ect…) ready before completing the application. Furthermore, there is a $100 fee for the application.
Steam Launch
Well we applied as of 11/23/2022 , so we will wait until everything is confirmed and then move forward with this.
Okay so we been approved, now you should have 1 application credit in your Steamworks profile! This is where you then create your application, using that application credit that you paid $100 for!
Place your application name and then go through the form, it will then spit out some interesting variables:
Requesting AppID For: KBVE.com RogueJester Created package “KBVE.com RogueJester Developer Comp” with ID 802XXX Created package “KBVE.com RogueJester for Beta Testing” with ID 802XXX Created package “KBVE.com RogueJester” with ID 802XXX Added auto-grant to publisher *XXX Created store item ‘518XXX’ Created store package for store item ‘518XXX’
You should keep this information safe and as a reference step.
Plugins
Collection of plugins for Unity game engine. We want to include as many reference points and notes for the plugins that we are currently using.
Vuplex
This is a 3rd party plugin provider for Unity, that extends out the webview components for cross-platform compatibility through their own object-based library.
These are reference points for common errors within the Vuplex libraries / eco-system.
Vuplex Resources
Loading multiple webview components within a single scene can cause a spike within the client’s CPU/RAM, thus it is recommended to de-sync / destroy or de-activate any un-used Canvas. Furthermore, only activate the GameObject when the player is within a set proximity to the object through the Unity’s Collider system via event triggers. Vuplex does run an instance of a chromium browser and that can lead to memeory and cpu leaks.
An example of this would be to declare the GameObject, add collision and then hook it a simple trigger script, like this:
public GameObject webviewObject;
[SerializeField] private bool EnablePlayerWebview;
private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player") && EnablePlayerWebview) { webviewObject.SetActive(true); }
}
private void OnTriggerExit(Collider other)
{
Debug.Log("Exiting");
webviewObject.SetActive(false);
}
Here is our current work in progress Vuplex helper.
using System;
using System.Threading.Tasks;
using UnityEngine;
using Vuplex.WebView;
namespace Utils
{
public class VuplexHelper : MonoBehaviour
{
public string CanvasObjectName = "Canvas";
public string CanvasWebViewPrefabName = "CanvasWebViewPrefab";
public string CanvasWebViewPrefabViewName = "CanvasWebViewPrefabView";
private CanvasWebViewPrefab _canvasWebViewPrefab; // Updated to use CanvasWebViewPrefab
private async void Start()
{
try
{
await InitializeWebView();
}
catch (Exception ex)
{
Debug.LogError($"Vuplex CanvasWebView initialization failed: {ex.Message}");
}
}
/// <summary>
/// Initializes the CanvasWebViewPrefab and sets up communication.
/// </summary>
private async Task InitializeWebView()
{
// Step 1: Find the Canvas GameObject
GameObject canvasObject = GameObject.Find(CanvasObjectName);
if (canvasObject == null)
{
Debug.LogError($"No GameObject found with the name {CanvasObjectName}");
return;
}
Debug.Log($"Found Canvas GameObject: {GetFullPath(canvasObject)}");
// Step 2: Find the CanvasWebViewPrefab under the Canvas GameObject
Transform canvasWebViewPrefabTransform = canvasObject.transform.Find(CanvasWebViewPrefabName);
if (canvasWebViewPrefabTransform == null)
{
Debug.LogError($"No GameObject found with the name {CanvasWebViewPrefabName} under {CanvasObjectName}.");
return;
}
Debug.Log($"Found CanvasWebViewPrefab GameObject: {GetFullPath(canvasWebViewPrefabTransform.gameObject)}");
// Step 3: Find the CanvasWebViewPrefabView under the CanvasWebViewPrefab GameObject
Transform canvasWebViewPrefabViewTransform = canvasWebViewPrefabTransform.Find(CanvasWebViewPrefabViewName);
if (canvasWebViewPrefabViewTransform == null)
{
Debug.LogError($"No GameObject found with the name {CanvasWebViewPrefabViewName} under {CanvasWebViewPrefabName}.");
return;
}
Debug.Log($"Found CanvasWebViewPrefabView GameObject: {GetFullPath(canvasWebViewPrefabViewTransform.gameObject)}");
// Step 4: Try to get the CanvasWebViewPrefab component from CanvasWebViewPrefabView
_canvasWebViewPrefab = canvasWebViewPrefabViewTransform.GetComponent<CanvasWebViewPrefab>();
if (_canvasWebViewPrefab == null)
{
// Step 5: Fallback to get CanvasWebViewPrefab from CanvasWebViewPrefab itself
Debug.LogWarning($"CanvasWebViewPrefab component not found on {CanvasWebViewPrefabViewName}. Trying to find CanvasWebViewPrefab on {CanvasWebViewPrefabName}.");
_canvasWebViewPrefab = canvasWebViewPrefabTransform.GetComponent<CanvasWebViewPrefab>();
if (_canvasWebViewPrefab == null)
{
Debug.LogError("Failed to locate the CanvasWebViewPrefab component after multiple attempts.");
return;
}
}
// Step 6: Wait for the CanvasWebViewPrefab to initialize
await _canvasWebViewPrefab.WaitUntilInitialized();
// Step 7: Subscribe to the MessageEmitted event
_canvasWebViewPrefab.WebView.MessageEmitted += OnMessageReceived;
Debug.Log("Vuplex CanvasWebView successfully initialized and ready to receive messages.");
}
/// <summary>
/// Handles messages received from the WebView.
/// </summary>
private void OnMessageReceived(object sender, EventArgs<string> eventArgs)
{
Debug.Log("JSON received: " + eventArgs.Value);
// Further processing of the received message can be done here.
}
/// <summary>
/// Unsubscribes from the event and performs cleanup if needed.
/// </summary>
private void OnDestroy()
{
if (_canvasWebViewPrefab != null && _canvasWebViewPrefab.WebView != null)
{
_canvasWebViewPrefab.WebView.MessageEmitted -= OnMessageReceived;
}
}
/// <summary>
/// Helper method to get the full path of a GameObject in the hierarchy.
/// </summary>
private string GetFullPath(GameObject gameObject)
{
string path = gameObject.name;
while (gameObject.transform.parent != null)
{
gameObject = gameObject.transform.parent.gameObject;
path = gameObject.name + "/" + path;
}
return path;
}
}
}
Vuplex Errors
- Click and scroll not working : Case 1
There could be multiple reasons why click/scroll might not be functional, depending on the operating system, AR/VR tool kits and the Unity’s input system.
When defusing the situation, we recommend build multiple test cases with all components mapped out and then using Debug.Log
to check through all the variables at play.
We been in situations where a foot of a humanoid object was not tagged as a Player
, thus causing the whole collision engine to be off and not registering the functionality within a scene.
UCC
Ultimate Character Controller was the plugin of choice when doing RSDD aka rapid self-destructive development. Official Documentation Link. It is over 300 pages and covers the controller and its interaction within the unity environment. According to Opsive, their UCC is a professional and kinematic character controller that is designed for flexibility, modularity and performance; we consider it an “AIO” or “All-In-One” library.
UCC URP
Grab the invoice number from the plugin purchase and head over to OPSive Downloads with it. After placing the invoice number into the system, it will give you download integrations for external plugins.
UCC Asset Store
Official Asset Store. Last Release Date: 3.0.3 - Nov 24, 2022
UCC Reference
Opsive Video Collection First Person Character Creation
UCC Character
The core of the UCC, Ultimate Character Controller, would be the Character model and its interactivity within the Scene
, thus these notes are for referencing through the plugin and movement, collision, motion, gravity, abilities and more for the Humanoid
/ Character
.
UCC Inventory
The UCC Inventory
can be broken into modules, that we will refer to as:
- Inventory
- Item
- Action (Item)
- Object (Item)
- Attributes
- Currency
- Crafting
- Input
There are more modules within the system but v3 was released in late November 2022 and we still have to read through the notes/documentation && create test cases for each of the additional modules.
UCCIS Attributes
The Attributes
can be referenced throughout the engine
and are designed to override, inherit or modify
the value of another attribute; Attributes
can be utilized to create variants (Override
, Inherit
or Modify
) of Item Definitions.
The Attributes
can be broken down into three variant types: (As referenced in the documentation)
- Override: Overrides the
parent
attribute value of the given object. - Inherit: Inherits the
parent
attribute value of the given object. - Modify: Uses an expression to compute a value that is dependent on the “parent” attribute or any other attribute in the same collection.
UCCIS References
Video Tutorials
The two part video tutorial goes through a UCC / Inventory integration.
Modular AI
Modular AI helps design the behavior of GameObjects within Unity. The official Modular AI repo
Hey Area Object Spawner
A simple tool that helps procedural generation of objects within an area. The plugin’s official repo for Hey Area Object Spawner
Hierarchy 2
- Hierarchy 2 helps organize the Unity UI.
- Official Asset Store
Javascript
OneJS
- Interpol between Javascript and Unity through JINT
- This plugin is not open source but rather a private engine.
There are three core tasks that we will need for the OneJS
and they handle the typescript, bundling and tailwindcss generation.
Below are the tasks.json
for .vscode
folder:
{
"version": "2.0.0",
"tasks": [
{
"label": "tsc: watch - App/tsconfig.json",
"type": "shell",
"command": "npx",
"args": [
"tsc",
"-p",
"tsconfig.json",
"--watch"
],
"group": "build",
"problemMatcher": [
"$tsc-watch"
],
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/App"
}
},
{
"label": "esbuild: watch",
"type": "shell",
"command": "node",
"args": [
"esbuild.mjs",
"--watch"
],
"group": "build",
"problemMatcher": [],
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/App"
}
},
{
"label": "postcss: watch",
"type": "shell",
"command": "npx",
"args": [
"postcss",
"input.css",
"-o",
"../Assets/tailwind.uss",
"--watch"
],
"group": "build",
"problemMatcher": [],
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/App"
}
},
{
"label": "build: all",
"dependsOn": [
"tsc: watch - App/tsconfig.json",
"esbuild: watch",
"postcss: watch"
],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
If the project is stored in a monorepo, then adjust the cwd
under options
to fix the pathing for the commands.
Under some situations, you might have to add an anti-strip pattern to your link.xml
.
We can update these docs a bit more after the release of Unity 6.
React
- For React and Unity integration, we recommend going to our React application page.
Python
The official notes and changelogs for the python integration inside of unity can be found on their website.
JSON
There are a couple options for JSON plugins, the two main ones that we recommend are the JSON.NET library from Nuget and the SimpleJSON.### SimpleJSON
JSON.NET
Here is a simple guide on how to install the official JSON.NET plugin from NewtonSoft.
SimpleJSON
SimpleJSON is a plugin for JSON parsing in C#.
- Official Repo
Webview
Unity plugins that focus on webview by providing abstract layers that extend to controllers.
UniWebView
- Adding Webview for iOS/Android can be easier through UniWebView, which is an open source web view component for mobile platforms.
- Official Repo
Vuplex Plugin
A commercial plugin that extends WebView components across all platforms, with major focus on AR/VR development kits for Oculus, Hololens and more. Notes on the Vuplex
Corgi
These are KBVE notes and references for the Corgi Engine
that was developed by More Mountains. Please note that the core of the Corgi Engine is a private / premium plugin for the Unity Engine, thus parts of our codebase / references will not work out of the box
, as you will have to install the latest engine from the Unity Asset store.
We are currently test casing the corgi engine as the base for our 2D engine and then going to integrate it with our 2DUnity. As of early December 2022, we are test casing the pipeline with the engine as an underlay and restructuring our 2DUnity
as a gateway layer, a similar setup to our 3DUnity
and UCC
.
Corki Namespace
The Corki
namespace is a KBVE extension of the Corgi
namespace, adding custom gateway layers that make it easier to infer and interpolate among different APIs.
Unity Canvas
The Canvas is a GameObject within Unity that extends the UI elements and utilizes the EventSystem / Scene View.
Unity Assets
- Unity Assets are a collection of media files.
2D Assets
This is a collection of 2D assets that can be a great resource / reference for anyone looking to make a 2D game. We could migrate the 2D assets into their own reference later down the line.
PixelFrog
Official Itch
Treasure Hunters Download Kings and Pings Download Pixel Adventure Download Pirate Bomb Download
2D
These are the notes for Unity’s 2D engine and/or projects related to the 2D development cycle.
2D Examples
The list below are open source projects that use Unity as their base for 2D/Retro style games.
Newbark
Official Repo
Itsjavi created an amazing open source proof-of-concept version of classic Pokemon (Red/Blue/Gold) that has been updated to Unity 2021 and has URP. It should be noted that there assets that might be infringing on intellectual property of Nintendo/Game Freak. On a positive note, upon looking through his repo, I did stumble across a github bot known as ImgBot, which provides image optimization via Git pulls.
The project uses: 2021.1.6f1 as the Unity Version and there seems to not include any pipeline/workflow, which might be because of the copyright issues. The project also has URP / Universal Render Pipeline
I suppose it be interesting to take a look at their combat system, since the biggest issue that I see would be the usage of copyrighted material, but if you were to swap them out, then there might be a case to continue and enhance
the repo? If anyone might be down to do this, please reach out to h0lybyte.
Kailius
Official Repo
This was another open source 2D repo that sparked my interest because it was built for the phone! It is a great reference point for a game written for Android by going through input design
from dual perspective of UX/UI and internal scripting.
Minor 2Ds
SpaceWalk Official Repo FinalProject UnityW2022
Notes
- Unity follows a duel release structure for their engine, a
latest
engine build and aLTS
engine. - We recommend using the
LTS
as it hasLong Term Support
, which the company states for about 2 years, whereas thelatest
does not have any extended support.
Errors
- Common errors that users might face when working with Unity. This error log is meant to help keep track and may save some future developers a lot of time.
Error WebGL-000001FEA50EC410
-
[.WebGL-000001FEA50EC410] GL_INVALID_FRAMEBUFFER_OPERATION: Draw framebuffer is incomplete
- Solution: Turn on post processing on the Main Camera.
Error libil2cpp ERROR: Could not open Il2CppData/
Currently: There might be an issue when directly loading the Git LFS, so we will reference it via Github’s media server. Git Notes can be found here
Error Dirty Branch
This will be a common error that you will see throughout CI/CD
and comes from various issues, it can be from the wrong guid
/ Seralization
or broken ProjectSettings.asset
You can ignore the dirty branch errors by using allowDirtyBuild: true
within the game-ci
, however this may cause problems down the line when the build gets more complex and additional platforms i.e WebGl
, Xbox
, ect…