This commit is contained in:
Sean Stolberg 2020-05-09 18:44:16 -07:00
Родитель 2ba3a04441
Коммит cf394b081d
30 изменённых файлов: 2383 добавлений и 1 удалений

32
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,32 @@
!.Documentation
!Documentation~
**/.vs
**/.vscode/
**/Library/
**/Logs/
**/obj/
**/Temp/
*.app
*.csproj
*.idea
*.rsp
*.sln
*.suo
*.swp
*.user
*.userprefs
*.VC.*
*~
.build_script/**
.DS_Store
.idea/
.npmrc
.vs/
artifacts/**
build.bat.meta
build.sh.meta
build/*
build/**
node_modules/**
npm-debug.log

0
.gitmodules поставляемый Normal file
Просмотреть файл

19
.npmignore Normal file
Просмотреть файл

@ -0,0 +1,19 @@
artifacts/**
build/**
.build_script/**
node_modules/**
Documentation/ApiDocs/**
Documentation~/ApiDocs/**
.DS_Store
.npmrc
.npmignore
.gitignore
CONTRIBUTING.md
CONTRIBUTING.md.meta
QAReport.md
QAReport.md.meta
.gitlab-ci.yml
build.sh
build.sh.meta
build.bat
build.bat.meta

76
.yamato/promotion.yml Normal file
Просмотреть файл

@ -0,0 +1,76 @@
test_editors:
- version: 2019.1
test_platforms:
- name: win
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
---
{% for editor in test_editors %}
{% for platform in test_platforms %}
promotion_test_{{ platform.name }}_{{ editor.version }}:
name : Promotion Test {{ editor.version }} on {{ platform.name }}
agent:
type: {{ platform.type }}
image: {{ platform.image }}
flavor: {{ platform.flavor}}
variables:
UPMCI_PROMOTION: 1
commands:
- npm install upm-ci-utils@latest -g --registry https://api.bintray.com/npm/unity/unity-npm
- upm-ci package test --unity-version {{ editor.version }}
artifacts:
logs:
paths:
- "upm-ci~/test-results/**/*"
dependencies:
- .yamato/upm-ci.yml#pack
{% endfor %}
{% endfor %}
promotion_test_trigger:
name: Promotion Tests Trigger
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
artifacts:
logs:
paths:
- "upm-ci~/test-results/**/*"
packages:
paths:
- "upm-ci~/packages/**/*"
dependencies:
{% for editor in test_editors %}
{% for platform in test_platforms %}
- .yamato/promotion.yml#promotion_test_{{platform.name}}_{{editor.version}}
{% endfor %}
{% endfor %}
promote:
name: Promote to Production
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
variables:
UPMCI_PROMOTION: 1
commands:
- npm install upm-ci-utils@latest -g --registry https://api.bintray.com/npm/unity/unity-npm
- upm-ci package promote
triggers:
tags:
only:
- /^(r|R)elease-\d+\.\d+\.\d+(-preview(\.\d+)?)?$/
artifacts:
artifacts:
paths:
- "upm-ci~/packages/*.tgz"
dependencies:
- .yamato/upm-ci.yml#pack
{% for editor in test_editors %}
{% for platform in test_platforms %}
- .yamato/promotion.yml#promotion_test_{{ platform.name }}_{{ editor.version }}
{% endfor %}
{% endfor %}

98
.yamato/upm-ci.yml Normal file
Просмотреть файл

@ -0,0 +1,98 @@
test_editors:
- version: 2019.1
- version: trunk
test_platforms:
- name: win
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
- name: mac
type: Unity::VM::osx
image: buildfarm/mac:stable
flavor: m1.mac
---
pack:
name: Pack
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
commands:
- npm install upm-ci-utils@stable -g --registry https://api.bintray.com/npm/unity/unity-npm
- upm-ci package pack
artifacts:
packages:
paths:
- "upm-ci~/**/*"
{% for editor in test_editors %}
{% for platform in test_platforms %}
test_{{ platform.name }}_{{ editor.version }}:
name : Test {{ editor.version }} on {{ platform.name }}
agent:
type: {{ platform.type }}
image: {{ platform.image }}
flavor: {{ platform.flavor}}
commands:
- npm install upm-ci-utils@stable -g --registry https://api.bintray.com/npm/unity/unity-npm
- upm-ci package test --unity-version {{ editor.version }}
artifacts:
logs:
paths:
- "upm-ci~/test-results/**/*"
dependencies:
- .yamato/upm-ci.yml#pack
{% endfor %}
{% endfor %}
test_trigger:
name: Tests Trigger
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
commands:
- dir
triggers:
branches:
only:
- "/.*/"
artifacts:
logs:
paths:
- "upm-ci~/test-results/**/*"
packages:
paths:
- "upm-ci~/packages/**/*"
dependencies:
- .yamato/upm-ci.yml#pack
{% for editor in test_editors %}
{% for platform in test_platforms %}
- .yamato/upm-ci.yml#test_{{platform.name}}_{{editor.version}}
{% endfor %}
{% endfor %}
publish:
name: Publish to Internal Registry
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
commands:
- npm install upm-ci-utils@stable -g --registry https://api.bintray.com/npm/unity/unity-npm
- upm-ci package publish
triggers:
tags:
only:
- /^(r|R)(c|C)-\d+\.\d+\.\d+(-preview(\.\d+)?)?$/
artifacts:
artifacts:
paths:
- "upm-ci~/packages/*.tgz"
dependencies:
- .yamato/upm-ci.yml#pack
{% for editor in test_editors %}
{% for platform in test_platforms %}
- .yamato/upm-ci.yml#test_{{ platform.name }}_{{ editor.version }}
{% endfor %}
{% endfor %}

10
CHANGELOG.md Normal file
Просмотреть файл

@ -0,0 +1,10 @@
# Changelog
All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [0.1.0] - 2019-06-18
### This is the first release of *Unity Package \com.unity.cli-config-manager*.

7
CHANGELOG.md.meta Normal file
Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c40c27602d86e06479ad33f303af8cae
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
CONTRIBUTING Normal file
Просмотреть файл

@ -0,0 +1,8 @@
# PR review process
- Any PR must have an entry in the corresponding changelog in a separate commit (CHANGELOG.MD file)
- Changelog follow these guidelines: https://github.com/Unity-Technologies/PostProcessing/blob/v2/CHANGELOG.md
- Each release branch (2018.1, 2018.2...) have a unique Changelog file
- when backporting, don't backport the changelog commit but update the branch changelog manually
- (optional) add reviewver from doc team
- Any more complex description of a change with future need to go in a release note file

7
CONTRIBUTING.meta Normal file
Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6ece49ca4446a774aadf283ac8662948
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

9
CONTRIBUTIONS.md Normal file
Просмотреть файл

@ -0,0 +1,9 @@
# Contributions
## If you are interested in contributing, here are some ground rules:
* Talk to us before doing the work -- we love contributions, but we might already be working on the same thing, or we might have different opinions on how it should be implemented.
## All contributions are subject to the [Unity Contribution Agreement(UCA)](https://unity3d.com/legal/licenses/Unity_Contribution_Agreement)
By making a pull request, you are confirming agreement to the terms and conditions of the UCA, including that your Contributions are your original creation and that you have complete right and authority to make your Contributions.
## Once you have a change ready following these ground rules. Simply make a pull request in Github

7
CONTRIBUTIONS.md.meta Normal file
Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a688a57ce4f57274ca0c41b40d884dbc
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Editor.meta Normal file
Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: df99bd7f40d74334193ecb56f9a4cdcd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

241
Editor/CliConfigManager.cs Normal file
Просмотреть файл

@ -0,0 +1,241 @@
using NDesk.Options;
using System;
#if UNITY_EDITOR
using UnityEditor;
#if OCULUS_SDK
using Unity.XR.Oculus;
#endif
#endif
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.Rendering;
namespace com.unity.cliconfigmanager
{
public class CliConfigManager
{
private readonly Regex customArgRegex = new Regex("-([^=]*)=", RegexOptions.Compiled);
private readonly PlatformSettings platformSettings = new PlatformSettings();
public void ConfigureFromCmdlineArgs()
{
#if UNITY_EDITOR
ParseCommandLineArgs();
ConfigureSettings();
#endif
}
#if UNITY_EDITOR
private void ParseCommandLineArgs()
{
var args = Environment.GetCommandLineArgs();
EnsureOptionsLowerCased(args);
var optionSet = DefineOptionSet();
var unParsedArgs = optionSet.Parse(args);
platformSettings.SerializeToAsset();
}
private void EnsureOptionsLowerCased(string[] args)
{
for (var i = 0; i < args.Length; i++)
{
if (customArgRegex.IsMatch(args[i]))
{
args[i] = customArgRegex.Replace(args[i], customArgRegex.Matches(args[i])[0].ToString().ToLower());
}
}
}
private void ConfigureSettings()
{
// Setup all-inclusive player settings
ConfigureCrossplatformSettings();
// If Android, setup Android player settings
if (platformSettings.BuildTarget == BuildTarget.Android)
{
ConfigureAndroidSettings();
}
// If iOS, setup iOS player settings
if (platformSettings.BuildTarget == BuildTarget.iOS)
{
ConfigureIosSettings();
}
if (!string.IsNullOrEmpty(platformSettings.XrTarget))
{
var xrConfigurator = new XrConfigurator(platformSettings);
xrConfigurator.ConfigureXr();
}
}
private void ConfigureIosSettings()
{
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, string.Format("com.unity3d.{0}", PlayerSettings.productName));
PlayerSettings.iOS.appleDeveloperTeamID = platformSettings.AppleDeveloperTeamId;
PlayerSettings.iOS.appleEnableAutomaticSigning = false;
PlayerSettings.iOS.iOSManualProvisioningProfileID = platformSettings.IOsProvisioningProfileId;
PlayerSettings.iOS.iOSManualProvisioningProfileType = ProvisioningProfileType.Development;
}
private void ConfigureCrossplatformSettings()
{
PlayerSettings.virtualRealitySupported = false;
if (platformSettings.PlayerGraphicsApi != GraphicsDeviceType.Null)
{
PlayerSettings.SetUseDefaultGraphicsAPIs(platformSettings.BuildTarget, false);
PlayerSettings.SetGraphicsAPIs(platformSettings.BuildTarget, new[] {platformSettings.PlayerGraphicsApi});
}
PlayerSettings.colorSpace = platformSettings.ColorSpace;
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup,
platformSettings.ScriptingImplementation);
}
private void ConfigureAndroidSettings()
{
EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
PlayerSettings.Android.minSdkVersion = platformSettings.MinimumAndroidSdkVersion;
PlayerSettings.Android.targetSdkVersion = platformSettings.TargetAndroidSdkVersion;
// If the user has specified AndroidArchitecture.ARMv7, but not specified ScriptingImplementation.Mono2x, or has incorrectly specified ScriptingImplementation.IL2CPP (not supported
// with mono), then set to AndroidArchitecture.ARMv7 so we're in a compatible configuration state.
if (platformSettings.AndroidTargetArchitecture == AndroidArchitecture.ARMv7 &&
platformSettings.ScriptingImplementation != ScriptingImplementation.Mono2x)
{
platformSettings.ScriptingImplementation = ScriptingImplementation.Mono2x;
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup,
platformSettings.ScriptingImplementation);
}
// If the user has specified mono scripting backend, but not specified AndroidArchitecture.ARMv7, or has incorrectly specified AndroidArchitecture.ARM64 (not supported
// with mono), then set to AndroidArchitecture.ARMv7 so we're in a compatible configuration state.
if (platformSettings.ScriptingImplementation == ScriptingImplementation.Mono2x &&
platformSettings.AndroidTargetArchitecture != AndroidArchitecture.ARMv7)
{
platformSettings.AndroidTargetArchitecture = AndroidArchitecture.ARMv7;
}
PlayerSettings.Android.targetArchitectures = platformSettings.AndroidTargetArchitecture;
}
private OptionSet DefineOptionSet()
{
var optionsSet = new OptionSet();
optionsSet.Add("scriptingbackend=",
"Scripting backend to use. IL2CPP is default. Values: IL2CPP, Mono", ParseScriptingBackend);
optionsSet.Add("simulationmode=",
"Enable Simulation modes for Windows MR in Editor. Values: \r\n\"HoloLens\"\r\n\"WindowsMR\"\r\n\"Remoting\"",
simMode => platformSettings.SimulationMode = simMode);
optionsSet.Add("enabledxrtarget|enabledxrtargets=",
"XR target to enable in player settings. Values: " +
"\r\n\"Oculus\"\r\n\"OpenVR\"\r\n\"cardboard\"\r\n\"daydream\"\r\n\"MockHMD\"\r\n\"OculusXRSDK\"\r\n\"MagicLeapXRSDK\"\r\n\"WindowsMRXRSDK\"",
xrTarget => platformSettings.XrTarget = xrTarget);
optionsSet.Add("playergraphicsapi=", "Graphics API based on GraphicsDeviceType.",
graphicsDeviceType =>
platformSettings.PlayerGraphicsApi = TryParse<GraphicsDeviceType>(graphicsDeviceType));
optionsSet.Add("colorspace=", "Linear or Gamma color space.",
colorSpace => platformSettings.ColorSpace = TryParse<ColorSpace>(colorSpace));
#if OCULUS_SDK
optionsSet.Add("stereorenderingpath=", "Stereo rendering path to enable. SinglePass is default", TryParseOculusXrSdkSrm);
#else
optionsSet.Add("stereorenderingpath=", "Stereo rendering path to enable. SinglePass is default", TryParseLegacyVrSrm);
#endif
optionsSet.Add("mtRendering",
"Enable or disable multithreaded rendering. Enabled is default. Use option to enable, or use option and append '-' to disable.",
option => platformSettings.MtRendering = option != null);
optionsSet.Add("graphicsJobs",
"Enable graphics jobs rendering. Disabled is default. Use option to enable, or use option and append '-' to disable.",
option => platformSettings.GraphicsJobs = option != null);
optionsSet.Add("minimumandroidsdkversion=", "Minimum Android SDK Version to use.",
minAndroidSdkVersion => platformSettings.MinimumAndroidSdkVersion =
TryParse<AndroidSdkVersions>(minAndroidSdkVersion));
optionsSet.Add("targetandroidsdkversion=", "Target Android SDK Version to use.",
trgtAndroidSdkVersion => platformSettings.TargetAndroidSdkVersion =
TryParse<AndroidSdkVersions>(trgtAndroidSdkVersion));
optionsSet.Add("appledeveloperteamid=",
"Apple Developer Team ID. Use for deployment and running tests on iOS device.",
appleTeamId => platformSettings.AppleDeveloperTeamId = appleTeamId);
optionsSet.Add("iosprovisioningprofileid=",
"iOS Provisioning Profile ID. Use for deployment and running tests on iOS device.",
id => platformSettings.IOsProvisioningProfileId = id);
optionsSet.Add("xrsdkrev=",
"revision id of the xrsdk being used.",
id => platformSettings.XrsdkRevision = id);
optionsSet.Add("xrsdkrevdate=",
"revision date of the xrsdk being used.",
revDate => platformSettings.XrsdkRevisionDate = revDate);
optionsSet.Add("xrsdkbranch=",
"branch of the xrsdk being used.",
xrsdkbranch => platformSettings.XrsdkBranch = xrsdkbranch);
optionsSet.Add("deviceruntimeversion=",
"runtime version of the device we're running on.",
deviceruntime => platformSettings.DeviceRuntimeVersion = string.Format("deviceruntimeversion|{0}",deviceruntime));
optionsSet.Add("ffrlevel=",
"ffr level we're running at",
ffrlevel => platformSettings.FfrLevel = string.Format("ffrlevel|{0}", ffrlevel));
optionsSet.Add("testsrev=",
"revision id of the tests being used.",
id => platformSettings.TestsRevision = string.Format("testsrev|{0}", id));
optionsSet.Add("testsrevdate=",
"revision date of the tests being used.",
revDate => platformSettings.TestsRevisionDate = string.Format("testsrevdate|{0}", revDate));
optionsSet.Add("testsbranch=",
"branch of the tests repo being used.",
testsbranch => platformSettings.TestsBranch = string.Format("testsbranch|{0}", testsbranch));
optionsSet.Add("androidtargetarchitecture=",
"Android Target Architecture to use.",
androidtargetarchitecture => platformSettings.AndroidTargetArchitecture = TryParse<AndroidArchitecture>(androidtargetarchitecture));
return optionsSet;
}
public static T TryParse<T>(string stringToParse)
{
T thisType;
try
{
thisType = (T) Enum.Parse(typeof(T), stringToParse);
}
catch (Exception e)
{
throw new ArgumentException(($"Couldn't cast {stringToParse} to {typeof(T)}"), e);
}
return thisType;
}
#if OCULUS_SDK
private void TryParseOculusXrSdkSrm(string srm)
{
if (platformSettings.BuildTarget == BuildTarget.Android)
{
platformSettings.StereoRenderingModeAndroid = TryParse<OculusSettings.StereoRenderingModeAndroid>(srm);
}
else
{
platformSettings.StereoRenderingModeDesktop = TryParse<OculusSettings.StereoRenderingModeDesktop>(srm);
}
}
#else
private void TryParseLegacyVrSrm(string srm)
{
platformSettings.StereoRenderingPath = TryParse<StereoRenderingPath>(srm);
}
#endif
private void ParseScriptingBackend(string scriptingBackend)
{
var sb = scriptingBackend.ToLower();
if (sb.Equals("mono"))
{
platformSettings.ScriptingImplementation = ScriptingImplementation.Mono2x;
}
}
#endif
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7ffc29c2e7e96342b962d230d5980f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1173
Editor/Options.cs Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

11
Editor/Options.cs.meta Normal file
Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8cb9471cc7f53a4bac720225cbdb34c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

319
Editor/PlatformSettings.cs Normal file
Просмотреть файл

@ -0,0 +1,319 @@
#if OCULUS_SDK
using Unity.XR.Oculus;
#endif
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using com.unity.xr.test.runtimesettings;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.PackageManager;
#if URP
using UnityEngine.Rendering.Universal;
#endif
#endif
using UnityEngine;
using UnityEngine.Rendering;
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
#if ENABLE_VR
using UnityEngine.XR;
#endif
namespace com.unity.cliconfigmanager
{
public class PlatformSettings
{
#if UNITY_EDITOR
public BuildTargetGroup BuildTargetGroup => EditorUserBuildSettings.selectedBuildTargetGroup;
public BuildTarget BuildTarget => EditorUserBuildSettings.activeBuildTarget;
public string XrTarget;
public GraphicsDeviceType PlayerGraphicsApi;
#if OCULUS_SDK
public OculusSettings.StereoRenderingModeDesktop StereoRenderingModeDesktop;
public OculusSettings.StereoRenderingModeAndroid StereoRenderingModeAndroid;
#else
public StereoRenderingPath StereoRenderingPath;
#endif
public bool MtRendering = true;
public bool GraphicsJobs;
public AndroidSdkVersions MinimumAndroidSdkVersion = AndroidSdkVersions.AndroidApiLevel24;
public AndroidSdkVersions TargetAndroidSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
public ScriptingImplementation ScriptingImplementation = ScriptingImplementation.IL2CPP;
public string AppleDeveloperTeamId;
public string IOsProvisioningProfileId;
public ColorSpace ColorSpace = ColorSpace.Gamma;
public string XrsdkRevision;
public string XrsdkRevisionDate;
public string XrsdkBranch;
public string TestsRevision;
public string TestsRevisionDate;
public string TestsBranch;
public string DeviceRuntimeVersion;
public string SimulationMode;
public string Username;
public string RenderPipeline;
public string FfrLevel;
public AndroidArchitecture AndroidTargetArchitecture = AndroidArchitecture.ARM64;
private readonly string resourceDir = "Assets/Resources";
private readonly string xrManagementPackageName = "com.unity.xr.management";
private readonly string perfTestsPackageName = "xr.sdk.oculus.performancetests";
private readonly string urpPackageName = "com.unity.render-pipelines.universal";
private readonly string oculusXrSdkPackageName = "com.unity.xr.oculus";
private readonly string hdrpPackageName = "com.unity.testing.hdrp";
private readonly Regex revisionValueRegex = new Regex("\"revision\": \"([a-f0-9]*)\"",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
private readonly Regex majorMinorVersionValueRegex = new Regex("([0-9]*\\.[0-9]*\\.)",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
public void SerializeToAsset()
{
var settingsAsset = ScriptableObject.CreateInstance<CurrentSettings>();
settingsAsset.SimulationMode = SimulationMode;
settingsAsset.PlayerGraphicsApi = PlayerGraphicsApi.ToString();
settingsAsset.MtRendering = MtRendering;
settingsAsset.GraphicsJobs = GraphicsJobs;
settingsAsset.ColorSpace = ColorSpace.ToString();
settingsAsset.EnabledXrTarget = XrTarget;
settingsAsset.XrsdkRevision = GetOculusXrSdkPackageVersionInfo();
settingsAsset.XrManagementRevision = GetXrManagementPackageVersionInfo();
settingsAsset.UrpPackageVersionInfo = GetUrpPackageVersionInfo();
settingsAsset.HdrpPackageVersionInfo = GetHdrpPackageVersionInfo();
settingsAsset.PerfTestsPackageRevision = GetPerfTestsPackageVersionInfo();
settingsAsset.DeviceRuntimeVersion = DeviceRuntimeVersion;
settingsAsset.Username = Username = Environment.UserName;
settingsAsset.FfrLevel = FfrLevel;
settingsAsset.TestsRevision = TestsRevision;
settingsAsset.TestsRevisionDate = TestsRevisionDate;
settingsAsset.TestsBranch = TestsBranch;
settingsAsset.AndroidTargetArchitecture = string.Format("AndroidTargetArchitecture|{0}", AndroidTargetArchitecture.ToString());
settingsAsset.RenderPipeline = RenderPipeline =
$"renderpipeline|{(GraphicsSettings.renderPipelineAsset != null ? GraphicsSettings.renderPipelineAsset.name : "BuiltInRenderer")}";
#if URP
settingsAsset.AntiAliasing = GraphicsSettings.renderPipelineAsset != null
? ((UniversalRenderPipelineAsset) GraphicsSettings.renderPipelineAsset).msaaSampleCount
: QualitySettings.antiAliasing;
#else
settingsAsset.AntiAliasing = QualitySettings.antiAliasing;
#endif
#if OCULUS_SDK
settingsAsset.StereoRenderingModeDesktop = StereoRenderingModeDesktop.ToString();
settingsAsset.StereoRenderingModeAndroid = StereoRenderingModeAndroid.ToString();
#if OCULUS_SDK_PERF
settingsAsset.PluginVersion = string.Format("OculusPluginVersion|{0}", OculusStats.PluginVersion);
#endif
#else
settingsAsset.StereoRenderingMode = GetXrStereoRenderingPathMapping(StereoRenderingPath).ToString();
#endif
CreateAndSaveCurrentSettingsAsset(settingsAsset);
}
private string GetXrManagementPackageVersionInfo()
{
string packageRevision = string.Empty;
var listRequest = Client.List(true);
while (!listRequest.IsCompleted)
{
}
if (listRequest.Result.Any(r => r.name.Equals(xrManagementPackageName)))
{
var xrManagementPckg =
listRequest.Result.First(r => r.name.Equals(xrManagementPackageName));
var revision = TryGetRevisionFromPackageJson(xrManagementPackageName) ?? "unavailable";
var version = xrManagementPckg.version;
packageRevision = string.Format("XrManagementPackageName|{0}|XrManagementVersion|{1}|XrManagementRevision|{2}", xrManagementPackageName, version, revision);
}
return packageRevision;
}
private string GetUrpPackageVersionInfo()
{
string packageRevision = string.Empty;
var listRequest = Client.List(true);
while (!listRequest.IsCompleted)
{
}
if (listRequest.Result.Any(r => r.name.Equals(urpPackageName)))
{
var urpPckg =
listRequest.Result.First(r => r.name.Equals(urpPackageName));
var revision = TryGetRevisionFromPackageJson(urpPackageName) ?? "unavailable";
var version = urpPckg.version;
packageRevision = string.Format("UrpPackageName|{0}|UrpVersion|{1}|UrpRevision|{2}", urpPackageName, version, revision);
}
return packageRevision;
}
private string GetHdrpPackageVersionInfo()
{
string packageRevision = string.Empty;
var listRequest = Client.List(true);
while (!listRequest.IsCompleted)
{
}
if (listRequest.Result.Any(r => r.name.Equals(hdrpPackageName)))
{
var urpPckg =
listRequest.Result.First(r => r.name.Equals(hdrpPackageName));
var revision = TryGetRevisionFromPackageJson(hdrpPackageName) ?? "unavailable";
var version = urpPckg.version;
packageRevision = string.Format("HdrpPackageName|{0}|HdrpVersion|{1}|HdrpRevision|{2}", hdrpPackageName, version, revision);
}
return packageRevision;
}
private string GetPerfTestsPackageVersionInfo()
{
string packageRevision = string.Empty;
var listRequest = Client.List(true);
while (!listRequest.IsCompleted)
{
}
if (listRequest.Result.Any(r => r.name.Equals(perfTestsPackageName)))
{
var perfTestsPckg =
listRequest.Result.First(r => r.name.Equals(perfTestsPackageName));
var revision = TryGetRevisionFromPackageJson(perfTestsPackageName) ?? "unavailable";
var version = perfTestsPckg.version;
packageRevision = string.Format("PerfTestsPackageName|{0}|PerfTestsVersion|{1}|PerfTestsRevision|{2}", perfTestsPackageName, version, revision);
}
return packageRevision;
}
private string GetOculusXrSdkPackageVersionInfo()
{
string packageRevision = string.Empty;
var listRequest = Client.List(true);
while (!listRequest.IsCompleted)
{
}
if (listRequest.Result.Any(r => r.name.Equals(oculusXrSdkPackageName)))
{
var oculusXrsdkPckg =
listRequest.Result.First(r => r.name.Equals(oculusXrSdkPackageName));
var version = oculusXrsdkPckg.version;
// if XrsdkRevision is empty, then it wasn't passed in on the command line (which is
// usually going to be the case if we're running in tests at the PR level for Xrsdk package).
// In this case, we most likely are using a released package reference, so let's try to get
// the revision from the package.json.
if (string.IsNullOrEmpty(XrsdkRevision))
{
XrsdkRevision = TryGetRevisionFromPackageJson(oculusXrSdkPackageName) ?? "unavailable";
}
// if XrsdkRevisionDate is empty, then it wasn't passed in on the command line (which is
// usually going to be the case if we're running in tests at the PR level for Xrsdk package).
// In this case, we most likely are using a released package reference, so let's try to get
// the revision date from the package manager api instead.
if (string.IsNullOrEmpty(XrsdkRevisionDate))
{
TryGetXrsdkRevisionDate(oculusXrsdkPckg);
}
// if XrsdkBranch is empty, then it wasn't passed in on the command line (which is
// usually going to be the case if we're running in tests at the PR level for Xrsdk package).
// In this case, we most likely are using a released package reference, so let's try to infer
// the branch from the major.minor version of the package via the package manager API
if (string.IsNullOrEmpty(XrsdkBranch))
{
TryGetXrsdkBranch(oculusXrsdkPckg);
}
packageRevision = string.Format(
"XrSdkName|{0}|XrSdkVersion|{1}|XrSdkRevision|{2}|XrSdkRevisionDate|{3}|XrSdkBranch|{4}",
oculusXrSdkPackageName,
version,
XrsdkRevision,
XrsdkRevisionDate,
XrsdkBranch);
}
return packageRevision;
}
private void TryGetXrsdkBranch(PackageInfo oculusXrsdkPckg)
{
var matches = majorMinorVersionValueRegex.Matches(oculusXrsdkPckg.version);
XrsdkBranch = matches.Count > 0 ? string.Concat(matches[0].Groups[0].Value, "x") : "release";
}
private void TryGetXrsdkRevisionDate(PackageInfo oculusXrsdkPckg)
{
#if OCULUS_SDK
XrsdkRevisionDate =
oculusXrsdkPckg.datePublished != null ?
((DateTime) oculusXrsdkPckg.datePublished).ToString("s", DateTimeFormatInfo.InvariantInfo) : "unavailable";
#endif
}
private string TryGetRevisionFromPackageJson(string packageName)
{
string revision = null;
var packageAsString = File.ReadAllText(string.Format("Packages/{0}/package.json",packageName));
var matches = revisionValueRegex.Matches(packageAsString);
if (matches.Count > 0)
{
revision = matches[0].Groups[1].Value;
}
return revision;
}
private XRSettings.StereoRenderingMode GetXrStereoRenderingPathMapping(StereoRenderingPath stereoRenderingPath)
{
switch (stereoRenderingPath)
{
case StereoRenderingPath.SinglePass:
return XRSettings.StereoRenderingMode.SinglePass;
case StereoRenderingPath.MultiPass:
return XRSettings.StereoRenderingMode.MultiPass;
case StereoRenderingPath.Instancing:
return XRSettings.StereoRenderingMode.SinglePassInstanced;
default:
return XRSettings.StereoRenderingMode.SinglePassMultiview;
}
}
private void CreateAndSaveCurrentSettingsAsset(CurrentSettings settingsAsset)
{
if (!System.IO.Directory.Exists(resourceDir))
{
System.IO.Directory.CreateDirectory(resourceDir);
}
AssetDatabase.CreateAsset(settingsAsset, resourceDir + "/settings.asset");
AssetDatabase.SaveAssets();
}
#endif
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bdf30ba0ce15b914984e73f7ce4e9bde
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

164
Editor/XrConfigurator.cs Normal file
Просмотреть файл

@ -0,0 +1,164 @@

using System.IO;
#if UNITY_EDITOR
#if XR_SDK
using UnityEditor.XR.Management;
using System;
#endif
using UnityEditor;
#endif
using UnityEngine;
#if XR_SDK
using UnityEngine.XR.Management;
#endif
#if OCULUS_SDK
using Unity.XR.Oculus;
#endif
#if MOCKHMD_SDK
using Unity.XR.MockHMD;
#endif
namespace com.unity.cliconfigmanager
{
public class XrConfigurator
{
#if XR_SDK
private readonly string xrsdkTestXrSettingsPath = "Assets/XR/Settings/Test Settings.asset";
#endif
private readonly PlatformSettings platformSettings;
public XrConfigurator(PlatformSettings platformSettings)
{
this.platformSettings = platformSettings;
}
#if UNITY_EDITOR
public void ConfigureXr()
{
#if XR_SDK
ConfigureXrSdk();
#else
ConfigureLegacyVr();
#endif
}
#if XR_SDK
private void ConfigureXrSdk()
{
PlayerSettings.virtualRealitySupported = false;
// Create our own test version of xr general settings.
var xrGeneralSettings = ScriptableObject.CreateInstance<XRGeneralSettings>();
var managerSettings = ScriptableObject.CreateInstance<XRManagerSettings>();
var buildTargetSettings = ScriptableObject.CreateInstance<XRGeneralSettingsPerBuildTarget>();
xrGeneralSettings.Manager = managerSettings;
EnsureArgumentsNotNull(xrGeneralSettings, buildTargetSettings, managerSettings);
#if OCULUS_SDK
SetupLoader<OculusLoader>(xrGeneralSettings, buildTargetSettings, managerSettings);
#endif
#if MOCKHMD_SDK
PlayerSettings.stereoRenderingPath = platformSettings.StereoRenderingPath;
SetupLoader<MockHMDLoader>(xrGeneralSettings, buildTargetSettings, managerSettings);
#endif
#if OCULUS_SDK
var settings = ConfigureOculusSettings();
#endif
AssetDatabase.SaveAssets();
EditorBuildSettings.AddConfigObject(XRGeneralSettings.k_SettingsKey, buildTargetSettings, true);
#if OCULUS_SDK
EditorBuildSettings.AddConfigObject("Unity.XR.Oculus.Settings", settings, true);
#endif
}
#if OCULUS_SDK
private OculusSettings ConfigureOculusSettings()
{
var settings = ScriptableObject.CreateInstance<OculusSettings>();
if (settings == null)
{
throw new ArgumentNullException(
$"Tried to instantiate an instance of {typeof(OculusSettings).Name} but it is null.");
}
AssetDatabase.AddObjectToAsset(settings, xrsdkTestXrSettingsPath);
if (platformSettings.BuildTarget == BuildTarget.Android)
{
settings.m_StereoRenderingModeAndroid = platformSettings.StereoRenderingModeAndroid;
}
else
{
settings.m_StereoRenderingModeDesktop = platformSettings.StereoRenderingModeDesktop;
}
return settings;
}
#endif
private void SetupLoader<T>(XRGeneralSettings xrGeneralSettings,
XRGeneralSettingsPerBuildTarget buildTargetSettings,
XRManagerSettings managerSettings) where T : XRLoader
{
var loader = ScriptableObject.CreateInstance<T>();
loader.name = loader.GetType().Name;
if (loader == null)
{
throw new ArgumentNullException(
$"Tried to instantiate an instance of {typeof(T).Name}, but it is null.");
}
xrGeneralSettings.Manager.loaders.Add(loader);
buildTargetSettings.SetSettingsForBuildTarget(EditorUserBuildSettings.selectedBuildTargetGroup,
xrGeneralSettings);
EnsureXrGeneralSettingsPathExists(xrsdkTestXrSettingsPath);
AssetDatabase.CreateAsset(buildTargetSettings, xrsdkTestXrSettingsPath);
AssetDatabase.AddObjectToAsset(xrGeneralSettings, xrsdkTestXrSettingsPath);
AssetDatabase.AddObjectToAsset(managerSettings, xrsdkTestXrSettingsPath);
AssetDatabase.AddObjectToAsset(loader, xrsdkTestXrSettingsPath);
}
private void EnsureArgumentsNotNull(XRGeneralSettings xrGeneralSettings,
XRGeneralSettingsPerBuildTarget buildTargetSettings, XRManagerSettings managerSettings)
{
EnsureArgumentNotNull(xrGeneralSettings);
EnsureArgumentNotNull(buildTargetSettings);
EnsureArgumentNotNull(managerSettings);
}
private void EnsureXrGeneralSettingsPathExists(string testXrGeneralSettingsPath)
{
var settingsPath = Path.GetDirectoryName(testXrGeneralSettingsPath);
if (!Directory.Exists(settingsPath))
{
Directory.CreateDirectory(testXrGeneralSettingsPath);
}
}
private static void EnsureArgumentNotNull(object arg)
{
if (arg == null)
{
throw new ArgumentNullException(nameof(arg));
}
}
#else
private void ConfigureLegacyVr()
{
PlayerSettings.virtualRealitySupported = true;
PlayerSettings.stereoRenderingPath = platformSettings.StereoRenderingPath;
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(platformSettings.BuildTargetGroup,
new string[] {platformSettings.XrTarget});
}
#endif
#endif
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 15e73d1b900ad6c4680361ac7d5f9c4e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,35 @@
{
"name": "com.unity.cli-config-manager",
"references": [
"com.unity.xr.tests.runtimesettings",
"Unity.XR.Oculus",
"Unity.XR.Oculus.Editor",
"Unity.XR.Management",
"Unity.XR.Management.Editor",
"com.unity.xr.oculusperformanceutility",
"Unity.XR.MockHMD",
"Unity.RenderPipelines.Universal.Runtime"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "com.unity.xr.oculus",
"expression": "0.0.1",
"define": "XR_SDK;OCULUS_SDK"
},
{
"name": "com.unity.xr.mock-hmd",
"expression": "0.0.1",
"define": "XR_SDK;MOCKHMD_SDK"
}
],
"noEngineReferences": false
}

Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f6cacf2273fa4a1488e781d84678972d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

5
LICENSE.md Normal file
Просмотреть файл

@ -0,0 +1,5 @@
Copyright © 2018 Unity Technologies ApS
Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions.

7
LICENSE.md.meta Normal file
Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f91a5571b0ad1ba47a5827b15a35f7d4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -1 +1,64 @@
# com.unity.cli-project-setup
# com.unity.cli-config-manager
Provides a command line parser and options to set editor, build, player, and other Unity settings when running Unity from the command line
# Methods
## public void ConfigureFromCmdlineArgs()
Parses command line args using args returned from `Environment.GetCommandLineArgs()` and matches up values based on Options below. Then sets the values to the appropriate build/player settings in the editor. Meant to be run prior to building the player or running a test.
# Options
Options Recognized from `Environment.GetCommandLineArgs()`
`-scriptingbackend=<ScriptingBackend>`
IL2CPP is default. Values: IL2CPP, Mono
`-simulationmode=<SimulationMode>`
Enable Simulation modes for Windows MR in Editor. Values: HoloLens, WindowsMR, Remoting
`-enabledxrtarget=<XrTargetToEnable>`
XR target to enable in player settings. Values: Oculus, OpenVR, cardboard, daydream, MockHMD, OculusXRSDK
`-playergraphicsapi=<GraphicsApi>`
Graphics API based on GraphicsDeviceType. Values: Direct3D11, OpenGLES2, OpenGLES3, PlayStation4, XboxOne, Metal, OpenGLCore, Direct3D12, Switch, XboxOneD3D12
`-colorspace=<ColorSpace>`
Linear or Gamma color space. Default is Gamma. Values: Linear, Gamma
`-stereorenderingpath=<StereoRenderingPath>`
Stereo rendering path to enable.
Legacy VR Values: MultiPass, SinglePass, Instancing
Oculus XR SDK Desktop Values: MultiPass, SinglePassInstanced
Oculus XR SDK Android Values: MultiPass, MultiView
`-mtRendering`
Enable or disable multithreaded rendering. Enabled is default.
Append '-' to disable: -mtRendering-
`-graphicsJobs`
Enable graphics jobs rendering. Disabled is default.
Append '-' to disable: -graphicsJobs-
`-minimumandroidsdkversion=`
Minimum Android SDK Version (Integer) to use.
`-targetandroidsdkversion=`
Target Android SDK Version (Integer) to use.
`-appleDeveloperTeamID=`
Apple Developer Team ID. Use for deployment and running tests on iOS device.
`-iOSProvisioningProfileID=`
iOS Provisioning Profile ID. Use for deployment and running tests on iOS device.

7
README.md.meta Normal file
Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7b56f7a7e4292484596f45c2a16f1137
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

15
Third Party Notices.md Normal file
Просмотреть файл

@ -0,0 +1,15 @@
This package contains third-party software components governed by the license(s) indicated below:
Component Name: Chart.js
License Type: MIT
The MIT License (MIT)
Copyright (c) 2018 Chart.js Contributors
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.

Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6eb80bd4b8697a04ab42b66b20aea256
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
package.json Normal file
Просмотреть файл

@ -0,0 +1,7 @@
{
"name": "com.unity.cli-config-manager",
"displayName": "Unity CLI Configuration Manager",
"version": "0.1.0-preview",
"unity": "2018.3",
"description": "Provides a command line parser and options to set build, player, and other Unity settings when running Unity from the command line."
}

7
package.json.meta Normal file
Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 73884c072159e0a4f985b2428497b0a4
PackageManifestImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: