-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(samples): Add project settings validation wizard
Summary: Add a project settings validation wizard to ensure that the correct project settings are applied. Remove old project validation files. Updated merge github workflow and added a cleanup workflow. Reviewed By: sohailshafiiWk Differential Revision: D41091947 fbshipit-source-id: 51c41a003d2a8951ff213671397d705b61dab25c
- Loading branch information
1 parent
f4cc1c2
commit b2f5005
Showing
15 changed files
with
185 additions
and
1,547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Cleanup deleted files from dev in main | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
merge-branch: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: main | ||
- name: Set Git config | ||
run: | | ||
git config --local user.email "actions@github.com" | ||
git config --local user.name "Github Actions" | ||
- name: Merge dev to main | ||
run: | | ||
git pull | ||
git merge --allow-unrelated-histories $(git commit-tree -p main -m "[Automated] Cleanup" origin/dev^{tree}) | ||
- name: Use CHANGELOG and package.json from main | ||
run: | | ||
git checkout HEAD~2 CHANGELOG.md | ||
git checkout HEAD~2 package.json | ||
git commit --amend --no-edit | ||
- name: Push | ||
run: | | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
||
using UnityEditor; | ||
using UnityEngine; | ||
using UnityEngine.Rendering; | ||
|
||
namespace Oculus.Movement.Utils | ||
{ | ||
/// <summary> | ||
/// Validates various project settings for the samples to work correctly. | ||
/// </summary> | ||
[InitializeOnLoad] | ||
public class ProjectValidation | ||
{ | ||
private static readonly string[] _expectedLayers = { "Character", "MirroredCharacter", "HiddenMesh" }; | ||
|
||
static ProjectValidation() | ||
{ | ||
if (!ShouldShowWindow()) | ||
{ | ||
return; | ||
} | ||
|
||
ProjectValidationWindow.ShowProjectValidationWindow(); | ||
} | ||
|
||
/// <summary> | ||
/// If all expected layers are in the project, returns true. | ||
/// </summary> | ||
/// <returns>True if all expected layers are in the project.</returns> | ||
public static bool TestLayers() | ||
{ | ||
bool allLayersArePresent = true; | ||
foreach (var expectedLayer in _expectedLayers) | ||
{ | ||
if (LayerMask.NameToLayer(expectedLayer) == -1) | ||
{ | ||
allLayersArePresent = false; | ||
break; | ||
} | ||
} | ||
return allLayersArePresent; | ||
} | ||
|
||
/// <summary> | ||
/// If the project is using URP, returns true if vulkan is set. | ||
/// </summary> | ||
/// <returns>True if vulkan is set and the project requires URP.</returns> | ||
public static bool TestVulkan() | ||
{ | ||
bool vulkanFoundOrNotRequired = GraphicsSettings.renderPipelineAsset == null | ||
|| SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan | ||
|| SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11; | ||
return vulkanFoundOrNotRequired; | ||
} | ||
|
||
private static bool ShouldShowWindow() | ||
{ | ||
return !TestLayers() || !TestVulkan(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Editor window that displays information about configuring the project. | ||
/// </summary> | ||
public class ProjectValidationWindow : EditorWindow | ||
{ | ||
private static ProjectValidationWindow _projectValidationWindow; | ||
|
||
/// <summary> | ||
/// Shows the project validation window. | ||
/// </summary> | ||
public static void ShowProjectValidationWindow() | ||
{ | ||
if (!HasOpenInstances<ProjectValidationWindow>()) | ||
{ | ||
_projectValidationWindow = GetWindow<ProjectValidationWindow>(); | ||
_projectValidationWindow.titleContent = new GUIContent("Movement Validation"); | ||
_projectValidationWindow.Focus(); | ||
} | ||
} | ||
|
||
private void OnEnable() | ||
{ | ||
EditorWindow editorWindow = this; | ||
|
||
Vector2 windowSize = new Vector2(600, 200); | ||
editorWindow.minSize = windowSize; | ||
editorWindow.maxSize = windowSize; | ||
} | ||
|
||
private void OnGUI() | ||
{ | ||
bool layersValid = ProjectValidation.TestLayers(); | ||
bool vulkanValid = ProjectValidation.TestVulkan(); | ||
GUIStyle labelStyle = new GUIStyle (EditorStyles.label); | ||
labelStyle.richText = true; | ||
labelStyle.wordWrap = true; | ||
|
||
GUILayout.BeginVertical(); | ||
{ | ||
GUI.enabled = !layersValid; | ||
GUILayout.BeginVertical(EditorStyles.helpBox); | ||
{ | ||
GUILayout.Label("Layers", EditorStyles.boldLabel); | ||
GUILayout.Label( | ||
"For the sample scenes, the following layers must be present in the project: <b>Character (layer index 10), MirroredCharacter (layer index 11), and HiddenMesh</b>. \n\nImport the Layers preset in <b>Edit -> Project Settings -> Tags and Layers</b> by selecting the tiny settings icon located at the top right corner and choosing the <b>Layers</b> preset located in the <b>Samples/Shared/Presets</b> folder.", | ||
labelStyle); | ||
GUILayout.Space(5); | ||
} | ||
GUILayout.EndVertical(); | ||
GUI.enabled = true; | ||
|
||
GUI.enabled = !vulkanValid; | ||
GUILayout.BeginVertical(EditorStyles.helpBox); | ||
{ | ||
GUILayout.Label("Vulkan", EditorStyles.boldLabel); | ||
GUILayout.Label( | ||
"Set the primary graphics API to Vulkan in <b>Edit -> Project Settings -> Player -> Other Settings -> Graphics API</b>.", | ||
labelStyle); | ||
GUILayout.Space(5); | ||
} | ||
GUILayout.EndVertical(); | ||
GUI.enabled = true; | ||
} | ||
GUILayout.EndVertical(); | ||
GUILayout.Space(5); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../Validation/RuntimeUnitValidation.cs.meta → Editor/Utils/ProjectValidation.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
Runtime/Scripts/Validation/LayerAndVulkanValidation.cs.meta
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.