-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
7,898 additions
and
258 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
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
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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using UnityEditor; | ||
using UnityEngine; | ||
using Innoactive.CreatorEditor.BasicInteraction; | ||
using Innoactive.CreatorEditor.PackageManager.XRInteraction; | ||
|
||
namespace Innoactive.CreatorEditor.XRInteraction | ||
{ | ||
/// <summary> | ||
/// Scene setup for XR-Interaction. | ||
/// </summary> | ||
public class XRInteractionSceneSetup : InteractionFrameworkSceneSetup | ||
{ | ||
private const string Title = "Obsolete XR Ring detected"; | ||
|
||
/// <inheritdoc /> | ||
public override string Key { get; } = "XRInteractionSetup"; | ||
|
||
/// <inheritdoc /> | ||
public override void Setup() | ||
{ | ||
DeleteStaticObject("[XR_Setup]"); | ||
|
||
#if XRIT_1_0_OR_NEWER | ||
XRSimulatorImporter simulatorImporter = new XRSimulatorImporter(); | ||
|
||
if (string.IsNullOrEmpty(simulatorImporter.SimulatorRigPath) || AssetDatabase.GetMainAssetTypeAtPath(simulatorImporter.SimulatorRigPath) == null) | ||
{ | ||
simulatorImporter.ImportSimulatorRig(); | ||
} | ||
#endif | ||
} | ||
|
||
private void DeleteStaticObject(string objectName) | ||
{ | ||
GameObject objectToDelete = GameObject.Find(objectName); | ||
|
||
if (objectToDelete != null) | ||
{ | ||
string message = $"Creator changed the XR Rig loading to a new dynamic system, you have a static {objectName} in the current scene, do you want to delete it?"; | ||
|
||
if (EditorUtility.DisplayDialog(Title, message, "Delete", "Skip")) | ||
{ | ||
EditorUtility.SetDirty(objectToDelete); | ||
Object.DestroyImmediate(objectToDelete); | ||
} | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
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,66 @@ | ||
#if XRIT_1_0_OR_NEWER | ||
using System.IO; | ||
using System.Linq; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Innoactive.CreatorEditor.PackageManager.XRInteraction | ||
{ | ||
/// <summary> | ||
/// Helper class to generate a new XR Simulator Rig out of the `[XR_Setup_Action_Based]` and the `XR Device Simulator` sample. | ||
/// </summary> | ||
internal class XRSimulatorImporter | ||
{ | ||
public string SimulatorRigPath { get; } = null; | ||
|
||
private const string SimulatorPathKey = "SimulatorRigPath"; | ||
private const string SamplePrefabName = "XR Device Simulator"; | ||
private const string ActionRigName = "[XR_Setup_Action_Based]"; | ||
private const string SimulatorPrefabName = "[XR_Setup_Simulator]"; | ||
|
||
public XRSimulatorImporter() | ||
{ | ||
SimulatorRigPath = EditorPrefs.GetString(SimulatorPathKey); | ||
} | ||
|
||
/// <summary> | ||
/// Imports a new `[XR_Setup_Simulator]` prefab based on the `[XR_Setup_Action_Based]` and the `XR Device Simulator` prefabs. | ||
/// </summary> | ||
/// <remarks>The generated prefab is imported into the `XR Interaction Component`’s `Resources` folder.</remarks> | ||
public void ImportSimulatorRig() | ||
{ | ||
GameObject simulator = LoadPrefab(SamplePrefabName, "Samples", out string simulatorRigPath); | ||
GameObject actionRig = LoadPrefab(ActionRigName, "Innoactive", out string actionRigPath); | ||
|
||
if (simulator == null || actionRig == null) | ||
{ | ||
Debug.LogError($"{SimulatorPrefabName} could not be generated. {(simulator == null ? SamplePrefabName : ActionRigName)} is missing."); | ||
return; | ||
} | ||
|
||
simulatorRigPath = $"{Path.GetDirectoryName(actionRigPath)}/{SimulatorPrefabName}.prefab"; | ||
|
||
simulator.transform.SetParent(actionRig.transform); | ||
PrefabUtility.SaveAsPrefabAsset(actionRig, simulatorRigPath); | ||
|
||
EditorPrefs.SetString(SimulatorPathKey, simulatorRigPath); | ||
PrefabUtility.UnloadPrefabContents(simulator); | ||
} | ||
|
||
private GameObject LoadPrefab(string prefabName, string searchFolder, out string assetPath) | ||
{ | ||
string filter = $"t:Prefab {prefabName}"; | ||
string prefabGUID = AssetDatabase.FindAssets(filter, new[] {$"Assets/{searchFolder}"}).FirstOrDefault(); | ||
|
||
if (string.IsNullOrEmpty(prefabGUID) == false) | ||
{ | ||
assetPath = AssetDatabase.GUIDToAssetPath(prefabGUID); | ||
return PrefabUtility.LoadPrefabContents(assetPath); | ||
} | ||
|
||
assetPath = string.Empty; | ||
return null; | ||
} | ||
} | ||
} | ||
#endif |
2 changes: 1 addition & 1 deletion
2
...geDependencies/InputSystemChecker.cs.meta → ...or/SceneSetup/XRSimulatorImporter.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 was deleted.
Oops, something went wrong.
Oops, something went wrong.