From cc2f4b42c315f0498e84fb1cc968620e4bc677a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Wed, 15 May 2024 16:34:17 +0200 Subject: [PATCH] Initial commit --- .github/CODEOWNERS | 5 + .github/FUNDING.yml | 1 + .github/PULL_REQUEST_TEMPLATE.md | 30 ++++++ .../development-buildandtestupmrelease.yml | 48 +++++++++ .github/workflows/development-publish.yml | 22 +++++ .github/workflows/main-publish.yml | 92 +++++++++++++++++ .gitignore | 79 +++++++++++++++ .npmignore | 3 + ...TEPlatformServiceConfigurationsProfile.txt | 1 + .../UPMTEMPLATEPlatformAssets.txt | 1 + CHANGELOG.md | 3 + .../com.realitytoolkit.upmtemplate.md | 3 + .../RealityToolkit.UPMTEMPLATE.Editor.asmdef | 23 +++++ Editor/UPMTEMPLATEPackageInstaller.cs | 47 +++++++++ Editor/UPMTEMPLATEPackageModulesInstaller.cs | 94 ++++++++++++++++++ Editor/UPMTEMPLATEPathFinder.cs | 18 ++++ InitializeTemplate.ps1 | 68 +++++++++++++ LICENSE.md | 21 ++++ README.md | 36 +++++++ Runtime/RealityToolkit.UPMTEMPLATE.asmdef | 18 ++++ Runtime/UPMTEMPLATEPlatform.cs | 98 +++++++++++++++++++ Tests/Editor/EditorExampleTest.cs | 96 ++++++++++++++++++ ...ityToolkit.UPMTEMPLATE.Editor.Tests.asmdef | 23 +++++ .../RealityToolkit.UPMTEMPLATE.Tests.asmdef | 20 ++++ Tests/Runtime/RuntimeExampleTest.cs | 96 ++++++++++++++++++ Third Party Notices.md | 16 +++ package.json | 36 +++++++ 27 files changed, 998 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/FUNDING.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/development-buildandtestupmrelease.yml create mode 100644 .github/workflows/development-publish.yml create mode 100644 .github/workflows/main-publish.yml create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 Assets~/Profiles/UPMTEMPLATEPlatformServiceConfigurationsProfile.txt create mode 100644 Assets~/StandardAssets/UPMTEMPLATEPlatformAssets.txt create mode 100644 CHANGELOG.md create mode 100644 Documentation~/com.realitytoolkit.upmtemplate.md create mode 100644 Editor/RealityToolkit.UPMTEMPLATE.Editor.asmdef create mode 100644 Editor/UPMTEMPLATEPackageInstaller.cs create mode 100644 Editor/UPMTEMPLATEPackageModulesInstaller.cs create mode 100644 Editor/UPMTEMPLATEPathFinder.cs create mode 100644 InitializeTemplate.ps1 create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 Runtime/RealityToolkit.UPMTEMPLATE.asmdef create mode 100644 Runtime/UPMTEMPLATEPlatform.cs create mode 100644 Tests/Editor/EditorExampleTest.cs create mode 100644 Tests/Editor/RealityToolkit.UPMTEMPLATE.Editor.Tests.asmdef create mode 100644 Tests/Runtime/RealityToolkit.UPMTEMPLATE.Tests.asmdef create mode 100644 Tests/Runtime/RuntimeExampleTest.cs create mode 100644 Third Party Notices.md create mode 100644 package.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..399ae48 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,5 @@ +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @global-owner1 and @global-owner2 will be requested for +# review when someone opens a pull request. +* @FejZa @SimonDarksideJ \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..27c9bd7 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [SimonDarksideJ,FejZa] \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..3dcfc40 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,30 @@ +# Reality Collective - Reality Toolkit Pull Request + +## Overview + + +## Changes + + +- Fixes: + +## Breaking Changes + + +- Breaks + +## Related Submodule Changes + + +- URL + +## Testing status + +* No tests have been added. +* Includes unit tests. +* Includes performance tests. +* Includes integration tests. + +### Manual testing status + + diff --git a/.github/workflows/development-buildandtestupmrelease.yml b/.github/workflows/development-buildandtestupmrelease.yml new file mode 100644 index 0000000..1fef2ab --- /dev/null +++ b/.github/workflows/development-buildandtestupmrelease.yml @@ -0,0 +1,48 @@ +name: Build and test UPM packages for platforms, all branches except main + +on: + pull_request: + branches-ignore: + - 'main' + # Ignore PRs targeting main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + # Check Unity version required by the package + validate-environment: + name: Get Unity Version from UPM package + uses: realitycollective/reusableworkflows/.github/workflows/getunityversionfrompackage.yml@v2 + with: + build-host: ubuntu-latest + + # Check Unity Hub and Editor Environment + Validate-Unity: + name: Validate Unity Install + needs: validate-environment + uses: realitycollective/reusableworkflows/.github/workflows/validateunityinstall.yml@v2 + with: + build-target: windows + unityversion: ${{ needs.validate-environment.outputs.unityversion }} + + # Run Unity unit tests defined in the package + Run-Unit-Tests: + name: Run Unity Unit Tests + needs: Validate-Unity + uses: realitycollective/reusableworkflows/.github/workflows/rununityUPMbuild.yml@v2 + with: + unityversion: ${{ needs.Validate-Unity.outputs.unityeditorversion }} + dependencies: '{"development": "github.com/realitycollective/com.realitycollective.buildtools.git"}' + secrets: inherit + + Build-Complete: + runs-on: ubuntu-latest + name: Build completion task + needs: Run-Unit-Tests + steps: + - run: echo "Build Complete" \ No newline at end of file diff --git a/.github/workflows/development-publish.yml b/.github/workflows/development-publish.yml new file mode 100644 index 0000000..8aae002 --- /dev/null +++ b/.github/workflows/development-publish.yml @@ -0,0 +1,22 @@ +name: Publish development branch on Merge + +on: + push: + branches: + - development + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + release_on_merge: + name: Tag and Publish UPM package + uses: realitycollective/reusableworkflows/.github/workflows/upversionandtagrelease.yml@v2 + with: + build-host: ubuntu-latest + build-type: pre-release + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/main-publish.yml b/.github/workflows/main-publish.yml new file mode 100644 index 0000000..aa1fcac --- /dev/null +++ b/.github/workflows/main-publish.yml @@ -0,0 +1,92 @@ +name: Publish main branch and increment version + +on: + push: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab, last resort if GitHub does not behave + workflow_dispatch: + +jobs: + # Get Version to tag and release the branch, no up-version - [no-ver] included in PR title + validate-environment: + if: contains(github.event.head_commit.message, 'no-ver') + name: Get Version from UPM package + uses: realitycollective/reusableworkflows/.github/workflows/getpackageversionfrompackage.yml@v2 + with: + build-host: ubuntu-latest + + # Perform tagging + release-Package-only: + needs: validate-environment + name: Release package only, no upversion + uses: realitycollective/reusableworkflows/.github/workflows/tagrelease.yml@v2 + with: + build-host: ubuntu-latest + version: ${{ needs.validate-environment.outputs.packageversion }} + secrets: inherit + + # Up version the release and publish major release + upversion-major-Package: + if: contains(github.event.head_commit.message, 'no-ver') == false && contains(github.event.head_commit.message, 'major-release') + name: Major Version package and release + uses: realitycollective/reusableworkflows/.github/workflows/upversionandtagrelease.yml@v2 + with: + build-host: ubuntu-latest + build-type: major + secrets: inherit + + # Up version the release and publish minor release + upversion-minor-Package: + if: contains(github.event.head_commit.message, 'no-ver') == false && contains(github.event.head_commit.message, 'minor-release') + name: Minor Version package and release + uses: realitycollective/reusableworkflows/.github/workflows/upversionandtagrelease.yml@v2 + with: + build-host: ubuntu-latest + build-type: minor + secrets: inherit + + # Up version the release and publish patch release (default) + upversion-patch-Package: + if: contains(github.event.head_commit.message, 'no-ver') == false && contains(github.event.head_commit.message, 'minor-release') == false && contains(github.event.head_commit.message, 'major-release') == false + name: Patch Version package and release + uses: realitycollective/reusableworkflows/.github/workflows/upversionandtagrelease.yml@v2 + with: + build-host: ubuntu-latest + build-type: patch-release + secrets: inherit + + release-Complete: + if: ${{ always() }} + needs: [upversion-major-Package, upversion-minor-Package, upversion-patch-Package, release-Package-only] + name: Release complete + runs-on: ubuntu-latest + steps: + - name: Script Version + run: echo "Release done, updating Development" + + # Refresh the development branch with the main publish + refresh-development: + if: ${{ always() }} + needs: [release-Complete] + name: Refresh development branch + uses: realitycollective/reusableworkflows/.github/workflows/refreshbranch.yml@v2 + with: + build-host: ubuntu-latest + target-branch: development + source-branch: main + secrets: inherit + + # Up version the development branch ready for future development + upversion-development: + if: ${{ always() }} + needs: [refresh-development] + name: UpVersion the development branch for the next release + uses: realitycollective/reusableworkflows/.github/workflows/upversionandtagrelease.yml@v2 + with: + build-host: ubuntu-latest + build-type: patch + target-branch: development + createTag: false + secrets: inherit \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f2e6ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,79 @@ +# =============== # +# Unity generated # +# =============== # +[Tt]emp/ +[Oo]bj/ +[Bb]in/ +[Bb]uilds/ +[Uu]serSettings/ +[Bb]uild/ +[Ll]ibrary/ +[Aa]pp/ +[Aa]pp.meta +UserSettings/ + +.out/ +.gradle/ +project.lock.json +*.package +TextMesh Pro.meta +TextMesh Pro/ +UIElementsSchema/ +*packages-lock.json + +# ============ # +# Certificates # +# ============ # +*.cert +*.privkey +*.pfx +*.pfx.meta + +# ===================================== # +# Visual Studio / MonoDevelop generated # +# ===================================== # +.vs/ +ExportedObj/ +obj/ +*.svd +*.userprefs +/*.csproj +*.csproj +*.pidb +*.suo +/*.sln +*.sln +*.user +*.unityproj +*.ipch +*.opensdf +*.sdf +*.tlog +*.log +*.idb +*.opendb +*.vsconfig + +# ============================ # +# Visual Studio Code Generated # +# ============================ # +.vscode/ + +# ========================= # +# Jetbrains Rider Generated # +# ========================= # +.idea/ +_ReSharper.Caches + +# ===================== # +# System Specific List # +# ===================== # +.DS_Store + +# ===================== # +# Project Specific List # +# ===================== # +artifacts/ +ThirdParty/ +ThirdParty.meta +--Version/ \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..7f1a1c7 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +.github/ +Tests/ +Tests.meta diff --git a/Assets~/Profiles/UPMTEMPLATEPlatformServiceConfigurationsProfile.txt b/Assets~/Profiles/UPMTEMPLATEPlatformServiceConfigurationsProfile.txt new file mode 100644 index 0000000..10b2f57 --- /dev/null +++ b/Assets~/Profiles/UPMTEMPLATEPlatformServiceConfigurationsProfile.txt @@ -0,0 +1 @@ +PlatformServiceConfigurationsProfile goes here \ No newline at end of file diff --git a/Assets~/StandardAssets/UPMTEMPLATEPlatformAssets.txt b/Assets~/StandardAssets/UPMTEMPLATEPlatformAssets.txt new file mode 100644 index 0000000..5459fdb --- /dev/null +++ b/Assets~/StandardAssets/UPMTEMPLATEPlatformAssets.txt @@ -0,0 +1 @@ +Any shared assets go here \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..609efcd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +Please refer to the package's [Releases GitHub Page](https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/releases) for the changelog. \ No newline at end of file diff --git a/Documentation~/com.realitytoolkit.upmtemplate.md b/Documentation~/com.realitytoolkit.upmtemplate.md new file mode 100644 index 0000000..9dabb2a --- /dev/null +++ b/Documentation~/com.realitytoolkit.upmtemplate.md @@ -0,0 +1,3 @@ + + +This file will be opened on `View Documentation` button click in the [Package Manager Window](https://docs.unity3d.com/Manual/upm-ui.html) diff --git a/Editor/RealityToolkit.UPMTEMPLATE.Editor.asmdef b/Editor/RealityToolkit.UPMTEMPLATE.Editor.asmdef new file mode 100644 index 0000000..1be5f42 --- /dev/null +++ b/Editor/RealityToolkit.UPMTEMPLATE.Editor.asmdef @@ -0,0 +1,23 @@ +{ + "name": "RealityToolkit.UPMTEMPLATE.Editor", + "rootNamespace": "RealityToolkit.UPMTEMPLATE.Editor", + "references": [ + "GUID:e67d30660ec243e4836aac191d3f36fb", + "GUID:f3241d040533491e8a1e2714b27c3111", + "GUID:13703f41b24bb904cb2305abe6317e3d", + "GUID:9753fcbb5b1feaf459f435ac95e51baa", + "GUID:b2d046948d6452a4b8485efc9ce0f88c", + "GUID:2a3f0ca4e21332c44bfdce311ea8943e" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Editor/UPMTEMPLATEPackageInstaller.cs b/Editor/UPMTEMPLATEPackageInstaller.cs new file mode 100644 index 0000000..fc5cdc1 --- /dev/null +++ b/Editor/UPMTEMPLATEPackageInstaller.cs @@ -0,0 +1,47 @@ +// Copyright (c) Reality Collective. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using RealityCollective.Editor.Utilities; +using RealityCollective.Extensions; +using RealityCollective.ServiceFramework.Editor; +using RealityCollective.ServiceFramework.Editor.Packages; +using RealityToolkit.Editor; +using System.IO; +using UnityEditor; +using UnityEngine; + +namespace RealityToolkit.UPMTEMPLATE.Editor +{ + [InitializeOnLoad] + internal static class UPMTEMPLATEPackageInstaller + { + private static readonly string destinationPath = Application.dataPath + "/RealityToolkit.Generated/UPMTEMPLATE"; + private static readonly string sourcePath = Path.GetFullPath($"{PathFinderUtility.ResolvePath(typeof(UPMTEMPLATEPackagePathFinder)).ForwardSlashes()}{Path.DirectorySeparatorChar}{"Assets~"}"); + + static UPMTEMPLATEPackageInstaller() + { + EditorApplication.delayCall += CheckPackage; + } + + [MenuItem(RealityToolkitPreferences.Editor_Menu_Keyword + "/Packages/Install UPMTEMPLATE Package Assets...", true)] + private static bool ImportPackageAssetsValidation() + { + return !Directory.Exists($"{destinationPath}{Path.DirectorySeparatorChar}"); + } + + [MenuItem(RealityToolkitPreferences.Editor_Menu_Keyword + "/Packages/Install UPMTEMPLATE Package Assets...")] + private static void ImportPackageAssets() + { + EditorPreferences.Set($"{nameof(UPMTEMPLATEPackageInstaller)}.Assets", false); + EditorApplication.delayCall += CheckPackage; + } + + private static void CheckPackage() + { + if (!EditorPreferences.Get($"{nameof(UPMTEMPLATEPackageInstaller)}.Assets", false)) + { + EditorPreferences.Set($"{nameof(UPMTEMPLATEPackageInstaller)}.Assets", AssetsInstaller.TryInstallAssets(sourcePath, destinationPath)); + } + } + } +} \ No newline at end of file diff --git a/Editor/UPMTEMPLATEPackageModulesInstaller.cs b/Editor/UPMTEMPLATEPackageModulesInstaller.cs new file mode 100644 index 0000000..1be5b0d --- /dev/null +++ b/Editor/UPMTEMPLATEPackageModulesInstaller.cs @@ -0,0 +1,94 @@ +// Copyright (c) Reality Collective. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using RealityCollective.ServiceFramework.Definitions; +using RealityCollective.ServiceFramework.Editor.Packages; +using RealityCollective.ServiceFramework.Services; +using System.Linq; +using UnityEditor; + +namespace RealityToolkit.UPMTEMPLATE.Editor +{ + /// + /// Installs s coming from a third party package + /// into the in the . + /// + [InitializeOnLoad] + public sealed class UPMTEMPLATEPackageModulesInstaller : IPackageModulesInstaller + { + /// + /// Static initializer for the installer instance. + /// + static UPMTEMPLATEPackageModulesInstaller() + { + if (Instance == null) + { + Instance = new UPMTEMPLATEPackageModulesInstaller(); + } + + PackageInstaller.RegisterModulesInstaller(Instance); + } + + /// + /// Internal singleton instance of the installer. + /// + private static UPMTEMPLATEPackageModulesInstaller Instance { get; } + + /// + public bool Install(ServiceConfiguration serviceConfiguration) + { +/* +------------------------------------------------------- +TO install modules for the service, uncomment the code below. + +Note, in order to correctly assign modules for the service, you need to replace the following (Where UPMTEMPLATE is the service name used to generate this repository): + +- UPMTEMPLATE with the correct service type. +- UPMTEMPLATEModule with the correct module type. +- IUPMTEMPLATEModule with the correct module interface. +- UPMTEMPLATEProfile with the correct profile type. + +These are collated from the service and module definitions generated using the Service Template Generator +------------------------------------------------------- + if (!typeof(IUPMTEMPLATEModule).IsAssignableFrom(serviceConfiguration.InstancedType.Type)) + { + // This module installer does not accept the configuration type. + return false; + } + + if (!ServiceManager.IsActiveAndInitialized) + { + UnityEngine.Debug.LogWarning($"Could not install {serviceConfiguration.InstancedType.Type.Name}.{nameof(ServiceManager)} is not initialized."); + return false; + } + + if (!ServiceManager.Instance.HasActiveProfile) + { + UnityEngine.Debug.LogWarning($"Could not install {serviceConfiguration.InstancedType.Type.Name}.{nameof(ServiceManager)} has no active profile."); + return false; + } + + if (!ServiceManager.Instance.TryGetServiceProfile(out var UPMTEMPLATEProfile)) + { + UnityEngine.Debug.LogWarning($"Could not install {serviceConfiguration.InstancedType.Type.Name}.{nameof(UPMTEMPLATEProfile)} not found."); + return false; + } + + // Setup the configuration. + var typedServiceConfiguration = new ServiceConfiguration(serviceConfiguration.InstancedType.Type, serviceConfiguration.Name, serviceConfiguration.Priority, serviceConfiguration.RuntimePlatforms, serviceConfiguration.Profile); + + // Make sure it is not already in the target profile. + if (UPMTEMPLATEProfile.ServiceConfigurations.All(sc => sc.InstancedType.Type != serviceConfiguration.InstancedType.Type)) + { + UPMTEMPLATEProfile.AddConfiguration(typedServiceConfiguration); + UnityEngine.Debug.Log($"Successfully installed the {serviceConfiguration.InstancedType.Type.Name} to {UPMTEMPLATEProfile.name}."); + } + else + { + UnityEngine.Debug.Log($"Skipped installing the {serviceConfiguration.InstancedType.Type.Name} to {UPMTEMPLATEProfile.name}. Already installed."); + } +*/ + return true; + } + } +} \ No newline at end of file diff --git a/Editor/UPMTEMPLATEPathFinder.cs b/Editor/UPMTEMPLATEPathFinder.cs new file mode 100644 index 0000000..7589670 --- /dev/null +++ b/Editor/UPMTEMPLATEPathFinder.cs @@ -0,0 +1,18 @@ +// Copyright (c) Reality Collective. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using RealityCollective.ServiceFramework.Editor; +using UnityEngine; + +namespace RealityToolkit.UPMTEMPLATE.Editor +{ + /// + /// Dummy scriptable object used to find the relative path of the package. + /// + /// + public class UPMTEMPLATEPackagePathFinder : ScriptableObject, IPathFinder + { + /// + public string Location => $"/Editor/{nameof(UPMTEMPLATEPackagePathFinder)}.cs"; + } +} \ No newline at end of file diff --git a/InitializeTemplate.ps1 b/InitializeTemplate.ps1 new file mode 100644 index 0000000..97d5b86 --- /dev/null +++ b/InitializeTemplate.ps1 @@ -0,0 +1,68 @@ +# Reality Toolkit UPM project generator +# +# To use: +# * Use the Template repository to clone a new repository (ensure to select the option to "copy ALL branches") +# * Clone the project locally +# * Run powershell in the cloned folder +# * Run this template initialization script with the suffix of the project being generated +# E.G. +# ./InitialiseTemplate.ps1 WindowsXR +# * Once run, delete the InitializeTemplate script +# * Copy the cloned project into the RealityToolkit.dev project in the packages folder +# * Open Unity to generate the required meta files for the solution +# * Resolve any issues in the Unity project +# * Push the generated project back to the repository +# * Once the build has successfully built, ONLY THEN, deleted the cloned folder and add it as a submodule to the "RealityToolkit.dev" project +# +# This will generate the "RealityToolkit.WindowsXR" UPM package + + + param ( + [Parameter(Mandatory = $true)] + [string[]]$ProjectName + ) + +$templateVar = 'UPMTEMPLATE' +$templateVarGUID = 'UPMTEMPLATEGUID' +$cleanProjectName = $ProjectName.Replace('.','_').Replace('-','_') +$lowerProjectName = $ProjectName.ToLower().Replace('-','_') +$upperProjectName = $ProjectName.Toupper().Replace('-','_').Replace(".","_") +$newProjectGuid = [guid]::NewGuid() + +if ( -not (Test-Path ".\Documentation~\com.realitytoolkit.$templateVar.md")) +{ + echo "Unable to process, no template files / folders found. Has the processor already been run for this project?" + exit 1 +} + +if (Test-Path ".\Documentation\com.realitytoolkit.$ProjectName.md") +{ + echo "Unable to process, files exist for the new template name already" + exit 1 +} + + +Get-ChildItem ".\*.json" -Recurse | ForEach-Object -Process { + (Get-Content $_) -Replace $templateVar, $lowerProjectName | Set-Content $_ +} +Get-ChildItem ".\*.cs" -Recurse | ForEach-Object -Process { + (Get-Content $_) -Replace $templateVarGUID, $newProjectGuid | Set-Content $_ +} +Get-ChildItem ".\*.cs" -Recurse | ForEach-Object -Process { + (Get-Content $_) -Replace "REALITYTOOLKIT_$templateVar", "REALITYTOOLKIT_$upperProjectName" | Set-Content $_ +} +Get-ChildItem ".\*.cs" -Recurse | ForEach-Object -Process { + (Get-Content $_) -Replace $templateVar, $cleanProjectName | Set-Content $_ +} +Get-ChildItem ".\*.md" -Recurse | ForEach-Object -Process { + (Get-Content $_) -Replace $templateVar, $lowerProjectName | Set-Content $_ +} +Get-ChildItem ".\*.asmdef" -Recurse | ForEach-Object -Process { + (Get-Content $_) -Replace $templateVar, $cleanProjectName | Set-Content $_ +} + +#Rename files# +ChildItem .\Documentation~ -Recurse | Where-Object { $_.name -like "*$templateVar*"} | Rename-Item -NewName { $_.name -replace $templateVar, $lowerProjectName} +ChildItem .\ -Recurse | Where-Object { $_.name -like "*$templateVar*"} | Rename-Item -NewName { $_.name -replace $templateVar, $cleanProjectName} + +echo "package name: $ProjectName" \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..32c0aa1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Reality Collective + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b37b14 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Reality Toolkit - UPMTEMPLATE + +![com.realitytoolkit.UPMTEMPLATE](https://github.com/realitycollective/realitycollective.logo/blob/main/RealityToolkit/RepoBanners/com.realitytoolkit.UPMTEMPLATE.png?raw=true) + +The UPMTEMPLATE module for the [Reality Toolkit](https://www.realitytoolkit.io/). + +[![openupm](https://img.shields.io/npm/v/com.realitytoolkit.UPMTEMPLATE?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.realitytoolkit.UPMTEMPLATE/) [![Discord](https://img.shields.io/discord/597064584980987924.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/hF7TtRCFmB) +[![Publish main branch and increment version](https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/actions/workflows/main-publish.yml/badge.svg)](https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/actions/workflows/main-publish.yml) +[![Publish development branch on Merge](https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/actions/workflows/development-publish.yml/badge.svg)](https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/actions/workflows/development-publish.yml) +[![Build and test UPM packages for platforms, all branches except main](https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/actions/workflows/development-buildandtestupmrelease.yml/badge.svg)](https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/actions/workflows/development-buildandtestupmrelease.yml) + +## Installation + +Make sure to always use the same source for all toolkit modules. Avoid using different installation sources within the same project. We provide the following ways to install Reality Toolkit modules: + +### Method 1: Using Package Manager for git users + +1. Open the Package Manager using the Window menu -> Package Manager + +2. Inside the Package Manager, click on the "+" button on the top left and select "Add package from git URL..." + +3. Input the following URL: https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE.git and click "Add". + +### Method 2: OpenUPM + +```text + openupm add com.realitytoolkit.UPMTEMPLATE +``` + +### Method 3: Unity Asset Store + +This option will be available soon. + +## Getting Started + +Check the ["Getting Started"](https://www.realitytoolkit.io/) documentation for the Reality Toolkit and to learn more about this module. \ No newline at end of file diff --git a/Runtime/RealityToolkit.UPMTEMPLATE.asmdef b/Runtime/RealityToolkit.UPMTEMPLATE.asmdef new file mode 100644 index 0000000..d8c08cb --- /dev/null +++ b/Runtime/RealityToolkit.UPMTEMPLATE.asmdef @@ -0,0 +1,18 @@ +{ + "name": "RealityToolkit.UPMTEMPLATE", + "rootNamespace": "RealityToolkit.UPMTEMPLATE", + "references": [ + "GUID:f3241d040533491e8a1e2714b27c3111", + "GUID:13703f41b24bb904cb2305abe6317e3d", + "GUID:b2d046948d6452a4b8485efc9ce0f88c" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Runtime/UPMTEMPLATEPlatform.cs b/Runtime/UPMTEMPLATEPlatform.cs new file mode 100644 index 0000000..2ef085a --- /dev/null +++ b/Runtime/UPMTEMPLATEPlatform.cs @@ -0,0 +1,98 @@ +// Copyright (c) Reality Collective. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using RealityCollective.ServiceFramework.Definitions.Platforms; +using RealityCollective.ServiceFramework.Interfaces; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.XR; + +namespace RealityToolkit.UPMTEMPLATE +{ + /// + /// Used by the toolkit to signal that a feature is available on the UPMTEMPLATE platform. + /// + [System.Runtime.InteropServices.Guid("UPMTEMPLATEGUID")] + public class UPMTEMPLATEPlatform : BasePlatform + { + private const string xrDisplaySubsystemDescriptorId = "UPMTEMPLATE Display"; + private const string xrInputSubsystemDescriptorId = "UPMTEMPLATE Input"; + + /// + public override IPlatform[] PlatformOverrides { get; } = + { + //new AndroidPlatform() + //new WindowsStandalonePlatform() + }; +/* + Choose a path for Is Platform available at runtime + /// + public override bool IsAvailable => + !Application.isEditor && UPMTEMPLATEApi.Version > NoVersion && UPMTEMPLATEApi.Initialized; +*/ + /// + public override bool IsAvailable + { + get + { + var displaySubsystems = new List(); + SubsystemManager.GetSubsystems(displaySubsystems); + var xrDisplaySubsystemDescriptorFound = false; + + for (var i = 0; i < displaySubsystems.Count; i++) + { + var displaySubsystem = displaySubsystems[i]; + if (displaySubsystem.SubsystemDescriptor.id.Equals(xrDisplaySubsystemDescriptorId) && + displaySubsystem.running) + { + xrDisplaySubsystemDescriptorFound = true; + } + } + + // The XR Display Subsystem is not available / running, + // the platform doesn't seem to be available. + if (!xrDisplaySubsystemDescriptorFound) + { + return false; + } + + var inputSubsystems = new List(); + SubsystemManager.GetSubsystems(inputSubsystems); + var xrInputSubsystemDescriptorFound = false; + + for (var i = 0; i < inputSubsystems.Count; i++) + { + var inputSubsystem = inputSubsystems[i]; + if (inputSubsystem.SubsystemDescriptor.id.Equals(xrInputSubsystemDescriptorId) && + inputSubsystem.running) + { + xrInputSubsystemDescriptorFound = true; + } + } + + // The XR Input Subsystem is not available / running, + // the platform doesn't seem to be available. + if (!xrInputSubsystemDescriptorFound) + { + return false; + } + + // Only if both, Display and Input XR Subsystems are available + // and running, the platform is considered available. + return true; + } + } + +#if UNITY_EDITOR + /// + public override UnityEditor.BuildTarget[] ValidBuildTargets { get; } = + { + //Choose which Platforms this runtime is available for in the Editor + //UnityEditor.BuildTarget.Android + //UnityEditor.BuildTarget.WSAPlayer + //UnityEditor.BuildTarget.StandaloneWindows64, + //UnityEditor.BuildTarget.StandaloneWindows + }; +#endif + } +} \ No newline at end of file diff --git a/Tests/Editor/EditorExampleTest.cs b/Tests/Editor/EditorExampleTest.cs new file mode 100644 index 0000000..e9d5423 --- /dev/null +++ b/Tests/Editor/EditorExampleTest.cs @@ -0,0 +1,96 @@ +// ----------------------------------------------------------------------------- +// Package Editor Tests. +// Test Framework +// https://docs.unity3d.com/Manual/com.unity.test-framework.html +// +// For embedded packages you don’t need to explicitly enable tests because embedded packages are in development. +// However, for other types of dependencies, you need to add the `testables` attribute to the Project `manifest.json` +// ----------------------------------------------------------------------------- + +using UnityEngine.TestTools; +using NUnit.Framework; +using System.Collections; +using UnityEngine; + +namespace RealityToolkit.UPMTEMPLATE.Editor.Tests +{ + class EditorExampleTest + { + [SetUp] + public void Setup() + { + // Called before each test method is called. + } + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // Called once prior to executing any of the tests in a fixture + } + + [UnitySetUp] + public IEnumerator UnitySetUp() + { + // Identical to the standard SetUp. + yield return null; + } + + [TearDown] + public void TearDown() + { + // Called after each test method. + } + + [OneTimeTearDown] + public void OneTimeTearDown() + { + // Called once after executing any of the tests in a fixture. + } + + [UnityTearDown] + public IEnumerator UnityTearDown() + { + // Identical to the standard TearDown. + yield return null; + } + + [Test] + public void SimpleTest() + { + // Simple Test + Assert.That(1, Is.EqualTo(1)); + } + + [Test] + [UnityPlatform(RuntimePlatform.WindowsPlayer, RuntimePlatform.Android)] + public void TestMethod() + { + // Run test only for defined platforms + Assert.AreEqual(Application.platform, RuntimePlatform.WindowsPlayer); + } + + [Test] + [TestCase("Alex", 101)] + [TestCase("Pavel", 777)] + [TestCase("Stan", 707)] + public void TestMethod(string name, int id) + { + // TestCase sample. + } + + [Test, Ignore("Described the reason why ignored")] + public void IgnoredTest() + { + // Ignore test example. + } + + [UnityTest] + public IEnumerator EditorSampleTestWithEnumeratorPasses() + { + // A UnityTest behaves like a coroutine in PlayMode + // and allows you to yield null to skip a frame in EditMode + yield return null; + Assert.That(1, Is.EqualTo(1)); + } + } +} diff --git a/Tests/Editor/RealityToolkit.UPMTEMPLATE.Editor.Tests.asmdef b/Tests/Editor/RealityToolkit.UPMTEMPLATE.Editor.Tests.asmdef new file mode 100644 index 0000000..948aaf4 --- /dev/null +++ b/Tests/Editor/RealityToolkit.UPMTEMPLATE.Editor.Tests.asmdef @@ -0,0 +1,23 @@ +{ + "name": "RealityToolkit.UPMTEMPLATE.Editor.Tests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner", + "RealityToolkit.UPMTEMPLATE" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Tests/Runtime/RealityToolkit.UPMTEMPLATE.Tests.asmdef b/Tests/Runtime/RealityToolkit.UPMTEMPLATE.Tests.asmdef new file mode 100644 index 0000000..faf9fee --- /dev/null +++ b/Tests/Runtime/RealityToolkit.UPMTEMPLATE.Tests.asmdef @@ -0,0 +1,20 @@ +{ + "name": "RealityToolkit.UPMTEMPLATE.Tests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Tests/Runtime/RuntimeExampleTest.cs b/Tests/Runtime/RuntimeExampleTest.cs new file mode 100644 index 0000000..275f5fe --- /dev/null +++ b/Tests/Runtime/RuntimeExampleTest.cs @@ -0,0 +1,96 @@ +// ----------------------------------------------------------------------------- +// Package Runtime Tests. +// Test Framework +// https://docs.unity3d.com/Manual/com.unity.test-framework.html +// +// For embedded packages you don’t need to explicitly enable tests because embedded packages are in development. +// However, for other types of dependencies, you need to add the `testables` attribute to the Project `manifest.json` +// ----------------------------------------------------------------------------- + +using UnityEngine.TestTools; +using NUnit.Framework; +using System.Collections; +using UnityEngine; + +namespace RealityToolkit.UPMTEMPLATE.Tests +{ + class RuntimeExampleTest + { + [SetUp] + public void Setup() + { + // Called before each test method is called. + } + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // Called once prior to executing any of the tests in a fixture + } + + [UnitySetUp] + public IEnumerator UnitySetUp() + { + // Identical to the standard SetUp. + yield return null; + } + + [TearDown] + public void TearDown() + { + // Called after each test method. + } + + [OneTimeTearDown] + public void OneTimeTearDown() + { + // Called once after executing any of the tests in a fixture. + } + + [UnityTearDown] + public IEnumerator UnityTearDown() + { + // Identical to the standard TearDown. + yield return null; + } + + [Test] + public void SimpleTest() + { + // Simple Test + Assert.That(1, Is.EqualTo(1)); + } + + [Test] + [UnityPlatform(RuntimePlatform.WindowsPlayer, RuntimePlatform.Android)] + public void TestMethod() + { + // Run test only for defined platforms + Assert.AreEqual(Application.platform, RuntimePlatform.WindowsPlayer); + } + + [Test] + [TestCase("Alex", 101)] + [TestCase("Pavel", 777)] + [TestCase("Stan", 707)] + public void TestMethod(string name, int id) + { + // TestCase sample. + } + + [Test, Ignore("Described the reason why ignored")] + public void IgnoredTest() + { + // Ignore test example. + } + + [UnityTest] + public IEnumerator EditorSampleTestWithEnumeratorPasses() + { + // A UnityTest behaves like a coroutine in PlayMode + // and allows you to yield null to skip a frame in EditMode + yield return null; + Assert.That(1, Is.EqualTo(1)); + } + } +} diff --git a/Third Party Notices.md b/Third Party Notices.md new file mode 100644 index 0000000..b1245bd --- /dev/null +++ b/Third Party Notices.md @@ -0,0 +1,16 @@ + + +This package contains third-party software components governed by the license(s) indicated below: + +Component Name: Semver + +License Type: "MIT" + +[SemVer License](https://github.com/myusername/semver/blob/master/License.txt) + + +Component Name: MyComponent + +License Type: "MyLicense" + +[MyComponent License](https://www.mycompany.com/licenses/License.txt) diff --git a/package.json b/package.json new file mode 100644 index 0000000..2bf809f --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "com.realitytoolkit.UPMTEMPLATE", + "displayName": "RealityToolkit.UPMTEMPLATE", + "description": "The UPMTEMPLATE framework of the Reality Toolkit by the Reality Collective", + "keywords": [ + "VR", + "AR", + "XR", + "Mixed Reality" + ], + "version": "1.0.0-pre.0", + "unity": "2021.3", + "homepage": "https://github.com/realitycollective", + "bugs": { + "url": "https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE/issues" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/realitycollective/com.realitytoolkit.UPMTEMPLATE" + }, + "author": { + "name": "Reality Collective", + "email": "realitycollectivedev@gmail.com", + "url": "https://github.com/realitycollective" + }, + "dependencies": { + "com.realitytoolkit.core": "1.0.0-pre.37" + }, + "assets": [ + { + "displayName": "Default Assets", + "path": "Assets~/" + } + ] +}