Using Third Party Packages
Not all third-party packages are immediately compatible with the Spatial Creator Toolkit, but most packages can be adapted for the Creator Toolkit. Some popular third-party Unity packages have been successfully ported to be used with the Spatial Creator Toolkit, including Cinemachine, iTween, LeanTween, and more.
Porting a Package
Here are the general steps to port a third-party package to work with the Spatial Creator Toolkit:
- Packages with precompiled DLLs are not supported.
- All C# code must be in your Creator Toolkit Space’s C# assembly.
- Packages must not use any of the banned APIs by the Spatial C# Scripting Runtime.
- Copy the package’s source into your Creator Toolkit Space’s C# assembly folder.
- If the package has any runtime assemblies of its own (i.e.
.asmdef
), those need to be removed and any missing references must be resolved. Assemblies in anEditor
folder do not need to be removed. - Check for errors or warnings about banned APIs.
- If there are banned APIs in editor-only code, ensure that the code is in a
Editor
folder, or that you use a#if UNITY_EDITOR
directive. - For banned API usage in runtime code, remove the code if possible and replace with alternate APIs. You can find examples of this below in some of the packages that we've ported successfully.
- In practice, we’ve found that many packages can be adapted with a moderate amount of effort. ⚠️ However, some packages cannot be supported if they have a hard dependency on banned APIs.
You can find a list of third-party packages with porting instructions here, including packages such as tweening and car control packages.
Addressables
See Addressables for a guide on how to use Addressables in your project. The Creator Toolkit already includes the Addressables package as a dependency.
Cinemachine
See Controlling the Camera or the Cinemachine Template for a guide on how to use Cinemachine in Spatial Creator Toolkit projects.
iTween
iTween is a simple animation library that can be ported rather easily since it’s one file. The only function used banned function is the CallBack
function, which uses SendMessage
to deliver callbacks for tweens. If you need event callbacks for tweens, you’ll have to implement them differently.
Porting instructions:
- Copy the files (Pixelplacement folder) into your assembly.
- Comment out the references to
Application.OpenURL
andObject.SendMessage
LeanTween
See Spatial-LeanTween for a forked version that works in Spatial Creator Toolkit projects and is used in production games.
DOTween Free
The DOTween license does not allow redistributing a modified version; here are the general instructions for modifying it to work in Spatial Creator Toolkit.
Porting instructions:
- Clone [DOTween] locally.
- From the
_DOTween.Assembly
folder, copy theDOTween
,DOTweenEditor
, andbin/Modules
folders into your project under the folder containing your C# assembly. - Remove
AssemblyInfo.cs
fromDOTween/Properties
andDOTweenEditor/Properties
. You can remove theProperties
folder too. - Remove or comment out all functions beginning with AsyncAwait in
DOTween/Modules/DOTweenModuleUnityVersion.cs
- Remove instances of using Resource.Load (for example, you could do
DOTweenSettings settings = ScriptableObject.CreateInstance<DOTweenSettings>();
) - In
DOTween/DOTween/Core/DOTweenComponent.cs
- for all the lines beginning with
Type modules = DOTweenUtils.GetLooseScriptType("DG.Tweening.DOTweenModuleUtils");
and ending withmi.Invoke(null, null);
- replace with just this one line:
DOTweenModuleUtils.Init();
- for all the lines beginning with
- Remove or comment out
GetLooseScriptType
inDOTweenUtils.cs
- Comment out or remove all uses of
DontDestroyOnLoad
- Command out or remove all helper functions that reference Unity’s camera (in
DOTween/Plugins/Core/SpecialPluginsUtils.cs
) - For every file in the
Editor
folder, add a#if UNITY_EDITOR
directive on the first line of the file, and a#endif
on the last line of the file.- Normally, each
Editor
folder should have its own assembly definition. However, we found that for DOTween specifically this causes reference errors for non-exposed classes. - Sample unix commands to do this (replace
/path/to/DOTweenEditor
with your path to the editor folder)
- Normally, each
Simple Car Controller
See the Simple Car Controller Template for a full example of using a third-party car controller from the Unity Asset store in Spatial.
Dynamic Bone
This package from the Asset Store allows you to use bones / splines. To be able to use it, be sure to change the CheckDistance
function so that it doesn’t use Camera.main
. Instead, you want to use the camera position: