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
- devUPM
package
The package details/info is in
package.json
manifest file. Please, check Unity package layout docs for deeper understanding of the package structure.
samples
-Unity
sample projects, for dev flow we useunity-of-bugs
Let's outline the needed steps for UPM
package development flow
- open
samples/unity-of-bugs
inUnity
or run in silent mode via CLI -Unity -batchmode -projectPath <YOUR_PATH>/samples/unity-of-bugs -exit
The first run will take some time as
Unity
downloads 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.dll
andUnityEditor.TestRunner.dll
) forsrc/tests
projects from[email protected]
library. After this package is restored, the actual dlls are placed insidesamples/unity-of-bugs/Library/ScriptAssemblies
folder.
- open
src/Sentry.Unity.sln
in your editor of choice
Make sure the projects are restored properly and you have zero errors, otherwise you probably misconfigured
src/Directory.Build.props
or didn't restore submodules properly
- build solution, artifacts (
.dll
s) will be placed insidesrc/package-dev
folder - check
src/package-dev
folder, it should be populated with the outlined contentEditor
-Sentry.Unity.Editor.dll
Runtime
-Sentry.Unity.dll
and all its dependencies likeSentry.dll
,System.Text.Json
and so onTests
Editor
-Sentry.Unity.Editor.Tests.dll
Runtime
-Sentry.Unity.Tests.dll
- open
samples/unity-of-bugs
project inUnity
, thenScenes/BugFarmScene
scene - configure
Sentry Unity (dev)
package- on the tab
Tools
, selectSentry
and insert yourDSN
or Sentry SDK onehttps://[email protected]/5439417
- configure other settings for your needs
- on the tab
- run the project in
Unity
via clickingPlay
- click
ThrowNull
or any other button and check errors inSentry
web 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.props
specific variables and settings (inheritssrc/Directory.Build.props
) for test projectsSentry.Unity.Tests
project forRuntime
Unity testsSentry.Unity.Editor.Tests
project forEditor
Unity 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-bugs
Unity project - open
TestRunner
viaWindows -> General -> Test Runner
- run
PlayMode
orEditMode
tests
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-dev
specific files likepackage.json
,Runtime/*.asmdef
,Editor/*.asmdef
intopackage
. Those files contain package specific information.