Clone the repo git clone https://github.com/getsentry/sentry-unity.git and cd into it
We recommend using Unity Hub. The specific version to download can be found here.
You'll need the following modules to be added in order to use Sentry Unity:
- Android Build Support.
- iOS Build Support.
- Linux Build Support (ILCPP) for Linux.
- Windows Build Support (ILCPP) for Windows.
- Install Java 11
- Using sdkman which manage versions for you.
- Or download the OpenJDK directly.
- Instal Git and ensure is accessible from the path
- Add JAVA_HOME to your environment variables (if not using sdkman):
- Windows:
setx JAVA_HOME "C:\Program Files\Java\jdk-11.0.11"
- Windows:
- Install Android Studio
- Open Android Studio and go to Customize -> All settings...
- Search for "SDK" in the Seachbar
- Select System Settings -> Android SDK
- Swap tab to SDK Tools
- Check "Show Package Details"
- Under Android SDK Build-Tools check "30.0.2"
- Apply
- Add ANDROID_SDK_ROOT to your environment variables
- macOS zsh:
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" - Windows:
setx ANDROID_HOME "C:\Program Files (x86)\Android\android-sdk"for a machine wide install,setx ANDROID_HOME "%localappdata%\Android\Sdk"for a user level install.
- macOS zsh:
On the root of the repository, write:
dotnet build
Several projects are used as submodules - sentry-dotnet, Ben.Demystifier The submodule will be restored as a result of
dotnet build. The Unity editor is also loaded via the build if needed to restore any UPM package required by the project, like testing libraries.
dotnet msbuild /t:"UnityPlayModeTest;UnityEditModeTest" /p:Configuration=Release dotnet msbuild /t:"Build;UnityBuildStandalonePlayerIL2CPP;UnitySmokeTestStandalonePlayerIL2CPP"After this you can open your IDE (i.e: Visual Studio or Rider) and Unity Editor for development.
The UnityPath in src/Directory.Build.targets does a lookup at different locations to find Unity.
This is different per operating system. The repository is configured for Windows and macOS. You can adjust it as needed:
<Project>
<!-- Other properties & groups -->
<PropertyGroup>
<UnityPath Condition="<YOUR_PATH_CONDITION>">YOUR_PATH</UnityPath>
</PropertyGroup>
</Project>There is a configuration in place already. Just make sure it works for you or reconfigure for your needs.
There are two projects involved in sentry-unity development. UPM package (src and package-dev folders) and Unity project (samples/unity-of-bugs folder, BugFarmScene.unity) to test the package in.
Folders involved in this stage src, package-dev, samples where
src- package source codepackage-dev- devUPMpackage
The package details/info is in
package.jsonmanifest file. Please, check Unity package layout docs for deeper understanding of the package structure.
samples-Unitysample projects, for dev flow we useunity-of-bugs
Let's outline the needed steps for UPM package development flow
- open
samples/unity-of-bugsinUnityor run in silent mode via CLI -Unity -batchmode -projectPath <YOUR_PATH>/samples/unity-of-bugs -exit
The first run will take some time as
Unitydownloads and caches a bunch of pre-included packages and resources.
We need to run the project first, so it downloads needed dependencies (namely
UnityEngine.TestRunner.dllandUnityEditor.TestRunner.dll) forsrc/testsprojects fromcom.unity.test-framework@1.1.20library. After this package is restored, the actual dlls are placed insidesamples/unity-of-bugs/Library/ScriptAssembliesfolder.
- open
src/Sentry.Unity.slnin your editor of choice
Make sure the projects are restored properly and you have zero errors, otherwise you probably misconfigured
src/Directory.Build.propsor didn't restore submodules properly
- build solution, artifacts (
.dlls) will be placed insidesrc/package-devfolder - check
src/package-devfolder, it should be populated with the outlined contentEditor-Sentry.Unity.Editor.dllRuntime-Sentry.Unity.dlland all its dependencies likeSentry.dll,System.Text.Jsonand so onTestsEditor-Sentry.Unity.Editor.Tests.dllRuntime-Sentry.Unity.Tests.dll
- open
samples/unity-of-bugsproject inUnity, thenScenes/BugFarmScenescene - configure
Sentry Unity (dev)package- on the tab
Tools, selectSentryand insert yourDSNor Sentry SDK onehttps://94677106febe46b88b9b9ae5efd18a00@o447951.ingest.sentry.io/5439417 - configure other settings for your needs
- on the tab
- run the project in
Unityvia clickingPlay - click
ThrowNullor any other button and check errors inSentryweb UI
The project has PlayMode and EditMode tests. They should be available (after you finished Package stage outlined above) when your open samples/unity-of-bugs project.
The tests project are inside src/test folder where
Directory.Build.propsspecific variables and settings (inheritssrc/Directory.Build.props) for test projectsSentry.Unity.Testsproject forRuntimeUnity testsSentry.Unity.Editor.Testsproject forEditorUnity tests
Build artifacts from the test projects will be placed inside package-dev/Tests/Editor and package-dev/Tests/Runtime folders.
In order to run the tests
- open
samples/unity-of-bugsUnity project - open
TestRunnerviaWindows -> General -> Test Runner - run
PlayModeorEditModetests
In CI, a workflow validates that the content of the package doesn't change accidentally. If you intentially want to add or remove files in the final UPM package. You need to accept the diff:
pwsh ./test/Scripts.Tests/test-pack-contents.ps1 accept
The release is done by pushing the artifact built in CI to a new repo. The artifact is built by using the template files in the package directory. In order to make a release, the contents of package-dev/Editor and package-dev/Runtime folders should be copied into package.
Don't copy
package-devspecific files likepackage.json,Runtime/*.asmdef,Editor/*.asmdefintopackage. Those files contain package specific information.