# Integrating visage|SDK into Unity project

visage|SDK allows easy integration with Unity 3D game engine using VisageTrackerUnityPlugin and VisageAnalyserUnityPlugin, wrappers that expose VisageTracker's and VisageFaceAnalyser's functionalities for use in managed programming language such as C#.
In order to use visage|SDK in your own Unity project, libraries and selected data files need to be included. Unity sample application VisageTrackerUnityDemo is provided in visage|SDK as a ready-to-build project with all necessary dependencies and can be used as a reference.
Following steps are required to integrate visage|SDK in your own project:

Pre-build step:

- Following libraries need to be added to the project:
  - VisageTrackerUnityPlugin.jslib (located in www/lib folder)
  - VisageAnalyserUnityPlugin.jslib (located in www/lib folder)
- Following files and folders (located in www/lib) need to be copied to the project's assets:
  - tracker configuration file (e.g. Head Tracker.cfg)
  - neural net configuration file (i.e. NeuralNet.cfg)
- license key file

Post-build step:

- The following files need to be copied to the same folder as the index.html file:
  - visageAnalysisData.data (located in www/lib folder)
  - visageAnalysisData.js (located in www/lib folder)
  - visageSDK.data (located in www/lib folder)
  - visageSDK.wasm (located in www/lib folder)
  - visageSDK.js (located in www/lib folder)

- Modify index.html output file to expose unityInstance to the global variable unityGame:

      <body>
          <script>
          ...
          var unityGame;
          var script = document.createElement("script");
          script.src = loaderUrl;
          script.onload = () => {
            createUnityInstance(canvas, config, (progress) => {
              progressBarFull.style.width = 100 * progress + "%";
            }).then((unityInstance) => {
              loadingBar.style.display = "none";
              unityGame = unityInstance;
              fullscreenButton.onclick = () => {
                unityInstance.SetFullscreen(1);
              };
            }).catch((message) => {
              alert(message);
            });
          };
          document.body.appendChild(script);
          </script>
      </body>