clean project

This commit is contained in:
Helar Jaadla
2022-03-07 17:52:41 +02:00
parent a174b45bd2
commit cbeb10ec35
5100 changed files with 837159 additions and 0 deletions

View File

@@ -0,0 +1,114 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using Oculus.Interaction.Input;
using UnityEditor;
using UnityEngine;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System;
namespace Oculus.Interaction.HandPosing.Visuals.Editor
{
[CustomEditor(typeof(HandPuppet))]
public class HandPuppetEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
HandPuppet puppet = target as HandPuppet;
if (GUILayout.Button("Auto-Assign Bones"))
{
SkinnedMeshRenderer skinnedHand = puppet.GetComponentInChildren<SkinnedMeshRenderer>();
if (skinnedHand != null)
{
SetPrivateValue(puppet, "_jointMaps", AutoAsignBones(skinnedHand));
}
}
}
private List<HandJointMap> AutoAsignBones(SkinnedMeshRenderer skinnedHand)
{
List<HandJointMap> maps = new List<HandJointMap>();
Transform root = skinnedHand.rootBone;
Regex regEx = new Regex(@"Hand(\w*)(\d)");
foreach (var bone in FingersMetadata.HAND_JOINT_IDS)
{
Match match = regEx.Match(bone.ToString());
if (match != Match.Empty)
{
string boneName = match.Groups[1].Value.ToLower();
string boneNumber = match.Groups[2].Value;
Transform skinnedBone = RecursiveSearchForChildrenContainingPattern(root, "col", boneName, boneNumber);
if (skinnedBone != null)
{
maps.Add(new HandJointMap()
{
id = bone,
transform = skinnedBone,
rotationOffset = Vector3.zero
});
}
}
}
return maps;
}
private Transform RecursiveSearchForChildrenContainingPattern(Transform root, string ignorePattern, params string[] args)
{
if (root == null)
{
return null;
}
for (int i = 0; i < root.childCount; i++)
{
Transform child = root.GetChild(i);
string childName = child.name.ToLower();
bool shouldCheck = string.IsNullOrEmpty(ignorePattern)|| !childName.Contains(ignorePattern);
if (shouldCheck)
{
bool containsAllArgs = args.All(a => childName.Contains(a));
Transform result = containsAllArgs ? child
: RecursiveSearchForChildrenContainingPattern(child, ignorePattern, args);
if (result != null)
{
return result;
}
}
}
return null;
}
private static void SetPrivateValue(object instance, string fieldName, object value)
{
FieldInfo fieldData = GetPrivateField(instance, fieldName);
fieldData.SetValue(instance, value);
}
private static FieldInfo GetPrivateField(object instance, string fieldName)
{
Type type = instance.GetType();
FieldInfo fieldData = null;
while (type != null && fieldData == null)
{
fieldData = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
type = type.BaseType;
}
return fieldData;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb714303644f5c343bd2c80559c02856
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: