forked from cgvr/DeltaVR
deltavr multiplayer 2.0
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86f27c2138eb8584fa6527e18c1be13d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.XR.CoreUtils.Editor;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEditor.PackageManager.Requests;
|
||||
using UnityEditor.PackageManager.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.XR.Interaction.Toolkit.Samples.Hands
|
||||
{
|
||||
/// <summary>
|
||||
/// Unity Editor class which registers Project Validation rules for the Hands Interaction Demo sample,
|
||||
/// checking that other required samples and packages are installed.
|
||||
/// </summary>
|
||||
static class HandsInteractionSampleProjectValidation
|
||||
{
|
||||
const string k_SampleDisplayName = "Hands Interaction Demo";
|
||||
const string k_Category = "XR Interaction Toolkit";
|
||||
const string k_StarterAssetsSampleName = "Starter Assets";
|
||||
const string k_HandVisualizerSampleName = "HandVisualizer";
|
||||
|
||||
static readonly BuildTargetGroup[] s_BuildTargetGroups =
|
||||
((BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup))).Distinct().ToArray();
|
||||
|
||||
static readonly List<BuildValidationRule> s_BuildValidationRules = new List<BuildValidationRule>
|
||||
{
|
||||
new BuildValidationRule
|
||||
{
|
||||
IsRuleEnabled = () => s_HandsPackageAddRequest == null || s_HandsPackageAddRequest.IsCompleted,
|
||||
Message = $"[{k_SampleDisplayName}] XR Hands (com.unity.xr.hands) package must be installed to use this sample.",
|
||||
Category = k_Category,
|
||||
CheckPredicate = () => PackageVersionUtility.IsPackageInstalled("com.unity.xr.hands"),
|
||||
FixIt = () =>
|
||||
{
|
||||
s_HandsPackageAddRequest = Client.Add("com.unity.xr.hands");
|
||||
if (s_HandsPackageAddRequest.Error != null)
|
||||
{
|
||||
Debug.LogError($"Package installation error: {s_HandsPackageAddRequest.Error}: {s_HandsPackageAddRequest.Error.message}");
|
||||
}
|
||||
},
|
||||
FixItAutomatic = true,
|
||||
Error = true,
|
||||
},
|
||||
new BuildValidationRule
|
||||
{
|
||||
IsRuleEnabled = () => PackageVersionUtility.IsPackageInstalled("com.unity.xr.hands"),
|
||||
Message = $"[{k_SampleDisplayName}] {k_HandVisualizerSampleName} sample from XR Hands (com.unity.xr.hands) package must be imported or updated to use this sample.",
|
||||
Category = k_Category,
|
||||
CheckPredicate = () => TryFindSample("com.unity.xr.hands", string.Empty, k_HandVisualizerSampleName, out var sample) && sample.isImported,
|
||||
FixIt = () =>
|
||||
{
|
||||
if (TryFindSample("com.unity.xr.hands", string.Empty, k_HandVisualizerSampleName, out var sample))
|
||||
{
|
||||
sample.Import(Sample.ImportOptions.OverridePreviousImports);
|
||||
}
|
||||
},
|
||||
FixItAutomatic = true,
|
||||
Error = true,
|
||||
},
|
||||
new BuildValidationRule
|
||||
{
|
||||
Message = $"[{k_SampleDisplayName}] {k_StarterAssetsSampleName} sample from XR Interaction Toolkit (com.unity.xr.interaction.toolkit) package must be imported or updated to use this sample.",
|
||||
Category = k_Category,
|
||||
CheckPredicate = () => TryFindSample("com.unity.xr.interaction.toolkit", string.Empty, k_StarterAssetsSampleName, out var sample) && sample.isImported,
|
||||
FixIt = () =>
|
||||
{
|
||||
if (TryFindSample("com.unity.xr.interaction.toolkit", string.Empty, k_StarterAssetsSampleName, out var sample))
|
||||
{
|
||||
sample.Import(Sample.ImportOptions.OverridePreviousImports);
|
||||
}
|
||||
},
|
||||
FixItAutomatic = true,
|
||||
Error = true,
|
||||
},
|
||||
};
|
||||
|
||||
static AddRequest s_HandsPackageAddRequest;
|
||||
|
||||
[InitializeOnLoadMethod]
|
||||
static void RegisterProjectValidationRules()
|
||||
{
|
||||
foreach (var buildTargetGroup in s_BuildTargetGroups)
|
||||
{
|
||||
BuildValidator.AddRules(buildTargetGroup, s_BuildValidationRules);
|
||||
}
|
||||
}
|
||||
|
||||
static bool TryFindSample(string packageName, string packageVersion, string sampleDisplayName, out Sample sample)
|
||||
{
|
||||
sample = default;
|
||||
|
||||
var packageSamples = Sample.FindByPackage(packageName, packageVersion);
|
||||
if (packageSamples == null)
|
||||
{
|
||||
Debug.LogError($"Couldn't find samples of the {ToString(packageName, packageVersion)} package; aborting project validation rule.");
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var packageSample in packageSamples)
|
||||
{
|
||||
if (packageSample.displayName == sampleDisplayName)
|
||||
{
|
||||
sample = packageSample;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError($"Couldn't find {sampleDisplayName} sample in the {ToString(packageName, packageVersion)} package; aborting project validation rule.");
|
||||
return false;
|
||||
}
|
||||
|
||||
static string ToString(string packageName, string packageVersion)
|
||||
{
|
||||
return string.IsNullOrEmpty(packageVersion) ? packageName : $"{packageName}@{packageVersion}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0deb305527bf17143801528616ee4f73
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Unity.XR.Interaction.Toolkit.Samples.Hands.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:dc960734dc080426fa6612f1c5fe95f3",
|
||||
"GUID:4ddd23ea56a3a40f0aa0036d1624a53e"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec10eb674fe33dc418851b064a84acc4
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user