Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRTK3] Port Build Window to MRTK3 #11010

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UnityProjects/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
# Visual Studio Code cache directory
.vscode/

# Rider cache directory
.idea/

# Gradle cache directory
.gradle/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9f0ebc320a151d3408ea1e9fce54d40e, type: 3}
m_Name: OpenXR Package Settings
m_EditorClassIdentifier:
Keys: 010000000e00000007000000
Keys: 010000000e000000070000000d000000
Values:
- {fileID: -7232978043429515688}
- {fileID: -3301589181217746260}
- {fileID: -5356075571387229412}
- {fileID: 1803865306266780183}
--- !u!114 &668207626733321193
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -543,6 +544,21 @@ MonoBehaviour:
company: Microsoft
priority: 0
required: 0
--- !u!114 &1803865306266780183
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b5a1f07dc5afe854f9f12a4194aca3fb, type: 3}
m_Name: WebGL
m_EditorClassIdentifier:
features: []
m_renderMode: 1
m_depthSubmissionMode: 0
--- !u!114 &2243842767272741898
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
1 change: 1 addition & 0 deletions UnityProjects/MRTKDevTemplate/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"com.microsoft.mixedreality.visualprofiler": "https://github.com/microsoft/VisualProfiler-Unity.git#v2.2.0",
"com.microsoft.mrtk.accessibility": "file:../../../com.microsoft.mrtk.accessibility",
"com.microsoft.mrtk.audio": "file:../../../com.microsoft.mrtk.audio",
"com.microsoft.mrtk.buildwindow": "file:../../../com.microsoft.mrtk.buildwindow",
"com.microsoft.mrtk.core": "file:../../../com.microsoft.mrtk.core",
"com.microsoft.mrtk.data": "file:../../../com.microsoft.mrtk.data",
"com.microsoft.mrtk.diagnostics": "file:../../../com.microsoft.mrtk.diagnostics",
Expand Down
6 changes: 6 additions & 0 deletions UnityProjects/MRTKDevTemplate/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
"com.microsoft.mrtk.core": "3.0.0-development"
}
},
"com.microsoft.mrtk.buildwindow": {
"version": "file:../../../com.microsoft.mrtk.buildwindow",
"depth": 0,
"source": "local",
"dependencies": {}
},
"com.microsoft.mrtk.core": {
"version": "file:../../../com.microsoft.mrtk.core",
"depth": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PlayerSettings:
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.Microsoft.MRTK3Sample
Standalone: com.Microsoft.MRTK3Sample
Standalone: com.Microsoft.MRTK3-Sample
buildNumber:
Standalone: 0
iPhone: 0
Expand Down
12 changes: 12 additions & 0 deletions com.microsoft.mrtk.buildwindow/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Reflection;

[assembly: AssemblyProduct("Microsoft® Mixed Reality Toolkit Build Window")]
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation")]

// The AssemblyVersion attribute is checked-in and is recommended not to be changed often.
// https://docs.microsoft.com/troubleshoot/visualstudio/general/assembly-version-assembly-file-version
// AssemblyFileVersion and AssemblyInformationalVersion are added by pack-upm.ps1 to match the current MRTK build version.
[assembly: AssemblyVersion("3.0.0.0")]
11 changes: 11 additions & 0 deletions com.microsoft.mrtk.buildwindow/AssemblyInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

175 changes: 175 additions & 0 deletions com.microsoft.mrtk.buildwindow/AsyncCoroutineRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
// MIT License

// Copyright(c) 2016 Modest Tree Media Inc

// 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.

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

[assembly: InternalsVisibleTo("Microsoft.MixedReality.Toolkit.Tests.PlayModeTests")]
namespace Microsoft.MixedReality.Toolkit.Utilities
{
/// <summary>
/// This Async Coroutine Runner is just an object to
/// ensure that coroutines run properly with async/await.
/// </summary>
/// <remarks>
/// <para>The object that this MonoBehavior is attached to must be a root object in the
/// scene, as it will be marked as DontDestroyOnLoad (so that when scenes are changed,
/// it will persist instead of being destroyed). The runner will force itself to
/// the root of the scene if it's rooted elsewhere.</para>
/// </remarks>
[AddComponentMenu("Scripts/MRTK/Core/AsyncCoroutineRunner")]
internal sealed class AsyncCoroutineRunner : MonoBehaviour
{
private static AsyncCoroutineRunner instance;

private static bool isInstanceRunning = false;

private static readonly Queue<Action> Actions = new Queue<Action>();

internal static AsyncCoroutineRunner Instance
{
get
{
if (instance == null)
{
instance = FindObjectOfType<AsyncCoroutineRunner>();
}

// FindObjectOfType() only search for objects attached to active GameObjects. The FindObjectOfType(bool includeInactive) variant is not available to Unity 2019.4 and earlier so cannot be used.
// We instead search for GameObject called AsyncCoroutineRunner and see if it has the component attached.
if (instance == null)
{
var instanceGameObject = GameObject.Find("AsyncCoroutineRunner");

if (instanceGameObject != null)
{
instance = instanceGameObject.GetComponent<AsyncCoroutineRunner>();

if (instance == null)
{
Debug.Log("[AsyncCoroutineRunner] Found a \"AsyncCoroutineRunner\" GameObject but didn't have the AsyncCoroutineRunner component attached. Attaching the script.");
instance = instanceGameObject.AddComponent<AsyncCoroutineRunner>();
}
}
}

if (instance == null)
{
Debug.Log("[AsyncCoroutineRunner] There is no AsyncCoroutineRunner in the scene. Adding a GameObject with AsyncCoroutineRunner attached at the root of the scene.");
instance = new GameObject("AsyncCoroutineRunner").AddComponent<AsyncCoroutineRunner>();
}
else if (!instance.isActiveAndEnabled)
{
if (!instance.enabled)
{
Debug.LogWarning("[AsyncCoroutineRunner] Found a disabled AsyncCoroutineRunner component. Enabling the component.");
instance.enabled = true;
}
if (!instance.gameObject.activeSelf)
{
Debug.LogWarning("[AsyncCoroutineRunner] Found an AsyncCoroutineRunner attached to an inactive GameObject. Setting the GameObject active.");
instance.gameObject.SetActive(true);
}
}

instance.gameObject.hideFlags = HideFlags.None;

// AsyncCoroutineRunner must be at the root so that we can call DontDestroyOnLoad on it.
// This is ultimately to ensure that it persists across scene loads/unloads.
if (instance.transform.parent != null)
{
Debug.LogWarning($"[AsyncCoroutineRunner] AsyncCoroutineRunner was found as a child of another GameObject {instance.transform.parent}, " +
"it must be a root object in the scene. Moving the AsyncCoroutineRunner to the root.");
instance.transform.parent = null;
}

#if !UNITY_EDITOR
DontDestroyOnLoad(instance);
#endif
return instance;
}
}

internal static void Post(Action task)
{
lock (Actions)
{
Actions.Enqueue(task);
}
}

internal static bool IsInstanceRunning => isInstanceRunning;

private void Update()
{
if (Instance != this)
{
Debug.Log("[AsyncCoroutineRunner] Multiple active AsyncCoroutineRunners is present in the scene. Disabling duplicate ones.");
enabled = false;
return;
}
isInstanceRunning = true;

int actionCount;

lock (Actions)
{
actionCount = Actions.Count;
}

for (int i = 0; i < actionCount; i++)
{
Action next;

lock (Actions)
{
next = Actions.Dequeue();
}

next();
}
}

private void OnDisable()
{
if (instance == this)
{
isInstanceRunning = false;
}
}

private void OnEnable()
{
if (Instance != this)
{
Debug.Log("[AsyncCoroutineRunner] Multiple active AsyncCoroutineRunners is present in the scene. Disabling duplicate ones.");
enabled = false;
}
else
{
isInstanceRunning = true;
}
}
}
}
3 changes: 3 additions & 0 deletions com.microsoft.mrtk.buildwindow/AsyncCoroutineRunner.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions com.microsoft.mrtk.buildwindow/BuildAndDeploy.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.MixedReality.Toolkit.Utilities.Editor;
using System;
using System.IO;
using UnityEditor;
using UnityEngine;

namespace Microsoft.MixedReality.Toolkit.Build.Editor
{
/// <summary>
/// Build and Deploy Specific Editor Preferences for the Build and Deploy Window.
/// </summary>
public static class BuildDeployPreferences
{
// Constants
private const string EDITOR_PREF_BUILD_DIR = "BuildDeployWindow_BuildDir";
private const string EDITOR_PREF_INCREMENT_BUILD_VERSION = "BuildDeployWindow_IncrementBuildVersion";
private const string EDITOR_PREF_3D_APP_LAUNCHER_MODEL_LOCATION = "BuildDeployWindow_AppLauncherModelLocation";

/// <summary>
/// The Build Directory that the Mixed Reality Toolkit will build to.
/// </summary>
/// <remarks>
/// This is a root build folder path. Each platform build will be put into a child directory with the name of the current active build target.
/// </remarks>
public static string BuildDirectory
{
get => $"{EditorPreferences.Get(EDITOR_PREF_BUILD_DIR, "Builds")}/{EditorUserBuildSettings.activeBuildTarget}";
set => EditorPreferences.Set(EDITOR_PREF_BUILD_DIR, value.Replace($"/{EditorUserBuildSettings.activeBuildTarget}", string.Empty));
}

/// <summary>
/// The absolute path to <see cref="BuildDirectory"/>
/// </summary>
public static string AbsoluteBuildDirectory
{
get
{
string rootBuildDirectory = BuildDirectory;
int dirCharIndex = rootBuildDirectory.IndexOf("/", StringComparison.Ordinal);

if (dirCharIndex != -1)
{
rootBuildDirectory = rootBuildDirectory.Substring(0, dirCharIndex);
}

return Path.GetFullPath(Path.Combine(Path.Combine(Application.dataPath, ".."), rootBuildDirectory));
}
}

/// <summary>
/// Current setting to increment build visioning.
/// </summary>
public static bool IncrementBuildVersion
{
get => EditorPreferences.Get(EDITOR_PREF_INCREMENT_BUILD_VERSION, true);
set => EditorPreferences.Set(EDITOR_PREF_INCREMENT_BUILD_VERSION, value);
}

/// <summary>
/// The location in Assets of the 3D app launcher model for an AppX build.
/// </summary>
/// <remarks>See <see href="https://docs.microsoft.com/en-us/windows/mixed-reality/distribute/3d-app-launcher-design-guidance">3D app launcher design guidance</see> for more information.</remarks>
public static string AppLauncherModelLocation
{
get => ProjectPreferences.Get(EDITOR_PREF_3D_APP_LAUNCHER_MODEL_LOCATION, string.Empty);
set => ProjectPreferences.Set(EDITOR_PREF_3D_APP_LAUNCHER_MODEL_LOCATION, value);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading