Skip to content

Commit

Permalink
version 5.4.0-r.8
Browse files Browse the repository at this point in the history
  • Loading branch information
srl87 committed Sep 27, 2023
1 parent 8415599 commit 9c04382
Show file tree
Hide file tree
Showing 1,809 changed files with 1,111,160 additions and 1,108,116 deletions.
16 changes: 8 additions & 8 deletions com.htc.upm.wave.essence/Editor.meta

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

194 changes: 186 additions & 8 deletions com.htc.upm.wave.essence/Editor/EssenceSettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEngine;
using UnityEngine.Rendering;
using Wave.XR;
using Wave.XR.Settings;

Expand Down Expand Up @@ -182,6 +183,35 @@ internal static bool IsInteractionModePackageOnceImported()
}
#endregion

#region BodyTracking asset
const string kBodyTrackingAsset = "/BodyTracking.asset";
public static void UpdateAssetBodyTracking(bool importedBodyTrackingPackage)
{
PackageEssenceAsset asset = null;
if (File.Exists(WaveEssencePath + kBodyTrackingAsset))
{
asset = AssetDatabase.LoadAssetAtPath(WaveEssencePath + kBodyTrackingAsset, typeof(PackageEssenceAsset)) as PackageEssenceAsset;
asset.importedBodyTrackingPackage = importedBodyTrackingPackage;
}
else
{
asset = ScriptableObject.CreateInstance(typeof(PackageEssenceAsset)) as PackageEssenceAsset;
asset.importedBodyTrackingPackage = importedBodyTrackingPackage;
AssetDatabase.CreateAsset(asset, WaveEssencePath + kBodyTrackingAsset);
}
AssetDatabase.SaveAssets();
Debug.Log("UpdateAssetBodyTracking() " + WaveEssencePath + kBodyTrackingAsset + ", importedBodyTrackingPackage: " + asset.importedBodyTrackingPackage);
}
internal static bool IsBodyTrackingPackageOnceImported()
{
if (!File.Exists(WaveEssencePath + kBodyTrackingAsset))
return false;

PackageEssenceAsset asset = AssetDatabase.LoadAssetAtPath(WaveEssencePath + kBodyTrackingAsset, typeof(PackageEssenceAsset)) as PackageEssenceAsset;
return asset.importedBodyTrackingPackage;
}
#endregion

private static readonly string[] essenceKeywords = new string[]
{
"Wave",
Expand All @@ -195,7 +225,10 @@ internal static bool IsInteractionModePackageOnceImported()
"XR",
"Tracker",
"ScenePerception",
"TrackableMarker"
"TrackableMarker",
"URPMaterials",
"Spectator",
"BodyTracking",
};

internal static UnityEditor.PackageManager.PackageInfo pi = null;
Expand Down Expand Up @@ -239,6 +272,12 @@ internal static void Init()
internal const string kScenePerceptionPackage = "wave_essence_sceneperception.unitypackage";
internal const string kTrackableMarkerPath = "/TrackableMarker";
internal const string kTrackableMarkerPackage = "wave_essence_trackablemarker.unitypackage";
internal const string kURPMaterialsPackage = "wave_essence_urpmaterials.unitypackage";
internal const string kSpectatorPath = "/Spectator";
internal const string kSpectatorPackage = "wave_essence_spectator.unitypackage";
internal const string kBodyTrackingPath = "/BodyTracking";
internal const string kBodyTrackingPackage = "wave_essence_bodytracking.unitypackage";
internal const string kVrm1Package = "VRM-0.109.0_7aff.unitypackage";

internal static bool featureControllerModelImported = false;
internal static bool featureInputModuleImported = false;
Expand All @@ -252,6 +291,8 @@ internal static void Init()
internal static bool featureTrackerModelImported = false;
internal static bool featureScenePerceptionImported = false;
internal static bool featureTrackableMarkerImported = false;
internal static bool featureSpectatorImported = false;
internal static bool featureBodyTrackingImported = false;

internal static bool featureControllerModelNeedUpdate = false;
internal static bool featureInputModuleNeedUpdate = false;
Expand All @@ -265,6 +306,8 @@ internal static void Init()
internal static bool featureTrackerModelNeedUpdate = false;
internal static bool featureScenePerceptionNeedUpdate = false;
internal static bool featureTrackableMarkerNeedUpdate = false;
internal static bool featureSpectatorNeedUpdate = false;
internal static bool featureBodyTrackingNeedUpdate = false;

internal static bool hasFeatureNeedUpdate = false;

Expand All @@ -282,6 +325,8 @@ internal static bool checkFeaturePackages()
featureTrackerModelImported = Directory.Exists(WaveEssencePath + kTrackerModelPath);
featureScenePerceptionImported = Directory.Exists(WaveEssencePath + kScenePerceptionPath);
featureTrackableMarkerImported = Directory.Exists(WaveEssencePath + kTrackableMarkerPath);
featureSpectatorImported = Directory.Exists(WaveEssencePath + kSpectatorPath);
featureBodyTrackingImported = Directory.Exists(WaveEssencePath + kBodyTrackingPath);

if (pi == null)
return false;
Expand Down Expand Up @@ -310,9 +355,12 @@ internal static bool checkFeaturePackages()
!Directory.Exists(WaveEssencePath + kScenePerceptionPath + "/" + FAKE_VERSION);
featureTrackableMarkerNeedUpdate = featureTrackableMarkerImported && !Directory.Exists(WaveEssencePath + kTrackableMarkerPath + "/" + pi.version) &&
!Directory.Exists(WaveEssencePath + kTrackableMarkerPath + "/" + FAKE_VERSION);
featureSpectatorNeedUpdate = featureSpectatorImported && !Directory.Exists(WaveEssencePath + kSpectatorPath + "/" + pi.version) && !Directory.Exists(WaveEssencePath + kSpectatorPath + "/" + FAKE_VERSION);
featureBodyTrackingNeedUpdate = featureBodyTrackingImported && !Directory.Exists(WaveEssencePath + kBodyTrackingPath + "/" + pi.version) &&
!Directory.Exists(WaveEssencePath + kBodyTrackingPath + "/" + FAKE_VERSION);

hasFeatureNeedUpdate = featureControllerModelNeedUpdate || featureInputModuleNeedUpdate || featureHandModelNeedUpdate || featureInteractionModeNeedUpdate || featureInteractionToolkitNeedUpdate ||
featureCameraTextureNeedUpdate || featureCompositorLayerNeedUpdate || featureBundlePreviewNeedUpdate || featureRenderDocNeedUpdate || featureScenePerceptionNeedUpdate || featureTrackableMarkerNeedUpdate;
featureCameraTextureNeedUpdate || featureCompositorLayerNeedUpdate || featureBundlePreviewNeedUpdate || featureRenderDocNeedUpdate || featureScenePerceptionNeedUpdate || featureTrackableMarkerNeedUpdate || featureSpectatorNeedUpdate || featureBodyTrackingNeedUpdate;

return hasFeatureNeedUpdate;
}
Expand Down Expand Up @@ -344,6 +392,10 @@ public static void UpdateAllModules()
UpdateModule(WaveEssencePath + kScenePerceptionPath, kScenePerceptionPackage);
if (featureTrackableMarkerNeedUpdate)
UpdateModule(WaveEssencePath + kTrackableMarkerPath, kTrackableMarkerPackage);
if (featureSpectatorNeedUpdate)
UpdateModule(WaveEssencePath + kSpectatorPath, kSpectatorPackage);
if (featureBodyTrackingNeedUpdate)
UpdateModule(WaveEssencePath + kBodyTrackingPath, kBodyTrackingPackage);
}

public override void OnGUI(string searchContext)
Expand All @@ -361,6 +413,9 @@ public override void OnGUI(string searchContext)
bool showTrackerModel = searchContext.Contains("Tracker");
bool showScenePerception = searchContext.Contains("ScenePerception");
bool showTrackableMarker = searchContext.Contains("TrackableMarker");
bool showURPMaterials = searchContext.Contains("URPMaterials");
bool showSpectator = searchContext.Contains("Spectator");
bool showBodyTracking = searchContext.Contains("BodyTracking");

if (showControllerModel ||
showInputModule ||
Expand All @@ -373,7 +428,10 @@ public override void OnGUI(string searchContext)
showInteractionToolkit ||
showTrackerModel ||
showScenePerception ||
showTrackableMarker)
showTrackableMarker ||
showURPMaterials ||
showSpectator ||
showBodyTracking)
{
hasKeyword = true;
}
Expand All @@ -392,7 +450,10 @@ public override void OnGUI(string searchContext)
* 10. Tracker Model
* 11. Scene Perception
* 12. Trackable Marker
**/
* 13. URP Materials
* 14. Spectator
* 15. Body Tracking
**/

checkFeaturePackages();

Expand Down Expand Up @@ -754,7 +815,100 @@ public override void OnGUI(string searchContext)
GUILayout.EndVertical();
}

}
if (GraphicsSettings.renderPipelineAsset != null && (showURPMaterials || !hasKeyword))
{
GUILayout.BeginVertical(EditorStyles.helpBox);
{
GUILayout.Label("URP materials", EditorStyles.boldLabel);
GUILayout.Label("These materials will overwrite the original contents."
, new GUIStyle(EditorStyles.label) { wordWrap = true });
GUILayout.Label("The feature will be imported at everywhere", EditorStyles.label);
GUILayout.Space(5f);
if (GUILayout.Button("Import Feature - URP Materials", GUILayout.ExpandWidth(false)))
ImportModule(kURPMaterialsPackage, true);
GUILayout.Space(5f);
GUI.enabled = true;
}
GUILayout.EndVertical();
}

if (showSpectator || !hasKeyword)
{
GUILayout.BeginVertical(EditorStyles.helpBox);
{
GUILayout.Label("Spectator", EditorStyles.boldLabel);
GUILayout.Label("Note: This feature is currently in Beta.\n" +
"Spectator is a feature that enables you to set the spectator camera to record the VR scene freely.\n"
, new GUIStyle(EditorStyles.label) { wordWrap = true });
GUILayout.Label("The feature will be imported at " + WaveEssencePath + kSpectatorPath, EditorStyles.label);
GUILayout.Space(5f);
GUI.enabled = !featureSpectatorImported || featureSpectatorNeedUpdate;
if (featureSpectatorNeedUpdate)
{
if (GUILayout.Button("Update Feature - Spectator", GUILayout.ExpandWidth(false)))
{
// To check wherever the Spectator setup correctly in the Wave setting
WaveXRSettings waveXRSettings = WaveXRSettings.GetInstance();
if (waveXRSettings != null)
{
if (waveXRSettings.allowSpectatorCamera == false)
{
waveXRSettings.allowSpectatorCamera = true;
}
UpdateModule(WaveEssencePath + kSpectatorPath, kSpectatorPackage);
}
else
{
Debug.LogError("Import Spectator feature fail because cannot get the WaveXR" +
"setting, please try again later.");
}
}
}
else
{
if (GUILayout.Button("Import Feature - Spectator", GUILayout.ExpandWidth(false)))
ImportModule(kSpectatorPackage);
}
GUILayout.Space(5f);
GUI.enabled = true;
}
GUILayout.EndVertical();
}

if (showBodyTracking || !hasKeyword)
{
GUILayout.BeginVertical(EditorStyles.helpBox);
{
GUILayout.Label("Body Tracking", EditorStyles.boldLabel);
GUILayout.Label(
"The Body Tracking feature depends on Humanoid VRM plugin.",
new GUIStyle(EditorStyles.label) { wordWrap = true });
GUILayout.Label(
"Note: Must using Unity Editor 2020.3.30f1 or newer version.",
new GUIStyle(EditorStyles.label) { wordWrap = true });
GUILayout.Label("This feature will be imported at " + WaveEssencePath + "/BodyTracking.\n" +
"Import the Tracker Model package first before using this feature.", EditorStyles.label);
GUILayout.Space(5f);
GUI.enabled = (!featureBodyTrackingImported || featureBodyTrackingNeedUpdate) && featureTrackerModelImported;
if (featureBodyTrackingNeedUpdate)
{
if (GUILayout.Button("Update Feature - Body Tracking", GUILayout.ExpandWidth(false)))
UpdateModule(WaveEssencePath + kBodyTrackingPath, kBodyTrackingPackage);
}
else
{
if (GUILayout.Button("Import Feature - Body Tracking", GUILayout.ExpandWidth(false)))
{
ImportModule(kVrm1Package);
ImportModule(kBodyTrackingPackage);
}
}
GUILayout.Space(5f);
GUI.enabled = true;
}
GUILayout.EndVertical();
}
}

public static void DeleteFolder(string path)
{
Expand Down Expand Up @@ -852,11 +1006,11 @@ internal static void UpdateModule(string ModelPath, string packagePath)
AssetDatabase.ImportPackage(target, false);
}

internal static void ImportModule(string packagePath)
internal static void ImportModule(string packagePath, bool interactive = false)
{
string target = Path.Combine("Packages/" + Constants.EssencePackageName + "/UnityPackages~", packagePath);
Debug.Log("Import: " + target);
AssetDatabase.ImportPackage(target, false);
AssetDatabase.ImportPackage(target, interactive);
}

[SettingsProvider]
Expand Down Expand Up @@ -1093,6 +1247,27 @@ static List<Item> GetItems()
GetCurrent = () => { return EssenceSettingsProvider.featureTrackableMarkerNeedUpdate.ToString(); },
};

var URPMaterials = new Item("URP Materials")
{
IsShow = () => { return true; },
IsReady = () => { return true; },
GetCurrent = () => { return "Need Manual Update"; },
};

var Spectator = new Item("Spectator")
{
IsShow = () => { return EssenceSettingsProvider.featureSpectatorImported; },
IsReady = () => { return !EssenceSettingsProvider.featureSpectatorNeedUpdate; },
GetCurrent = () => { return EssenceSettingsProvider.featureSpectatorNeedUpdate.ToString(); },
};

var BodyTracking = new Item("Body Tracking")
{
IsShow = () => { return EssenceSettingsProvider.featureBodyTrackingImported; },
IsReady = () => { return !EssenceSettingsProvider.featureBodyTrackingNeedUpdate; },
GetCurrent = () => { return EssenceSettingsProvider.featureBodyTrackingNeedUpdate.ToString(); },
};

return new List<Item>()
{
ControllerModel,
Expand All @@ -1105,7 +1280,10 @@ static List<Item> GetItems()
RenderDoc,
InteractionToolkit,
ScenePerception,
TrackableMarker
TrackableMarker,
URPMaterials,
Spectator,
BodyTracking,
};
}

Expand Down
22 changes: 11 additions & 11 deletions com.htc.upm.wave.essence/Editor/EssenceSettingsProvider.cs.meta

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

1 change: 1 addition & 0 deletions com.htc.upm.wave.essence/Editor/PackageEssenceAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class PackageEssenceAsset : ScriptableObject
public bool importedHandModelPackage = false;
public bool importedInteractionModePackage = false;
public bool importedTrackerModelPackage = false;
public bool importedBodyTrackingPackage = false;
}
}
#endif
22 changes: 11 additions & 11 deletions com.htc.upm.wave.essence/Editor/PackageEssenceAsset.cs.meta

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

Loading

0 comments on commit 9c04382

Please sign in to comment.