Restructure to match recommended Unity Package layout

This commit is contained in:
Pascal Serrarens 2022-01-12 10:48:35 +01:00
parent 65d907d67e
commit 3efd153e9a
1552 changed files with 470697 additions and 0 deletions

5
Assets/Gizmos.meta Normal file
View File

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: db67ac655d8de824194f587deecafb3c
folderAsset: yes
DefaultImporter:
userData:

BIN
Assets/Gizmos/Bolt Icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,128 @@
fileFormatVersion: 2
guid: 1abf0ef6bcd6f4d33852c878c3400bc4
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 5
maxTextureSize: 256
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 256
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -0,0 +1,68 @@
fileFormatVersion: 2
guid: e73281d20dc4cb44bb739de2324974c2
timeCreated: 1490777312
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 1
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 5
maxTextureSize: 64
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 64
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

View File

@ -0,0 +1,68 @@
fileFormatVersion: 2
guid: b0fe1c764f0725444ab37125d3fc639c
timeCreated: 1490777312
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 1
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 5
maxTextureSize: 64
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 64
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 69afdacd3130b2449849f52e367dd2af
folderAsset: yes
timeCreated: 1559834442
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0381babeea008694481b0d1bfbb43948
folderAsset: yes
timeCreated: 1559834447
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

View File

@ -0,0 +1,68 @@
fileFormatVersion: 2
guid: bd69f2f608bae8348b956c4dbde76eb6
timeCreated: 1534772738
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

View File

@ -0,0 +1,68 @@
fileFormatVersion: 2
guid: edbb592ddbf8afa40b8e7aedae3b7d7a
timeCreated: 1534339930
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: f728493f9ebb2324d94581b928975c04
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

Binary file not shown.

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: 7390251e5bc320f4abea3501d907f3e3
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

Binary file not shown.

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: 846171814b98d1d48afa7805037eb0bc
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

Binary file not shown.

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: 4681a9805673831459ed595c2dc402d6
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

Binary file not shown.

View File

@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: dd021173169ae0c45840a63894bc27c0
TextureImporter:
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e3bc00eee8032a4c94fa915414f8cdf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ee1b6481cc8b2bd4b903abd0fa62d76b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3f7bdcfbd3aabb94ab76f09fa2083474
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0e21e875c1037294faff6e238111315b
timeCreated: 1534854189
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 46777292a3b508143b6a4513005097ad
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,73 @@
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
namespace Passer.Humanoid {
public class PoseEvent_Editor : Event_Editor {
public static void EventInspector(
SerializedProperty eventSourceProp, PoseEventList eventSource,
ref int selectedEventSourceIx, ref int selectedEventIx) {
//UnityEventBase unityEventBase = eventSource.events[selectedEventIx].GetUnityEventBase();
EventInspector(eventSourceProp, ref selectedEventSourceIx, ref selectedEventIx,
PoseMethodCheck, InitPoseEvent);
}
protected static void InitPoseEvent(SerializedProperty eventProp) {
}
protected static bool PoseMethodCheck(MethodInfo method, out string label) {
ParameterInfo[] parameters = method.GetParameters();
if (parameters.Length == 0 && method.ReturnType == typeof(void)) {
label = method.Name + " ()";
return true;
}
else if (parameters.Length == 1 && (
parameters[0].ParameterType == typeof(bool) ||
parameters[0].ParameterType == typeof(Pose)
)) {
label = method.Name + " (" + parameters[0].ParameterType.Name + ")";
return true;
}
label = "";
return false;
}
public static void DetailsInspector(SerializedProperty eventProp, string label) {
if (eventProp == null)
return;
DetailsTypeInspector(eventProp);
PoseDetailsInspector(eventProp, label);
}
protected static SerializedProperty DetailsTypeInspector(SerializedProperty eventProp) {
GUIContent text = new GUIContent(
"Event Type",
"Never: the function is never called\n" +
"OnStart: when the Pose becomes non-null\n" +
"OnEnd: when the Pose becomes null\n" +
"WhileActive: while Pose is non-null\n" +
"WhileInactive: while Pose is null\n" +
"OnChange: when the Pose changes\n" +
"Continuous: the function is called for every frame"
);
SerializedProperty eventTypeProp = eventProp.FindPropertyRelative("eventType");
eventTypeProp.intValue = (int)(EventHandler.Type)EditorGUILayout.EnumPopup(text, (EventHandler.Type)eventTypeProp.intValue);
return eventTypeProp;
}
protected static void PoseDetailsInspector(SerializedProperty eventProp, string label) {
SerializedProperty poseEventProp = eventProp.FindPropertyRelative("poseEvent");
EditorGUILayout.PropertyField(poseEventProp, new GUIContent("Pose"));
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 38cd88a9439142a4da4900d6fad80ee6
timeCreated: 1551348784
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4dbe76052d1e54c4a99e672f6389fae1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using UnityEngine;
using UnityEditor;
namespace Passer.Humanoid {
using Passer.Tracking;
[CustomEditor(typeof(RealWorldConfiguration))]
public class RealWorldConfiguration_Editor : Editor {
public override void OnInspectorGUI() {
serializedObject.Update();
SerializedProperty trackerList = serializedObject.FindProperty("trackers");
for (int i = 0; i < trackerList.arraySize; i++) {
SerializedProperty trackerProp = trackerList.GetArrayElementAtIndex(i);
TrackingSpaceInspector(trackerProp);
}
serializedObject.ApplyModifiedProperties();
}
bool foldout = true;
protected virtual void TrackingSpaceInspector(SerializedProperty trackerProp) {
SerializedProperty trackerIdProp = trackerProp.FindPropertyRelative("trackerId");
TrackerId trackerId = (TrackerId) trackerIdProp.intValue;
foldout = EditorGUILayout.Foldout(foldout, trackerId.ToString());
if (foldout) {
EditorGUI.indentLevel++;
SerializedProperty positionProp = trackerProp.FindPropertyRelative("position");
positionProp.vector3Value = EditorGUILayout.Vector3Field("Position", positionProp.vector3Value);
SerializedProperty rotationProp = trackerProp.FindPropertyRelative("rotation");
Vector3 angles = rotationProp.quaternionValue.eulerAngles;
angles = EditorGUILayout.Vector3Field("Rotation", angles);
rotationProp.quaternionValue = Quaternion.Euler(angles);
EditorGUI.indentLevel--;
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fec146cec5c169f44bb2a27991f924b3
timeCreated: 1562138586
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 57f31699b97d4cb4e92cbd741595daea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,184 @@
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Passer.Humanoid {
using Passer.Tracking;
public class UnityXR_Editor : Tracker_Editor {
#if pUNITYXR
#region Tracker
public class TrackerProps : HumanoidControl_Editor.HumanoidTrackerProps {
#if hOCHAND
readonly private SerializedProperty oculusHandTrackingProp;
#endif
#if hVIVEHAND
readonly private SerializedProperty viveHandTrackingProp;
#endif
public TrackerProps(SerializedObject serializedObject, HumanoidControl_Editor.HumanoidTargetObjs targetObjs, UnityXRTracker _unityXR)
: base(serializedObject, targetObjs, _unityXR, nameof(HumanoidControl.unityXR)) {
tracker = _unityXR;
#if hOCHAND
oculusHandTrackingProp = serializedObject.FindProperty("unityXR.oculusHandTracking");
CheckQuestManifest();
#endif
#if hVIVEHAND
viveHandTrackingProp = serializedObject.FindProperty("unityXR.viveHandTracking");
#endif
}
public override void Inspector(HumanoidControl humanoid) {
Inspector(humanoid, "Unity XR");
if (enabledProp.boolValue) {
EditorGUI.indentLevel++;
TrackerInspector(humanoid, humanoid.unityXR);
HandTrackingInspector(humanoid);
EditorGUI.indentLevel--;
}
}
protected void HandTrackingInspector(HumanoidControl humanoid) {
OculusHandTrackingInspector();
ViveHandTrackingInspector(humanoid);
}
protected void OculusHandTrackingInspector() {
#if hOCHAND
GUIContent labelText = new GUIContent(
"Oculus Hand Tracking",
"Enables hand tracking on the Oculus Quest"
);
oculusHandTrackingProp.boolValue = EditorGUILayout.ToggleLeft(labelText, oculusHandTrackingProp.boolValue);
#endif
}
protected virtual void CheckQuestManifest() {
string manifestPath = Application.dataPath + "/Plugins/Android/AndroidManifest.xml";
FileInfo fileInfo = new FileInfo(manifestPath);
fileInfo.Directory.Create();
bool manifestAvailable = File.Exists(manifestPath);
if (manifestAvailable)
return;
string humanoidPath = Configuration_Editor.FindHumanoidFolder();
string questManifestPath = Application.dataPath + humanoidPath + "Extensions/Oculus/QuestManifest.xml";
File.Copy(questManifestPath, manifestPath);
}
protected void ViveHandTrackingInspector(HumanoidControl humanoid) {
#if hVIVEHAND
GUIContent labelText = new GUIContent(
"Vive Hand Tracking",
"Enables hand tracking on the HTC Vive"
);
viveHandTrackingProp.boolValue = EditorGUILayout.ToggleLeft(labelText, viveHandTrackingProp.boolValue);
// When using vive hand tracking, the GestureProvider should be added to the UnityXR component
// before the scene starts. So we need to add it in the edito
// and we need to have the unityXR component in the scene
if (viveHandTrackingProp.boolValue == true) {
humanoid.unityXR.CheckTracker(humanoid, UnityXR.Get);
ViveHandSkeleton.CheckGestureProvider(humanoid.unityXR.trackerComponent);
}
#endif
}
}
#endregion
#region Head
public class HeadTargetProps : HeadTarget_Editor.TargetProps {
readonly SerializedProperty hmdProp;
public HeadTargetProps(SerializedObject serializedObject, HeadTarget headTarget)
: base(serializedObject, headTarget.unityXR, headTarget, nameof(HeadTarget.unityXR)) {
hmdProp = serializedObject.FindProperty(nameof(HeadTarget.unityXR) + ".hmd");
}
public override void Inspector() {
if (!headTarget.humanoid.unityXR.enabled)
return;
enabledProp.boolValue = HumanoidTarget_Editor.ControllerInspector(headTarget.unityXR, headTarget);
headTarget.unityXR.enabled = enabledProp.boolValue;
if (enabledProp.boolValue) {
EditorGUI.indentLevel++;
if (headTarget.unityXR.hmd == null) {
// Hmd does not exist
using (new EditorGUILayout.HorizontalScope()) {
EditorGUILayout.LabelField("Hmd", GUILayout.Width(120));
if (GUILayout.Button("Show")) {
headTarget.unityXR.CheckSensor(headTarget);
}
}
}
else
hmdProp.objectReferenceValue = (UnityXRHmd)EditorGUILayout.ObjectField("Hmd", headTarget.unityXR.hmd, typeof(UnityXRHmd), true);
EditorGUI.indentLevel--;
}
else
headTarget.unityXR.CheckSensor(headTarget);
}
}
#endregion
#region Hand
public class HandTargetProps : HandTarget_Editor.TargetProps {
SerializedProperty controllerProp;
public HandTargetProps(SerializedObject serializedObject, HandTarget handTarget)
: base(serializedObject, handTarget.unityXR, handTarget, "unityXR") {
controllerProp = serializedObject.FindProperty("unityXR.controller");
}
public override void Inspector() {
if (!handTarget.humanoid.unityXR.enabled)
return;
enabledProp.boolValue = HumanoidTarget_Editor.ControllerInspector(handTarget.unityXR, handTarget);
handTarget.unityXR.enabled = enabledProp.boolValue;
if (enabledProp.boolValue) {
EditorGUI.indentLevel++;
if (handTarget.unityXR.controller == null) {
// Controller does not exist
using (new EditorGUILayout.HorizontalScope()) {
EditorGUILayout.LabelField("Controller", GUILayout.Width(120));
if (GUILayout.Button("Show")) {
handTarget.unityXR.CheckSensor(handTarget);
}
}
}
else
controllerProp.objectReferenceValue = (UnityXRController)EditorGUILayout.ObjectField("Controller", controllerProp.objectReferenceValue, typeof(UnityXRController), true);
EditorGUI.indentLevel--;
}
else
handTarget.unityXR.CheckSensor(handTarget);
}
}
#endregion
#endif
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7b268ac19ecf09444b33a5c00674eec9
timeCreated: 1453541563
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,158 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Passer.Humanoid {
/// <summary>
/// Sets preferences for \ref Humanoid "Humanoid Control"
/// </summary>
///
/// The preferences can be accessed by the Edit->Preferences... menu.
///
/// \image html HumanoidPreferences.png
///
/// * SteamVR Support, enables support for SteamVR devices beyound Unity XR (VR, Plus, Pro)
/// * Vive Tracker Support, enables support for Vive Trackers (Plus, Pro)
/// * Leap Motion Support, enables support for Leap Motion (Plus, Pro)
/// * Kinect 1 Support, enables support for Microsoft Kinect 360/Kinect for Windows (Plus, Pro)
/// * Kinect 2 Support, enables support for Microsoft Kinect 2 (Plus, Pro)
/// * Azure Kinect Support, enables support for Azure Kinect (Plus, Pro)
/// * Orbbec Astra Support, enables support for Orbbec Astra (Plus, Pro)
/// * Hydra Support, enables support for Razer Hydra (Pro)
/// * Tobii Support, enables support for Tobii desktop eye tracking (Pro)
/// * Perception Neuron Support, enables support for Perception Neuron (Pro)
/// * OptiTrack Support, enables support for OptiTrack (Pro)
/// * Antilatency Support, enables support for Antilatency (Pro)
///
/// * The Testing Visitor selects which Visitor Scene will be used when a Site is started in Play mode.
///
[System.Serializable]
public class HumanoidPreferences : ScriptableObject {
public static bool help = false;
public const string settingsPath = "Assets/Passer/Humanoid/HumanoidPreferences.asset";
public Configuration configuration;
internal static HumanoidPreferences GetOrCreateSettings() {
string humanoidPath = Configuration_Editor.FindHumanoidFolder();
humanoidPath = humanoidPath.Substring(0, humanoidPath.Length - 1); // strip last /
humanoidPath = humanoidPath.Substring(0, humanoidPath.LastIndexOf('/') + 1); // strip Scripts;
string settingsPath = "Assets" + humanoidPath + "HumanoidPreferences.asset";
HumanoidPreferences settings = AssetDatabase.LoadAssetAtPath<HumanoidPreferences>(settingsPath);
SerializedObject serializedSettings = new SerializedObject(settings);
if (settings == null) {
settings = CreateInstance<HumanoidPreferences>();
AssetDatabase.CreateAsset(settings, settingsPath);
}
if (settings.configuration == null) {
string configurationString = EditorPrefs.GetString("HumanoidConfigurationKey", "DefaultConfiguration");
Configuration configuration = Configuration_Editor.LoadConfiguration(configurationString);
if (configuration == null) {
configurationString = "DefaultConfiguration";
Configuration_Editor.LoadConfiguration(configurationString);
if (configuration == null) {
Debug.Log("Created new Default Configuration");
// Create new Default Configuration
configuration = CreateInstance<Configuration>();
string path = "Assets" + humanoidPath + configurationString + ".asset";
AssetDatabase.CreateAsset(configuration, path);
AssetDatabase.SaveAssets();
}
}
SerializedProperty configurationProp = serializedSettings.FindProperty("configuration");
configurationProp.objectReferenceValue = configuration;
EditorUtility.SetDirty(settings);
}
serializedSettings.ApplyModifiedProperties();
return (HumanoidPreferences)serializedSettings.targetObject;//settings;
}
internal static SerializedObject GetOrCreateSerializedSettings() {
string humanoidPath = Configuration_Editor.FindHumanoidFolder();
humanoidPath = humanoidPath.Substring(0, humanoidPath.Length - 1); // strip last /
humanoidPath = humanoidPath.Substring(0, humanoidPath.LastIndexOf('/') + 1); // strip Scripts;
string settingsPath = "Assets" + humanoidPath + "HumanoidPreferences.asset";
HumanoidPreferences settings = AssetDatabase.LoadAssetAtPath<HumanoidPreferences>(settingsPath);
if (settings == null) {
Debug.Log("Created new Settings");
settings = CreateInstance<HumanoidPreferences>();
AssetDatabase.CreateAsset(settings, settingsPath);
}
if (settings.configuration == null) {
Debug.Log("Settings Configuration is not set");
string configurationString = "DefaultConfiguration";
Configuration configuration = Configuration_Editor.LoadConfiguration(configurationString);
if (configuration == null) {
configurationString = "DefaultConfiguration";
Configuration_Editor.LoadConfiguration(configurationString);
if (configuration == null) {
Debug.Log("Created new Default Configuration");
// Create new Default Configuration
configuration = CreateInstance<Configuration>();
string path = "Assets" + humanoidPath + configurationString + ".asset";
AssetDatabase.CreateAsset(configuration, path);
AssetDatabase.SaveAssets();
}
}
settings.configuration = configuration;
}
SerializedObject serializedSettings = new SerializedObject(settings);
return serializedSettings;
}
}
static class HumanoidPreferencesIMGUIRegister {
public static bool reload;
[SettingsProvider]
public static SettingsProvider CreateHumanoidSettingsProvider() {
var provider = new SettingsProvider("Preferences/HumanoidControlSettings", SettingsScope.User) {
label = "Humanoid Control",
guiHandler = (searchContext) => {
SerializedObject serializedSettings = HumanoidPreferences.GetOrCreateSerializedSettings();
SerializedProperty configurationProp = serializedSettings.FindProperty("configuration");
Configuration oldConfiguration = (Configuration)configurationProp.objectReferenceValue;
configurationProp.objectReferenceValue = EditorGUILayout.ObjectField("Configuration", configurationProp.objectReferenceValue, typeof(Configuration), false);
SerializedObject serializedConfiguration = new SerializedObject(configurationProp.objectReferenceValue);
bool anyChanged = false;
anyChanged |= (configurationProp.objectReferenceValue != oldConfiguration);
anyChanged |= Configuration_Editor.ConfigurationGUI(serializedConfiguration);
serializedConfiguration.ApplyModifiedProperties();
serializedSettings.ApplyModifiedProperties();
Configuration_Editor.CheckExtensions((Configuration)configurationProp.objectReferenceValue);
if (reload) {
reload = false;
#if hUNET
OnLoadHumanoidPlayerUnet.CheckHumanoidPlayer();
#endif
#if hPHOTON1 || hPHOTON2
OnLoadHumanoidPlayerPun.CheckHumanoidPlayer();
#endif
#if hBOLT
OnLoadHumanoidPlayerBolt.CheckHumanoidPlayer();
#endif
#if hMIRROR
OnLoadHumanoidPlayerMirror.CheckHumanoidPlayer();
#endif
}
},
keywords = new HashSet<string>(
new[] { "Humanoid", "Oculus", "SteamVR" }
)
};
return provider;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6021fe10956d4fe4e847551130851c03
timeCreated: 1559823791
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 505c20d3b5eb39c44b642561b71057c2
folderAsset: yes
DefaultImporter:
userData:

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

View File

@ -0,0 +1,47 @@
fileFormatVersion: 2
guid: e541a1c70a1d7c3439b0071a59508460
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

View File

@ -0,0 +1,47 @@
fileFormatVersion: 2
guid: b9f0c4cc30a3a8e459af3607eba66591
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0e47f9fdcd1fd87458f81fd6e36416bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
using UnityEditor;
namespace Passer.Humanoid {
using Pawn;
public class HumanoidNetworking_Editor : Editor {
protected virtual void SyncFingerSwingInspector() {
SerializedProperty syncFingerSwingProp = serializedObject.FindProperty("_syncFingerSwing");
syncFingerSwingProp.boolValue = EditorGUILayout.Toggle("Sync Finger Swing", syncFingerSwingProp.boolValue);
}
protected virtual void SyncTrackingInspector() {
SerializedProperty syncTrackingProp = serializedObject.FindProperty("_syncTracking");
syncTrackingProp.boolValue = EditorGUILayout.Toggle("Sync Tracking Space", syncTrackingProp.boolValue);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 534ed79b66bde8d459759734a5d468f7
timeCreated: 1504014208
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,83 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
#if !UNITY_2019_1_OR_NEWER
using UnityEngine.Networking;
#endif
namespace Passer.Humanoid {
[InitializeOnLoad]
public class OnLoadHumanoidPlayer {
static OnLoadHumanoidPlayer() {
HumanoidPreferencesIMGUIRegister.reload = true;
}
public static string GetHumanoidPlayerPrefabPath() {
string humanoidPath = Configuration_Editor.FindHumanoidFolder();
string prefabPathWithoutScripts = humanoidPath.Substring(0, humanoidPath.Length - 8);
string prefabPath = "Assets" + prefabPathWithoutScripts + "Prefabs/Networking/Resources/HumanoidPlayer.prefab";
return prefabPath;
}
public static GameObject GetHumanoidPlayerPrefab(string prefabPath) {
GameObject prefab = PrefabUtility.LoadPrefabContents(prefabPath);
return prefab;
}
public static void UpdateHumanoidPrefab(GameObject prefab, string prefabPath) {
if (!Application.isPlaying) {
Debug.Log("UpdateHumanoidPrefab " + Application.isFocused + " " + Application.isBatchMode + " " + Application.isEditor);
if (Application.isFocused && !Application.isBatchMode && Application.isEditor) {
Debug.Log("delaying save " + prefab);
HumanoidPlayer_Editor.prefabsToSave.Push(prefab);
HumanoidPlayer_Editor.prefabPaths.Push(prefabPath);
EditorApplication.delayCall += HumanoidPlayer_Editor.DelayedSave;
}
else {
Debug.Log("updating " + prefab);
PrefabUtility.SaveAsPrefabAsset(prefab, prefabPath);
PrefabUtility.UnloadPrefabContents(prefab);
}
}
}
[CustomEditor(typeof(HumanoidPlayer))]
public class HumanoidPlayer_Editor : HumanoidNetworking_Editor {
#if hNW_UNET
public override void OnInspectorGUI() {
serializedObject.Update();
SendRateInspector();
DebugLevelInspector();
SmoothingInspector();
SyncFingerSwingInspector();
CreateLocalRemotesInspector();
SyncTrackingInspector();
serializedObject.ApplyModifiedProperties();
}
#endif
public static Stack<GameObject> prefabsToSave = new Stack<GameObject>();
public static Stack<string> prefabPaths = new Stack<string>();
//private void OnSceneGUI() {
public static void DelayedSave() {
if (Application.isPlaying)
return;
if (prefabsToSave.Count > 0) {
GameObject prefab = prefabsToSave.Pop();
Debug.Log("Delayed save of prefab " + prefab);
string path = prefabPaths.Pop();
PrefabUtility.SaveAsPrefabAsset(prefab, path);
PrefabUtility.UnloadPrefabContents(prefab);
}
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ff6f5bfdd54b0a84da3fa2464feaf06e
timeCreated: 1563434259
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;
namespace Passer.Humanoid {
[CustomEditor(typeof(NetworkingSpawner))]
public class NetworkingSpawner_Editor : NetworkingStarter_Editor {
private SerializedProperty humanoidPrefabProp;
private SerializedProperty spawnPointsProp;
private SerializedProperty spawnMethodProp;
public override void OnEnable() {
base.OnEnable();
humanoidPrefabProp = serializedObject.FindProperty("humanoidPrefab");
spawnPointsProp = serializedObject.FindProperty("spawnPoints");
spawnMethodProp = serializedObject.FindProperty("spawnMethod");
}
public override void OnInspectorGUI() {
base.OnInspectorGUI();
GUIContent label;
label = new GUIContent(
"Humanoid Prefab",
"The Humanoid Prefab that will be spawned when networking has started"
);
EditorGUILayout.PropertyField(humanoidPrefabProp, label);
label = new GUIContent(
"Spawn Points",
"The possible spawning points for the Humanoid"
);
EditorGUILayout.PropertyField(spawnPointsProp, label, true);
label = new GUIContent(
"Spawn Mode",
"The order in which the spawn points are chosen"
);
EditorGUILayout.PropertyField(spawnMethodProp, label);
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a432ba4f8b031e84ebae8a3ad39724f3
timeCreated: 1519718995
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,118 @@
using UnityEditor;
using UnityEngine;
namespace Passer.Humanoid {
using Passer.Tracking;
[HelpURL("http://passervr.com/documentation/humanoid-control/object-tracker/")]
[CustomEditor(typeof(ObjectTracker))]
public class ObjectTracker_Editor : Editor {
public enum Side {
Left,
Right
}
protected ObjectTracker objectTracker;
#region Enable
public void OnEnable() {
objectTracker = (ObjectTracker)target;
//if (objectTracker.targetTransform == null)
// objectTracker.targetTransform = objectTracker.transform;
// HumanoidControl humanoid = objectTracker.humanoid;
// if (humanoid != null) {
//#if hOCULUS
// objectTracker.oculusTouch.tracker = humanoid.oculus;
//#endif
// }
//#if hOCULUS
// if (objectTracker.oculusTouch.target == null)
// objectTracker.oculusTouch.target = objectTracker;
//#endif
}
#endregion
#region Disable
public void OnDisable() {
if (!Application.isPlaying) {
serializedObject.Update();
SetSensor2Object();
serializedObject.ApplyModifiedProperties();
}
}
protected void SetSensor2Object() {
SensorComponent sensorComponent = objectTracker.sensorComponent;
if (sensorComponent == null)
return;
SerializedProperty sensor2ObjectRotationProp = serializedObject.FindProperty("sensor2ObjectRotation");
sensor2ObjectRotationProp.quaternionValue = Quaternion.Inverse(sensorComponent.transform.rotation) * objectTracker.transform.rotation;
SerializedProperty sensor2ObjectPositionProp = serializedObject.FindProperty("sensor2ObjectPosition");
sensor2ObjectPositionProp.vector3Value = -InverseTransformPointUnscaled(objectTracker.transform, sensorComponent.transform.position);
}
private static Vector3 InverseTransformPointUnscaled(Transform transform, Vector3 position) {
var worldToLocalMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one).inverse;
return worldToLocalMatrix.MultiplyPoint3x4(position);
}
#endregion
#region Inspector
public override void OnInspectorGUI() {
ObjectTracker objectTracker = (ObjectTracker)target;
serializedObject.Update();
SerializedProperty sensorComponentProp = serializedObject.FindProperty("sensorComponent");
sensorComponentProp.objectReferenceValue = (SensorComponent)EditorGUILayout.ObjectField("Sensor Component", sensorComponentProp.objectReferenceValue, typeof(SensorComponent), true);
Settings(objectTracker);
serializedObject.ApplyModifiedProperties();
}
#region Settings
private static bool showSettings = false;
public static void Settings(ObjectTracker objectTracker) {
showSettings = EditorGUILayout.Foldout(showSettings, "Settings", true);
if (showSettings) {
EditorGUI.indentLevel++;
objectTracker.showRealObjects = EditorGUILayout.Toggle("Show Real Objects", objectTracker.showRealObjects);
ShowTrackers(objectTracker, objectTracker.showRealObjects);
// Work in progress
//objectTracker.physics = EditorGUILayout.Toggle("Physics", objectTracker.physics);
EditorGUI.indentLevel--;
}
}
private static void ShowTrackers(ObjectTracker objectTracker, bool shown) {
objectTracker.ShowTrackers(shown);
}
#endregion
#endregion
#region Scene
//private Vector3 objectPosition;
//private Quaternion objectLocalRotation;
public void OnSceneGUI() {
ObjectTracker objectTracker = (ObjectTracker)target;
//if (!Application.isPlaying)
// objectTracker.UpdateSensorsFromTarget();
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 81fa75314925347479e90858692406b5
timeCreated: 1470140284
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 135f09a133a363a4cbcddb5019d34d3d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
using UnityEditor;
namespace Passer.Humanoid {
[CustomEditor(typeof(BallHandle))]
public class BallHandle_Editor : Handle_Editor {
public override void OnInspectorGUI() {
EditorGUILayout.HelpBox("BallHandle is depreciated, use Handle with Grab Type=Ball Grab instead.", MessageType.Warning);
base.OnInspectorGUI();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5377376e3bb6b534499b7acdc84ea2b0
timeCreated: 1547654508
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
using UnityEditor;
namespace Passer.Humanoid {
[CustomEditor(typeof(BarHandle))]
public class BarHandle_Editor : Handle_Editor {
public override void OnInspectorGUI() {
EditorGUILayout.HelpBox("BarHandle is depreciated, use Handle with Grab Type=Bar Grab instead.", MessageType.Warning);
base.OnInspectorGUI();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6f72951144d0b36449e65bbd06fc6ed4
timeCreated: 1506938796
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dd826f7f2ad395b40b8e26c0347e4985
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1 @@
// This file is intentionally empty

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 61ac78e296f28ed4895d68008f395045
timeCreated: 1515774271
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,322 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Passer;
using Passer.Humanoid.Tracking;
namespace Passer.Humanoid {
[CustomEditor(typeof(Pose))]
public class Pose_Editor : Editor {
private Pose pose;
#region Enable
public void OnEnable() {
pose = (Pose)target;
if (pose.bonePoses == null)
pose.bonePoses = new List<BonePose>();
}
#endregion
#region Disable
public void OnDisable() {
pose.Cleanup();
}
#endregion
private enum Reference {
HumanoidLocal,
BoneLocal
}
#region Inspector
public override void OnInspectorGUI() {
for (int i = 0; i < pose.bonePoses.Count; i++) {
BonePose bonePoses = pose.bonePoses[i];
if (bonePoses == null)
continue;
if (bonePoses.boneRef.type == BoneType.SideBones && bonePoses.boneRef.side == Side.AnySide) {
EditorGUILayout.HelpBox("Configure AnySide like Left Side", MessageType.Info);
}
EditorGUILayout.BeginHorizontal();
bonePoses.boneRef.type = (BoneType)EditorGUILayout.EnumPopup(bonePoses.boneRef.type, GUILayout.Width(159));
Bone oldBoneId = bonePoses.boneRef.boneId;
SideBone oldSideBoneId = bonePoses.boneRef.sideBoneId;
BoneSelector(ref bonePoses.boneRef);
EditorGUILayout.EndHorizontal();
if (bonePoses.boneRef.boneId != oldBoneId || bonePoses.boneRef.sideBoneId != oldSideBoneId)
PresetReferenceBone(bonePoses.boneRef, ref bonePoses.referenceBoneRef);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Reference", GUILayout.MaxWidth(65));
bonePoses.referenceBoneRef.type = (BoneType)EditorGUILayout.EnumPopup(bonePoses.referenceBoneRef.type, GUILayout.Width(90));
BoneSelector(ref bonePoses.referenceBoneRef); EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel++;
EditorGUILayout.BeginHorizontal();
bonePoses.setTranslation = EditorGUILayout.ToggleLeft("Translation", bonePoses.setTranslation, GUILayout.MaxWidth(131));
if (bonePoses.setTranslation)
bonePoses.translation = EditorGUILayout.Vector3Field("", bonePoses.translation);
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
bonePoses.setRotation = EditorGUILayout.ToggleLeft("Rotation", bonePoses.setRotation, GUILayout.MaxWidth(131));
if (bonePoses.setRotation) {
Vector3 eulerAngles = EditorGUILayout.Vector3Field("", bonePoses.rotation.eulerAngles);
if (eulerAngles != bonePoses.rotation.eulerAngles)
bonePoses.rotation.eulerAngles = eulerAngles;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
bonePoses.setScale = EditorGUILayout.ToggleLeft("Scale", bonePoses.setScale, GUILayout.MaxWidth(131));
if (bonePoses.setScale)
bonePoses.scale = EditorGUILayout.Vector3Field("", bonePoses.scale);
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
Buttons();
EditorUtility.SetDirty(pose);
}
private void PresetReferenceBone(BoneReference bone, ref BoneReference referenceBone) {
if (referenceBone.boneId != Bone.None)
return;
if (bone.isFacialBone)
referenceBone.centerBoneId = CenterBone.Head;
if (bone.isHandBone) {
referenceBone.sideBoneId = SideBone.Hand;
referenceBone.type = BoneType.SideBones;
}
}
private void BoneSelector(ref BoneReference bone) {
switch (bone.type) {
case BoneType.AllBones:
bone.boneId = (Bone)EditorGUILayout.EnumPopup(bone.boneId);
return;
case BoneType.CenterBones:
CenterBone centerBone = (CenterBone)EditorGUILayout.EnumPopup(bone.centerBoneId);
if (centerBone != CenterBone.Unknown)
bone.centerBoneId = centerBone;
return;
case BoneType.SideBones:
if (bone.boneId == Bone.None) {
SideBone sideBoneId = bone.sideBoneId;
bone.sideBoneId = (SideBone)EditorGUILayout.EnumPopup(sideBoneId);
}
else {
bone.sideBoneId = (SideBone)EditorGUILayout.EnumPopup(bone.sideBoneId);
}
bone.side = (Side)EditorGUILayout.EnumPopup(bone.side, GUILayout.Width(80));
return;
case BoneType.FaceBones:
bone.faceBoneId = (FacialBone)EditorGUILayout.EnumPopup(bone.faceBoneId);
return;
default:
return;
}
}
#region Buttons
private void Buttons() {
EditorGUILayout.BeginHorizontal();
AddBoneButton();
ClearAllButton();
EditorGUILayout.EndHorizontal();
}
private void AddBoneButton() {
if (GUILayout.Button("Add Bone")) {
//PoseBone newBone = new PoseBone();
//PoseBone newBone = ScriptableObject.CreateInstance<PoseBone>();
//pose.bones.Add(newBone);
pose.AddBone(Bone.None);
}
}
private void ClearAllButton() {
if (GUILayout.Button("Clear All")) {
pose.bonePoses = new List<BonePose>();
//pose.boneArray = new BonePose[0];
}
}
#endregion
#endregion
public static void PoseMixerInspector(PoseMixer poseMixer, HumanoidControl humanoid, Side side = Side.AnySide) {
int i = 0;
foreach (MixedPose pose in poseMixer.mixedPoses) {
Pose oldPose = pose.pose;
HumanoidPoseInspector(poseMixer, pose, i, humanoid, side);
if (pose.pose != oldPose && pose.pose == null) {
// We deleted a pose, let's undo it's effect
pose.value = 0;
pose.pose = oldPose;
poseMixer.ShowPose(humanoid);
pose.pose = null;
}
i++;
}
EditorGUILayout.BeginHorizontal();
Pose addPose = (Pose)EditorGUILayout.ObjectField(null, typeof(Pose), false, GUILayout.Width(200));
if (addPose != null) {
MixedPose newPose = poseMixer.Add();
newPose.pose = addPose;
}
EditorGUILayout.EndHorizontal();
}
public static MixedPose HumanoidPoseInspector(PoseMixer poseMixer, MixedPose mixedPose, int poseIx, HumanoidControl humanoid, Side side = Side.AnySide) {
EditorGUILayout.BeginHorizontal();
if (poseMixer.poseMode == PoseMixer.PoseMode.Set)
mixedPose.pose = (Pose)EditorGUILayout.ObjectField(mixedPose.pose, typeof(Pose), false, GUILayout.Width(200));
else
mixedPose.pose = (Pose)EditorGUILayout.ObjectField(mixedPose.pose, typeof(Pose), false);
if (mixedPose.pose != null) {
if (mixedPose.isEdited) {
EditorGUILayout.Slider(mixedPose.value, 0, 1);
poseMixer.SetPoseValue(poseIx, 1);
}
else if (poseMixer.poseMode == PoseMixer.PoseMode.Set)
{
float value = EditorGUILayout.Slider(mixedPose.value, 0, 1);
if (value != mixedPose.value) {
poseMixer.SetPoseValue(poseIx, value);
}
}
if (!Application.isPlaying || side == Side.AnySide) {
bool isEdited = EditorGUILayout.Toggle(mixedPose.isEdited, "button", GUILayout.Width(19));
if (mixedPose.isEdited != isEdited)
SceneView.RepaintAll();
mixedPose.isEdited = isEdited;
}
else {
EditorGUILayout.FloatField(mixedPose.score);
}
}
EditorGUILayout.EndHorizontal();
if (mixedPose.isEdited) {
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(" ", GUILayout.Width(200));
mixedPose.additive = EditorGUILayout.ToggleLeft("Additive", mixedPose.additive);
EditorGUILayout.EndHorizontal();
}
return mixedPose;
}
#region Scene
static int boneIndex = -1;
public static void UpdateScene(HumanoidControl humanoid, ITarget target, PoseMixer poseMixer, ref BonePose selectedBone, Side side = Side.AnySide) {
//if (!Application.isPlaying)
// poseMixer.ShowPose(humanoid);
MixedPose currentPose = poseMixer.GetEditedPose();
if (currentPose == null || !currentPose.isEdited) {
UnityEditor.Tools.hidden = false;
return;
}
UnityEditor.Tools.hidden = true;
HumanoidTarget.TargetedBone[] bones = target.GetBones();
int[] controlIds = new int[bones.Length];
Bone[] boneIds = new Bone[bones.Length];
for (int i = 0; i < bones.Length; i++) {
if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null)
continue;
Handles.FreeMoveHandle(bones[i].bone.transform.position, bones[i].bone.transform.rotation, 0.002F, Vector3.zero, DotHandleCapSaveID);
controlIds[i] = lastControlID;
boneIds[i] = bones[i].boneId;
}
FindSelectedHandle(controlIds, boneIds, ref boneIndex);
if (boneIndex == -1)
return;
HumanoidTarget.TargetedBone targetedBone = FindTargetedBone(bones, boneIds[boneIndex]);
if (targetedBone == null || targetedBone.bone.transform == null)
return;
GUIStyle style = new GUIStyle();
style.normal.textColor = Color.yellow;
Handles.Label(targetedBone.bone.transform.position + Vector3.up * 0.01F, targetedBone.name, style);
Handles.color = Color.white;
switch (UnityEditor.Tools.current) {
case Tool.Move:
selectedBone = currentPose.pose.CheckBone(boneIds[boneIndex], true);
Vector3 handlePosition = Handles.PositionHandle(targetedBone.target.transform.position, targetedBone.bone.transform.rotation);
targetedBone.target.transform.position = handlePosition;
selectedBone.setTranslation = true;
selectedBone.SetReferenceLocal(humanoid, side);
selectedBone.UpdateTranslation(humanoid, side);
break;
case Tool.Rotate:
selectedBone = currentPose.pose.CheckBone(boneIds[boneIndex], true);
Quaternion handleRotation = Handles.RotationHandle(targetedBone.target.transform.rotation, targetedBone.bone.transform.position);
targetedBone.target.transform.rotation = handleRotation;
selectedBone.setRotation = true;
selectedBone.SetReferenceLocal(humanoid, side);
selectedBone.UpdateRotation(humanoid, side);
break;
case Tool.Scale:
//Handles.ScaleHandle(selectedBone.transform.localScale, selectedBone.transform.position, selectedBone.transform.rotation, HandleUtility.GetHandleSize(selectedBone.transform.position));
// need to all morphScale first...
break;
}
Handles.BeginGUI();
ResetBoneButton(selectedBone, humanoid);
Handles.EndGUI();
}
private static void ResetBoneButton(BonePose selectedBone, HumanoidControl humanoid) {
if (GUILayout.Button("Reset Bone", GUILayout.Width(100))) {
Debug.Log("Got it to work.");
selectedBone.setRotation = false;
selectedBone.rotation = Quaternion.identity;
HumanoidTarget.TargetedBone targetedBone = humanoid.GetBone(selectedBone.boneRef.boneId);
targetedBone.target.transform.localRotation = selectedBone.rotation;
}
}
private static HumanoidTarget.TargetedBone FindTargetedBone(HumanoidTarget.TargetedBone[] bones, Tracking.Bone boneId) {
foreach (HumanoidTarget.TargetedBone bone in bones) {
if (bone.boneId == boneId)
return bone;
}
return null;
}
static int lastControlID;
public static void DotHandleCapSaveID(int controlID, Vector3 position, Quaternion rotation, float size, EventType et) {
lastControlID = controlID;
Handles.DotHandleCap(controlID, position, rotation, size, et);
}
private static void FindSelectedHandle(int[] controlIds, Tracking.Bone[] boneIds, ref int boneIndex) {
for (int i = 0; i < controlIds.Length; i++) {
if (controlIds[i] != 0 && controlIds[i] == GUIUtility.hotControl) {
boneIndex = i;
return;
}
}
return;
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5ff8acba029085e498aca5aa403685d5
timeCreated: 1515774608
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,35 @@
#if UNITY_EDITOR
using System;
using System.Runtime.InteropServices;
using UnityEditor;
using UnityEngine;
namespace Passer {
using Humanoid;
using Humanoid.Tracking;
using Passer.Tracking;
[InitializeOnLoad]
public class HumanoidConfiguration : MonoBehaviour {
static HumanoidConfiguration() {
//Configuration_Editor.GlobalDefine("pHUMANOID");
#if hLEAP
LeapDevice.LoadDlls();
#endif
#if hORBBEC
AstraDevice.LoadDlls();
#endif
#if hNEURON
NeuronDevice.LoadDlls();
#endif
}
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
// Have we loaded the prefs yet
public static Configuration configuration;
}
}
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 336932db5f7f6174ea2950adf102b57b
timeCreated: 1534854134
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d790c783fecd6d74f88b65be82fb57c0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,605 @@
using UnityEditor;
using UnityEngine;
namespace Passer {
using Humanoid;
[CanEditMultipleObjects]
[CustomEditor(typeof(FootTarget), true)]
public class FootTarget_Editor : Editor {
private FootTarget footTarget;
private HumanoidControl humanoid;
private TargetProps[] allProps;
#region Enable
public void OnEnable() {
footTarget = (FootTarget)target;
if (footTarget.humanoid == null)
footTarget.humanoid = GetHumanoid(footTarget);
humanoid = footTarget.humanoid;
if (humanoid == null)
return;
InitEditors();
footTarget.InitSensors();
InitConfiguration(footTarget);
InitSettings();
InitEvents();
}
private void InitEditors() {
allProps = new TargetProps[] {
#if hOPENVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
new ViveTracker_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hKINECT1
new Kinect1_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hKINECT2
new Kinect2_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hKINECT4
new Kinect4_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hORBBEC
new Astra_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hNEURON
new Neuron_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hOPTITRACK
new Optitrack_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hANTILATENCY
new Antilatency_Editor.FootTargetProps(serializedObject, footTarget),
#endif
#if hCUSTOM
new Custom_Editor.FootTargetProps(serializedObject, footTarget),
#endif
};
}
#endregion
#region Disable
public void OnDisable() {
if (humanoid == null) {
// This target is not connected to a humanoid, so we delete it
DestroyImmediate(footTarget, true);
return;
}
if (!Application.isPlaying) {
SetSensor2Target();
}
}
private void SetSensor2Target() {
foreach (TargetProps props in allProps)
props.SetSensor2Target();
}
#endregion
#region Inspector
public override void OnInspectorGUI() {
if (footTarget == null || humanoid == null)
return;
serializedObject.Update();
ControllerInspectors(footTarget);
ConfigurationInspector(footTarget);
SettingsInspector(footTarget);
EventsInspector();
serializedObject.ApplyModifiedProperties();
UpdateBones(footTarget);
}
public static FootTarget Inspector(FootTarget footTarget, string name) {
if (footTarget == null)
return footTarget;
EditorGUILayout.BeginHorizontal();
Transform defaultTargetTransform = footTarget.GetDefaultTarget(footTarget.humanoid);
Transform targetTransform = footTarget.transform ?? defaultTargetTransform;
GUIContent text = new GUIContent(
name,
"The transform controlling the " + name
);
targetTransform = (Transform)EditorGUILayout.ObjectField(text, targetTransform, typeof(Transform), true);
if (!Application.isPlaying) {
if (targetTransform == defaultTargetTransform && GUILayout.Button("Show", GUILayout.MaxWidth(60))) {
// Call static method CreateTarget on target
footTarget = (FootTarget)footTarget.GetType().GetMethod("CreateTarget").Invoke(null, new object[] { footTarget });
}
else if (targetTransform != footTarget.transform) {
footTarget = (FootTarget)footTarget.GetType().GetMethod("SetTarget").Invoke(null, new object[] { footTarget.humanoid, targetTransform, footTarget.isLeft });
}
}
EditorGUILayout.EndHorizontal();
return footTarget;
}
public static HumanoidControl GetHumanoid(HumanoidTarget target) {
HumanoidControl foundHumanoid = target.transform.GetComponentInParent<HumanoidControl>();
if (foundHumanoid != null)
return foundHumanoid;
HumanoidControl[] humanoids = GameObject.FindObjectsOfType<HumanoidControl>();
for (int i = 0; i < humanoids.Length; i++)
if (humanoids[i].leftFootTarget.transform == target.transform ||
humanoids[i].rightFootTarget.transform == target.transform)
foundHumanoid = humanoids[i];
return foundHumanoid;
}
#region Sensors
private static bool showControllers = true;
private void ControllerInspectors(FootTarget footTarget) {
showControllers = EditorGUILayout.Foldout(showControllers, "Controllers", true);
if (showControllers) {
EditorGUI.indentLevel++;
foreach (TargetProps props in allProps)
props.Inspector();
if (humanoid.animatorEnabled)
footTarget.legAnimator.enabled = EditorGUILayout.ToggleLeft("Procedural Animation", footTarget.legAnimator.enabled, GUILayout.MinWidth(80));
EditorGUI.indentLevel--;
}
}
#endregion
#region Configuration
private void InitConfiguration(FootTarget footTarget) {
if (footTarget.humanoid.avatarRig == null)
return;
InitUpperLegConfiguration(footTarget.upperLeg);
InitLowerLegConfiguration(footTarget.lowerLeg);
InitFootConfiguration(footTarget.foot);
InitToesConfiguration(footTarget.toes);
}
private static bool showConfiguration;
private void ConfigurationInspector(FootTarget footTarget) {
//if (!target.jointLimitations)
// return;
footTarget.RetrieveBones();
showConfiguration = EditorGUILayout.Foldout(showConfiguration, "Configuration", true);
if (showConfiguration) {
EditorGUI.indentLevel++;
UpperLegConfigurationInspector(ref footTarget.upperLeg, footTarget.isLeft);
LowerLegConfigurationInspector(ref footTarget.lowerLeg, footTarget.isLeft);
FootConfigurationInspector(ref footTarget.foot, footTarget.isLeft);
ToesConfigurationInspector(ref footTarget.toes, footTarget.isLeft);
EditorGUI.indentLevel--;
}
}
private void UpdateBones(FootTarget target) {
if (target.humanoid.avatarRig == null)
return;
UpdateUpperLegBones(target.upperLeg);
UpdateLowerLegBones(target.lowerLeg);
UpdateFootBones(target.foot);
UpdateToesBones(target.toes);
}
#region UpperLeg
//private string upperLegXname;
//private SerializedProperty upperLegMinX;
//private SerializedProperty upperLegMaxX;
//private string upperLegYname;
//private SerializedProperty upperLegMinY;
//private SerializedProperty upperLegMaxY;
//private string upperLegZname;
//private SerializedProperty upperLegMinZ;
//private SerializedProperty upperLegMaxZ;
private void InitUpperLegConfiguration(FootTarget.TargetedUpperLegBone upperLeg) {
//if (upperLeg.bone.transform == null)
// return;
//upperLegXname = upperLeg.bone.transform.name + "X";
//upperLegMinX = serializedObject.FindProperty("upperLeg.bone.minAngles.x");
//upperLegMaxX = serializedObject.FindProperty("upperLeg.bone.maxAngles.x");
//upperLegYname = upperLeg.bone.transform.name + "Y";
//upperLegMinY = serializedObject.FindProperty("upperLeg.bone.minAngles.y");
//upperLegMaxY = serializedObject.FindProperty("upperLeg.bone.maxAngles.y");
//upperLegZname = upperLeg.bone.transform.name + "Z";
//upperLegMinZ = serializedObject.FindProperty("upperLeg.bone.minAngles.z");
//upperLegMaxZ = serializedObject.FindProperty("upperLeg.bone.maxAngles.z");
}
private void UpperLegConfigurationInspector(ref FootTarget.TargetedUpperLegBone upperLeg, bool isLeft) {
if (upperLeg.bone.transform != null)
GUI.SetNextControlName(upperLeg.bone.transform.name + "00");
upperLeg.bone.transform = (Transform)EditorGUILayout.ObjectField("Upper Leg Bone", upperLeg.bone.transform, typeof(Transform), true);
if (upperLeg.bone.transform != null) {
EditorGUI.indentLevel++;
upperLeg.bone.jointLimitations = EditorGUILayout.Toggle("Joint Limitations", upperLeg.bone.jointLimitations);
if (upperLeg.bone.jointLimitations) {
upperLeg.bone.maxAngle = EditorGUILayout.Slider("Max Angle", upperLeg.bone.maxAngle, 0, 180);
}
//EditorGUILayout.BeginHorizontal();
//upperLeg.bone.maxAngle = EditorGUILayout.Slider("Max Angle", upperLeg.bone.maxAngle, 0, 180);
//if (GUILayout.Button("R", GUILayout.Width(20))) {
// upperLeg.bone.maxAngle = FootTarget.maxUpperLegAngle;
//}
//EditorGUILayout.EndHorizontal();
//if (isLeft) {
// Target_Editor.BoneAngleInspector(upperLegMinX, upperLegMaxX, FootTarget.minLeftUpperLegAngles.x, FootTarget.maxLeftUpperLegAngles.x, upperLegXname, "X Limits");
// Target_Editor.BoneAngleInspector(upperLegMinY, upperLegMaxY, FootTarget.minLeftUpperLegAngles.y, FootTarget.maxLeftUpperLegAngles.y, upperLegYname, "Y Limits");
// Target_Editor.BoneAngleInspector(upperLegMinZ, upperLegMaxZ, FootTarget.minLeftUpperLegAngles.z, FootTarget.maxLeftUpperLegAngles.z, upperLegZname, "Z Limits");
//} else {
// Target_Editor.BoneAngleInspector(upperLegMinX, upperLegMaxX, FootTarget.minRightUpperLegAngles.x, FootTarget.maxRightUpperLegAngles.x, upperLegXname, "X Limits");
// Target_Editor.BoneAngleInspector(upperLegMinY, upperLegMaxY, FootTarget.minRightUpperLegAngles.y, FootTarget.maxRightUpperLegAngles.y, upperLegYname, "Y Limits");
// Target_Editor.BoneAngleInspector(upperLegMinZ, upperLegMaxZ, FootTarget.minRightUpperLegAngles.z, FootTarget.maxRightUpperLegAngles.z, upperLegZname, "Z Limits");
//}
EditorGUI.indentLevel--;
}
}
private void UpdateUpperLegBones(FootTarget.TargetedUpperLegBone upperLeg) {
//if (upperLeg.bone.transform == null)
// return;
//upperLeg.bone.minAngles.x = upperLegMinX.floatValue;
//upperLeg.bone.maxAngles.x = upperLegMaxX.floatValue;
//upperLeg.bone.minAngles.y = upperLegMinY.floatValue;
//upperLeg.bone.maxAngles.y = upperLegMaxY.floatValue;
//upperLeg.bone.minAngles.z = upperLegMinZ.floatValue;
//upperLeg.bone.maxAngles.z = upperLegMaxZ.floatValue;
}
#endregion
#region LowerLeg
//private string lowerLegYname;
//private SerializedProperty lowerLegMinX;
//private SerializedProperty lowerLegMaxX;
private void InitLowerLegConfiguration(FootTarget.TargetedLowerLegBone lowerLeg) {
//if (lowerLeg.bone.transform == null)
// return;
//lowerLegYname = lowerLeg.bone.transform.name + "X";
//lowerLegMinX = serializedObject.FindProperty("lowerLeg.bone.minAngles.x");
//lowerLegMaxX = serializedObject.FindProperty("lowerLeg.bone.maxAngles.x");
}
private void LowerLegConfigurationInspector(ref FootTarget.TargetedLowerLegBone lowerLeg, bool isLeft) {
if (lowerLeg.bone.transform != null)
GUI.SetNextControlName(lowerLeg.bone.transform.name + "00");
lowerLeg.bone.transform = (Transform)EditorGUILayout.ObjectField("Lower Leg Bone", lowerLeg.bone.transform, typeof(Transform), true);
if (lowerLeg.bone.transform != null) {
EditorGUI.indentLevel++;
lowerLeg.bone.jointLimitations = EditorGUILayout.Toggle("Joint Limitations", lowerLeg.bone.jointLimitations);
if (lowerLeg.bone.jointLimitations) {
lowerLeg.bone.maxAngle = EditorGUILayout.Slider("Max Angle", lowerLeg.bone.maxAngle, 0, 180);
}
//EditorGUILayout.BeginHorizontal();
//lowerLeg.bone.maxAngle = EditorGUILayout.Slider("Max Angle", lowerLeg.bone.maxAngle, 0, 180);
//if (GUILayout.Button("R", GUILayout.Width(20))) {
// lowerLeg.bone.maxAngle = FootTarget.maxLowerLegAngle;
//}
//EditorGUILayout.EndHorizontal();
//if (isLeft)
// Target_Editor.BoneAngleInspector(lowerLegMinX, lowerLegMaxX, FootTarget.minLeftLowerLegAngles.x, FootTarget.maxLeftLowerLegAngles.x, lowerLegYname, "X Limits");
//else
// Target_Editor.BoneAngleInspector(lowerLegMinX, lowerLegMaxX, FootTarget.minRightLowerLegAngles.x, FootTarget.maxRightLowerLegAngles.x, lowerLegYname, "X Limits");
EditorGUI.indentLevel--;
}
}
private void UpdateLowerLegBones(FootTarget.TargetedLowerLegBone lowerLeg) {
//if (lowerLeg.bone.transform == null)
// return;
//lowerLeg.bone.minAngles.x = lowerLegMinX.floatValue;
//lowerLeg.bone.maxAngles.x = lowerLegMaxX.floatValue;
}
#endregion
#region Foot
//private string footXname;
//private SerializedProperty footMinX;
//private SerializedProperty footMaxX;
//private string footZname;
//private SerializedProperty footMinZ;
//private SerializedProperty footMaxZ;
private void InitFootConfiguration(FootTarget.TargetedFootBone foot) {
//if (foot.bone.transform == null)
// return;
//footXname = foot.bone.transform.name + "X";
//footMinX = serializedObject.FindProperty("foot.bone.minAngles.x");
//footMaxX = serializedObject.FindProperty("foot.bone.maxAngles.x");
//footZname = foot.bone.transform.name + "Z";
//footMinZ = serializedObject.FindProperty("foot.bone.minAngles.z");
//footMaxZ = serializedObject.FindProperty("foot.bone.maxAngles.z");
}
private void FootConfigurationInspector(ref FootTarget.TargetedFootBone foot, bool isLeft) {
if (foot.bone.transform != null)
GUI.SetNextControlName(foot.bone.transform.name + "00");
foot.bone.transform = (Transform)EditorGUILayout.ObjectField("Foot Bone", foot.bone.transform, typeof(Transform), true);
if (foot.bone.transform != null) {
EditorGUI.indentLevel++;
foot.bone.jointLimitations = EditorGUILayout.Toggle("Joint Limitations", foot.bone.jointLimitations);
if (foot.bone.jointLimitations) {
foot.bone.maxAngle = EditorGUILayout.Slider("Max Angle", foot.bone.maxAngle, 0, 180);
}
//EditorGUILayout.BeginHorizontal();
//foot.bone.maxAngle = EditorGUILayout.Slider("Max Angle", foot.bone.maxAngle, 0, 180);
//if (GUILayout.Button("R", GUILayout.Width(20))) {
// foot.bone.maxAngle = FootTarget.maxFootAngle;
//}
//EditorGUILayout.EndHorizontal();
//if (isLeft) {
// Target_Editor.BoneAngleInspector(footMinX, footMaxX, FootTarget.minLeftFootAngles.x, FootTarget.maxLeftFootAngles.x, footXname, "X Limits");
// Target_Editor.BoneAngleInspector(footMinZ, footMaxZ, FootTarget.minLeftFootAngles.z, FootTarget.maxLeftFootAngles.z, footZname, "Z Limits");
//} else {
// Target_Editor.BoneAngleInspector(footMinX, footMaxX, FootTarget.minRightFootAngles.x, FootTarget.maxRightFootAngles.x, footXname, "X Limits");
// Target_Editor.BoneAngleInspector(footMinZ, footMaxZ, FootTarget.minRightFootAngles.z, FootTarget.maxRightFootAngles.z, footZname, "Z Limtis");
//}
EditorGUI.indentLevel--;
}
}
private void UpdateFootBones(FootTarget.TargetedFootBone foot) {
//if (foot.bone.transform == null)
// return;
//foot.bone.minAngles.x = footMinX.floatValue;
//foot.bone.maxAngles.x = footMaxX.floatValue;
//foot.bone.minAngles.z = footMinZ.floatValue;
//foot.bone.maxAngles.z = footMaxZ.floatValue;
}
#endregion
#region Toes
//private string toesXname;
//private SerializedProperty toesMinX;
//private SerializedProperty toesMaxX;
private void InitToesConfiguration(FootTarget.TargetedToesBone toes) {
//if (toes.bone.transform == null)
// return;
//toesXname = toes.bone.transform.name + "X";
//toesMinX = serializedObject.FindProperty("toes.bone.minAngles.x");
//toesMaxX = serializedObject.FindProperty("toes.bone.maxAngles.x");
}
private void ToesConfigurationInspector(ref FootTarget.TargetedToesBone toes, bool isLeft) {
if (toes.bone.transform != null)
GUI.SetNextControlName(toes.bone.transform.name + "00");
toes.bone.transform = (Transform)EditorGUILayout.ObjectField("Toes Bone", toes.bone.transform, typeof(Transform), true);
if (toes.bone.transform != null) {
EditorGUI.indentLevel++;
toes.bone.jointLimitations = EditorGUILayout.Toggle("Joint Limitations", toes.bone.jointLimitations);
if (toes.bone.jointLimitations) {
toes.bone.maxAngle = EditorGUILayout.Slider("Max Angle", toes.bone.maxAngle, 0, 180);
}
//EditorGUILayout.BeginHorizontal();
//toes.bone.maxAngle = EditorGUILayout.Slider("Max Angle", toes.bone.maxAngle, 0, 180);
//if (GUILayout.Button("R", GUILayout.Width(20))) {
// toes.bone.maxAngle = FootTarget.maxToesAngle;
//}
//EditorGUILayout.EndHorizontal();
//if (isLeft)
// Target_Editor.BoneAngleInspector(toesMinX, toesMaxX, FootTarget.minLeftToesAngles.x, FootTarget.maxLeftToesAngles.x, toesXname, "X Limits");
//else
// Target_Editor.BoneAngleInspector(toesMinX, toesMaxX, FootTarget.minRightToesAngles.x, FootTarget.maxRightToesAngles.x, toesXname, "X Limits");
EditorGUI.indentLevel--;
}
}
private void UpdateToesBones(FootTarget.TargetedToesBone toes) {
//if (toes.bone.transform == null)
// return;
//toes.bone.minAngles.x = toesMinX.floatValue;
//toes.bone.maxAngles.x = toesMaxX.floatValue;
}
#endregion
#endregion
#region Settings
private SerializedProperty rotationSpeedLimitationProp;
private SerializedProperty slidePreventionProp;
private void InitSettings() {
rotationSpeedLimitationProp = serializedObject.FindProperty("rotationSpeedLimitation");
slidePreventionProp = serializedObject.FindProperty("slidePrevention");
}
private static bool showSettings;
private void SettingsInspector(FootTarget footTarget) {
showSettings = EditorGUILayout.Foldout(showSettings, "Settings", true);
if (showSettings) {
EditorGUI.indentLevel++;
//footTarget.jointLimitations = EditorGUILayout.Toggle("Joint Limitations", footTarget.jointLimitations);
bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", footTarget.showRealObjects);
if (showRealObjects != footTarget.showRealObjects) {
footTarget.ShowControllers(showRealObjects);
footTarget.showRealObjects = showRealObjects;
}
rotationSpeedLimitationProp.boolValue = EditorGUILayout.Toggle("Rotation Speed Limitation", rotationSpeedLimitationProp.boolValue);
slidePreventionProp.boolValue = EditorGUILayout.Toggle("Slide Prevention", slidePreventionProp.boolValue);
EditorGUI.indentLevel--;
}
}
#endregion
#region Events
protected SerializedProperty groundEventProp;
protected virtual void InitEvents() {
groundEventProp = serializedObject.FindProperty("groundEvent");
}
protected int selectedEventSource = -1;
protected int selectedEvent;
protected bool showEvents;
protected virtual void EventsInspector() {
showEvents = EditorGUILayout.Foldout(showEvents, "Events", true);
if (showEvents) {
EditorGUI.indentLevel++;
GameObjectEvent_Editor.EventInspector(groundEventProp, footTarget.groundEvent, ref selectedEventSource, ref selectedEvent);
//EditorGUILayout.BeginHorizontal();
////Labels
//EditorGUILayout.BeginVertical(GUILayout.MinWidth(110));
//GUILayout.Space(3);
//EditorGUILayout.LabelField("Ground", GUILayout.Width(110));
//EditorGUILayout.EndVertical();
//// Buttons
//string[] buttonTexts = new string[1];
//buttonTexts[0] = Event.GetInputButtonLabel(footTarget.groundEvent.gameObjectEvent);
//int oldFontSize = GUI.skin.button.fontSize;
//GUI.skin.button.fontSize = 9;
//selectedEventSource = GUILayout.SelectionGrid(selectedEventSource, buttonTexts, 1);
//GUI.skin.button.fontSize = oldFontSize;
//EditorGUILayout.EndHorizontal();
//// Details
//GUIStyle style = new GUIStyle(GUI.skin.label) {
// fontStyle = FontStyle.Bold
//};
//EditorGUILayout.LabelField("Details", style, GUILayout.ExpandWidth(true));
//EditorGUI.indentLevel++;
//EventDetails(selectedEventSource);
//EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
}
}
//protected void EventDetails(int selectedInputEvent) {
// switch (selectedInputEvent) {
// case 0:
// GameObjectEvent_Editor.DetailsInspector(groundEventProp, "Ground");
// break;
// }
//}
#endregion
#endregion
#region Scene
public void OnSceneGUI() {
if (footTarget == null || humanoid == null)
return;
if (Application.isPlaying)
return;
if (humanoid.pose != null) {
if (humanoid.editPose)
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
footTarget.CopyRigToTarget();
}
}
// update the target rig from the current foot target
footTarget.CopyTargetToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose
humanoid.MatchTargetsToAvatar();
// and update all target to match the target rig
humanoid.CopyRigToTargets();
// Update the sensors to match the updated targets
humanoid.UpdateSensorsFromTargets();
}
#endregion
public abstract class TargetProps {
public SerializedProperty enabledProp;
public SerializedProperty sensorTransformProp;
public SerializedProperty sensor2TargetPositionProp;
public SerializedProperty sensor2TargetRotationProp;
public FootTarget footTarget;
public LegSensor sensor;
public TargetProps(SerializedObject serializedObject, LegSensor _sensor, FootTarget _footTarget, string unitySensorName) {
enabledProp = serializedObject.FindProperty(unitySensorName + ".enabled");
sensorTransformProp = serializedObject.FindProperty(unitySensorName + ".sensorTransform");
sensor2TargetPositionProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetPosition");
sensor2TargetRotationProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetRotation");
footTarget = _footTarget;
sensor = _sensor;
sensor.Init(footTarget);
}
public virtual void SetSensor2Target() {
if (sensor.sensorTransform == null)
return;
sensor2TargetRotationProp.quaternionValue = Quaternion.Inverse(sensor.sensorTransform.rotation) * footTarget.foot.target.transform.rotation;
sensor2TargetPositionProp.vector3Value = -footTarget.foot.target.transform.InverseTransformPoint(sensor.sensorTransform.position);
}
public abstract void Inspector();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0874824509b87a747a5b7fc51126d0e1
timeCreated: 1462298140
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,759 @@
using UnityEditor;
using UnityEngine;
namespace Passer.Humanoid {
using Tracking;
[CanEditMultipleObjects]
[CustomEditor(typeof(HandTarget), true)]
public class HandTarget_Editor : Editor {
private HandTarget handTarget;
private Passer.Humanoid.HumanoidControl humanoid;
private TargetProps[] allProps;
#region Enable
public void OnEnable() {
handTarget = (HandTarget)target;
if (handTarget.humanoid == null)
handTarget.humanoid = GetHumanoid(handTarget);
humanoid = handTarget.humanoid;
if (humanoid == null)
return;
humanoid.InitTargets();
InitEditors();
handTarget.InitTarget();
InitConfiguration(handTarget);
InitSettings();
InitEvents();
InitHandPose(handTarget);
if (!Application.isPlaying)
SetSensor2Target();
}
private void InitEditors() {
allProps = new TargetProps[] {
#if pUNITYXR
new UnityXR_Editor.HandTargetProps(serializedObject, handTarget),
#endif
//#if hOPENVR && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
// new OpenVR_Editor.HandTargetProps(serializedObject, handTarget),
//#if hVIVETRACKER
// new ViveTracker_Editor.HandTargetProps(serializedObject, handTarget),
//#endif
//#endif
#if hSTEAMVR && UNITY_STANDALONE_WIN
//new SteamVR_Editor.HandTargetProps(serializedObject, handTarget),
#if hVIVETRACKER
//new ViveTracker_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#endif
//#if hOCULUS && (UNITY_STANDALONE_WIN || UNITY_ANDROID)
// new Oculus_Editor.HandTargetProps(serializedObject, handTarget),
//#endif
#if hWINDOWSMR && UNITY_WSA_10_0
new WindowsMR_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hWAVEVR
new WaveVR_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hVRTK
new Vrtk_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hLEAP
new LeapMotion_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hHYDRA
new Hydra_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hKINECT1
new Kinect1_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hKINECT2
new Kinect2_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hKINECT4
new Kinect4_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hORBBEC
new Astra_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hNEURON
new Neuron_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hOPTITRACK
new Optitrack_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hANTILATENCY
new Antilatency_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hHI5
new Hi5_Editor.HandTargetProps(serializedObject, handTarget),
#endif
#if hCUSTOM
new Custom_Editor.HandTargetProps(serializedObject, handTarget),
#endif
};
}
#endregion
#region Disable
public void OnDisable() {
if (humanoid == null) {
// This target is not connected to a humanoid, so we delete it
DestroyImmediate(handTarget, true);
return;
}
if (!Application.isPlaying) {
SetSensor2Target();
}
handTarget.poseMixer.Cleanup();
if (!Application.isPlaying)
handTarget.poseMixer.ShowPose(humanoid, handTarget.isLeft ? Side.Left : Side.Right);
handTarget.UpdateMovements(humanoid);
}
private void SetSensor2Target() {
foreach (TargetProps props in allProps)
props.SetSensor2Target();
}
#endregion
#region Inspector
public override void OnInspectorGUI() {
if (handTarget == null || humanoid == null)
return;
serializedObject.Update();
ControllerInspectors(handTarget);
if (humanoid != null) {
SubTargetsInspector(handTarget);
ConfigurationInspector(handTarget);
serializedObject.ApplyModifiedProperties();
HandPoseInspector(handTarget);
serializedObject.Update();
}
SettingsInspector(handTarget);
TouchedObjectInspector(handTarget);
GrabbedObjectInspector(handTarget);
EventsInspector();
InteractionPointerButton(handTarget);
serializedObject.ApplyModifiedProperties();
//serializedObject.Update();
//serializedObject.ApplyModifiedProperties();
}
public static HandTarget Inspector(HandTarget handTarget, string name) {
if (handTarget == null)
return handTarget;
EditorGUILayout.BeginHorizontal();
Transform defaultTargetTransform = handTarget.GetDefaultTarget(handTarget.humanoid);
Transform targetTransform = handTarget.transform ?? defaultTargetTransform;
GUIContent text = new GUIContent(
name,
"The transform controlling the " + name
);
targetTransform = (Transform)EditorGUILayout.ObjectField(text, targetTransform, typeof(Transform), true);
if (!Application.isPlaying) {
if (targetTransform == defaultTargetTransform && GUILayout.Button("Show", GUILayout.MaxWidth(60))) {
// Call static method CreateTarget on target
handTarget = (HandTarget)handTarget.GetType().GetMethod("CreateTarget").Invoke(null, new object[] { handTarget });
}
else if (targetTransform != handTarget.transform) {
handTarget = (HandTarget)handTarget.GetType().GetMethod("SetTarget").Invoke(null, new object[] { handTarget.humanoid, targetTransform, handTarget.isLeft });
}
}
EditorGUILayout.EndHorizontal();
return handTarget;
}
public static HumanoidControl GetHumanoid(HumanoidTarget target) {
HumanoidControl foundHumanoid = target.transform.GetComponentInParent<HumanoidControl>();
if (foundHumanoid != null)
return foundHumanoid;
HumanoidControl[] humanoids = GameObject.FindObjectsOfType<HumanoidControl>();
for (int i = 0; i < humanoids.Length; i++)
if (humanoids[i].leftHandTarget.transform == target.transform ||
humanoids[i].rightHandTarget.transform == target.transform)
foundHumanoid = humanoids[i];
return foundHumanoid;
}
#region Sensors
public bool showControllers = true;
private void ControllerInspectors(HandTarget handTarget) {
showControllers = EditorGUILayout.Foldout(showControllers, "Sensors/Controllers", true);
if (showControllers) {
EditorGUI.indentLevel++;
foreach (TargetProps props in allProps)
props.Inspector();
if (humanoid != null && humanoid.animatorEnabled)
handTarget.armAnimator.enabled = EditorGUILayout.ToggleLeft("Procedural animation", handTarget.armAnimator.enabled, GUILayout.MinWidth(80));
EditorGUI.indentLevel--;
}
}
#endregion
#region Morph Targets
//float thumbCurl = 0;
private bool showSubTargets;
private void SubTargetsInspector(HandTarget handTarget) {
showSubTargets = EditorGUILayout.Foldout(showSubTargets, "Sub Targets", true);
if (showSubTargets) {
EditorGUI.indentLevel++;
EditorGUI.BeginDisabledGroup(true);
float thumbCurl = handTarget.fingers.thumb.CalculateCurl();
EditorGUILayout.Slider("Thumb Curl", thumbCurl, -0.5F, 1);
float indexCurl = handTarget.fingers.index.CalculateCurl();
EditorGUILayout.Slider("Index Finger Curl", indexCurl, -0.1F, 1);
float middleCurl = handTarget.fingers.middle.CalculateCurl();
EditorGUILayout.Slider("Middle Finger Curl", middleCurl, -0.1F, 1);
float ringCurl = handTarget.fingers.ring.CalculateCurl();
EditorGUILayout.Slider("Ring Finger Curl", ringCurl, -0.1F, 1);
float littleCurl = handTarget.fingers.little.CalculateCurl();
EditorGUILayout.Slider("Little Finger Curl", littleCurl, -0.1F, 1);
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel--;
}
}
#endregion
#region Configuration
private void InitConfiguration(HandTarget handTarget) {
InitShoulderConfiguration(handTarget.shoulder);
InitUpperArmConfiguration(handTarget.upperArm);
InitForearmConfiguration(handTarget.forearm);
InitHandConfiguration(handTarget.hand);
}
private bool showConfiguration;
private bool showFingerConfiguration;
private void ConfigurationInspector(HandTarget handTarget) {
//if (!target.jointLimitations)
//return;
//handTarget.RetrieveBones();
showConfiguration = EditorGUILayout.Foldout(showConfiguration, "Configuration", true);
if (showConfiguration) {
EditorGUI.indentLevel++;
ShoulderConfigurationInspector(ref handTarget.shoulder, handTarget.isLeft);
UpperArmConfigurationInspector(ref handTarget.upperArm, handTarget.isLeft);
ForearmConfigurationInspector(ref handTarget.forearm, handTarget.isLeft);
HandConfigurationInspector(ref handTarget.hand, handTarget.isLeft);
showFingerConfiguration = EditorGUILayout.Foldout(showFingerConfiguration, "Fingers", true);
if (showFingerConfiguration) {
EditorGUI.indentLevel++;
FingersConfigurationInspector(handTarget);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
}
#region Shoulder
private SerializedProperty shoulderArmJointLimitations;
private SerializedProperty shoulderArmLimitationAngle;
private void InitShoulderConfiguration(HandTarget.TargetedShoulderBone shoulder) {
shoulderArmJointLimitations = serializedObject.FindProperty("shoulder.bone.jointLimitations");
shoulderArmLimitationAngle = serializedObject.FindProperty("shoulder.bone.maxAngle");
}
private void ShoulderConfigurationInspector(ref HandTarget.TargetedShoulderBone shoulder, bool isLeft) {
if (shoulder.bone.transform != null)
GUI.SetNextControlName(shoulder.bone.transform.name + "00");
shoulder.bone.transform = (Transform)EditorGUILayout.ObjectField("Shoulder Bone", shoulder.bone.transform, typeof(Transform), true);
if (shoulder.bone.transform != null) {
EditorGUI.indentLevel++;
shoulderArmJointLimitations.boolValue = EditorGUILayout.Toggle("Joint Limitations", shoulder.bone.jointLimitations);
if (shoulder.bone.jointLimitations) {
shoulderArmLimitationAngle.floatValue = EditorGUILayout.Slider("Max Angle", shoulder.bone.maxAngle, 0, 180);
}
EditorGUI.indentLevel--;
}
}
private void UpdateShoulderBones(HandTarget.TargetedShoulderBone shoulder) {
}
#endregion
#region UpperArm
private SerializedProperty upperArmJointLimitations;
private SerializedProperty upperArmLimitationAngle;
private void InitUpperArmConfiguration(HandTarget.TargetedUpperArmBone upperArm) {
upperArmJointLimitations = serializedObject.FindProperty("upperArm.bone.jointLimitations");
upperArmLimitationAngle = serializedObject.FindProperty("upperArm.bone.maxAngle");
}
private void UpperArmConfigurationInspector(ref HandTarget.TargetedUpperArmBone upperArm, bool isLeft) {
if (upperArm.bone.transform != null)
GUI.SetNextControlName(upperArm.bone.transform.name + "00");
upperArm.bone.transform = (Transform)EditorGUILayout.ObjectField("Upper Arm Bone", upperArm.bone.transform, typeof(Transform), true);
if (upperArm.bone.transform != null) {
EditorGUI.indentLevel++;
upperArmJointLimitations.boolValue = EditorGUILayout.Toggle("Joint Limitations", upperArm.bone.jointLimitations);
if (upperArm.bone.jointLimitations) {
upperArmLimitationAngle.floatValue = EditorGUILayout.Slider("Max Angle", upperArm.bone.maxAngle, 0, 180);
}
EditorGUI.indentLevel--;
}
}
private void UpdateUpperArmBones(HandTarget.TargetedUpperArmBone upperArm) {
}
#endregion
#region Forearm
private SerializedProperty forearmJointLimitations;
private SerializedProperty forearmLimitationAngle;
private void InitForearmConfiguration(HandTarget.TargetedForearmBone forearm) {
forearmJointLimitations = serializedObject.FindProperty("forearm.bone.jointLimitations");
forearmLimitationAngle = serializedObject.FindProperty("forearm.bone.maxAngle");
}
private void ForearmConfigurationInspector(ref HandTarget.TargetedForearmBone forearm, bool isLeft) {
if (forearm.bone.transform != null)
GUI.SetNextControlName(forearm.bone.transform.name + "00");
forearm.bone.transform = (Transform)EditorGUILayout.ObjectField("Forearm Bone", forearm.bone.transform, typeof(Transform), true);
if (forearm.bone.transform != null) {
EditorGUI.indentLevel++;
forearmJointLimitations.boolValue = EditorGUILayout.Toggle("Joint Limitations", forearm.bone.jointLimitations);
if (forearm.bone.jointLimitations) {
forearmLimitationAngle.floatValue = EditorGUILayout.Slider("Max Angle", forearm.bone.maxAngle, 0, 180);
}
EditorGUI.indentLevel--;
}
}
private void UpdateForearmBones(HandTarget.TargetedForearmBone forearm) {
}
#endregion
#region Hand
private SerializedProperty handJointLimitations;
private SerializedProperty handLimitationAngle;
private void InitHandConfiguration(HandTarget.TargetedHandBone hand) {
handJointLimitations = serializedObject.FindProperty("hand.bone.jointLimitations");
handLimitationAngle = serializedObject.FindProperty("hand.bone.maxAngle");
}
private void HandConfigurationInspector(ref HandTarget.TargetedHandBone hand, bool isLeft) {
hand.bone.transform = (Transform)EditorGUILayout.ObjectField("Hand Bone", hand.bone.transform, typeof(Transform), true);
if (hand.bone.transform != null) {
EditorGUI.indentLevel++;
handJointLimitations.boolValue = EditorGUILayout.Toggle("Joint Limitations", hand.bone.jointLimitations);
if (hand.bone.jointLimitations) {
handLimitationAngle.floatValue = EditorGUILayout.Slider("Max Angle", hand.bone.maxAngle, 0, 180);
}
EditorGUI.indentLevel--;
}
}
#endregion
#region Fingers
SerializedProperty proximalMinX;
SerializedProperty proximalMaxX;
private void InitFingerConfiguration(FingersTarget fingers) {
}
private void FingersConfigurationInspector(HandTarget handTarget) {
FingerConfigurationInspector(handTarget, handTarget.fingers.thumb, 0, "Proximal Thumb Bone");
FingerConfigurationInspector(handTarget, handTarget.fingers.index, 1, "Proximal Index Bone");
FingerConfigurationInspector(handTarget, handTarget.fingers.middle, 2, "Proximal Middle Bone");
FingerConfigurationInspector(handTarget, handTarget.fingers.ring, 3, "Proximal Ring Bone");
FingerConfigurationInspector(handTarget, handTarget.fingers.little, 4, "Proximal Little Bone");
}
private void FingerConfigurationInspector(HandTarget handTarget, FingersTarget.TargetedFinger digit, int fingerIndex, string label) {
Transform proximalBone = (Transform)EditorGUILayout.ObjectField(label, digit.proximal.bone.transform, typeof(Transform), true);
if (proximalBone == null || proximalBone != digit.proximal.bone.transform) {
if (proximalBone == null)
proximalBone = FingersTarget.GetFingerBone(handTarget, (Finger)fingerIndex, Humanoid.Tracking.FingerBones.Proximal);
if (proximalBone != null && proximalBone.childCount == 1) {
digit.intermediate.bone.transform = proximalBone.GetChild(0);
if (digit.intermediate.bone.transform != null && digit.intermediate.bone.transform.childCount == 1)
digit.distal.bone.transform = digit.intermediate.bone.transform.GetChild(0);
else
digit.distal.bone.transform = null;
}
else
digit.intermediate.bone.transform = null;
}
digit.proximal.bone.transform = proximalBone;
}
#endregion
#endregion
#region Settings
private SerializedProperty physicsProp;
private SerializedProperty rotationSpeedLimitationProp;
private SerializedProperty touchInteractionProp;
private void InitSettings() {
// Cannot use serializedPropery because showRealObjects is a getter/setter
//showRealObjectsProp = serializedObject.FindProperty("showRealObjects");
physicsProp = serializedObject.FindProperty("physics");
rotationSpeedLimitationProp = serializedObject.FindProperty("rotationSpeedLimitation");
touchInteractionProp = serializedObject.FindProperty("touchInteraction");
}
public bool showSettings;
private void SettingsInspector(HandTarget handTarget) {
showSettings = EditorGUILayout.Foldout(showSettings, "Settings", true);
if (showSettings) {
EditorGUI.indentLevel++;
// Cannot use serializedPropery because showRealObjects is a getter/setter
bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", handTarget.showRealObjects);
if (showRealObjects != handTarget.showRealObjects) {
handTarget.showRealObjects = showRealObjects;
handTarget.ShowSensors(showRealObjects, true);
}
rotationSpeedLimitationProp.boolValue = EditorGUILayout.Toggle("Rotation Speed Limitation", rotationSpeedLimitationProp.boolValue);
handTarget.rotationSpeedLimitation = rotationSpeedLimitationProp.boolValue;
touchInteractionProp.boolValue = EditorGUILayout.Toggle("Touch Interaction", touchInteractionProp.boolValue);
handTarget.touchInteraction = touchInteractionProp.boolValue;
physicsProp.boolValue = EditorGUILayout.Toggle("Physics", physicsProp.boolValue);
handTarget.physics = physicsProp.boolValue;
if (handTarget.humanoid.physics) {
handTarget.strength = EditorGUILayout.FloatField("Strength", handTarget.strength);
}
EditorGUI.indentLevel--;
}
}
#endregion
#region HandPose
public static BonePose selectedBone = null;
private string[] poseNames;
private void InitHandPose(HandTarget handTarget) {
}
private bool showHandPoses = false;
private void HandPoseInspector(HandTarget handTarget) {
EditorGUILayout.BeginHorizontal();
showHandPoses = EditorGUILayout.Foldout(showHandPoses, "Hand Pose", true);
GetPoseNames();
EditorGUILayout.BeginHorizontal(GUILayout.Width(300));
if (handTarget.poseMixer.poseMode == PoseMixer.PoseMode.Set) {
handTarget.poseMixer.poseMode = (PoseMixer.PoseMode)EditorGUILayout.EnumPopup(handTarget.poseMixer.poseMode, GUILayout.Width(100));
int poseIx = EditorGUILayout.Popup(handTarget.poseMixer.currentPoseIx, poseNames);
if (poseIx != handTarget.poseMixer.currentPoseIx) {
handTarget.poseMixer.currentPoseIx = poseIx;
handTarget.poseMixer.SetPoseValue(poseIx);
}
}
else if (Application.isPlaying) {
handTarget.poseMixer.poseMode = (PoseMixer.PoseMode)EditorGUILayout.EnumPopup(handTarget.poseMixer.poseMode, GUILayout.Width(100));
EditorGUILayout.ObjectField(handTarget.poseMixer.detectedPose, typeof(Pose), true);
}
else
handTarget.poseMixer.poseMode = (PoseMixer.PoseMode)EditorGUILayout.EnumPopup(handTarget.poseMixer.poseMode, GUILayout.MinWidth(100));
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndHorizontal();
if (showHandPoses) {
EditorGUI.indentLevel++;
Pose_Editor.PoseMixerInspector(handTarget.poseMixer, humanoid, handTarget.side);
EditorGUI.indentLevel--;
}
if (!Application.isPlaying) {
handTarget.poseMixer.ShowPose(humanoid, handTarget.isLeft ? Side.Left : Side.Right);
handTarget.UpdateMovements(humanoid);
SceneView.RepaintAll();
}
}
private void GetPoseNames() {
poseNames = new string[handTarget.poseMixer.mixedPoses.Count];//.Length];
for (int i = 0; i < poseNames.Length; i++) {
if (handTarget.poseMixer.mixedPoses[i].pose == null)
poseNames[i] = "";
else
poseNames[i] = handTarget.poseMixer.mixedPoses[i].pose.name;
}
}
#endregion
#region Other
private void TouchedObjectInspector(HandTarget handTarget) {
handTarget.touchedObject = (GameObject)EditorGUILayout.ObjectField("Touched Object", handTarget.touchedObject, typeof(GameObject), true);
}
private void GrabbedObjectInspector(HandTarget handTarget) {
SerializedProperty grabbedObjectProp = serializedObject.FindProperty("grabbedObject");
if (Application.isPlaying) {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.ObjectField("Grabbed Object", grabbedObjectProp.objectReferenceValue, typeof(GameObject), false);
EditorGUI.EndDisabledGroup();
}
else {
SerializedProperty grabbedPrefabProp = serializedObject.FindProperty("grabbedPrefab");
GameObject grabbedPrefab = (GameObject)EditorGUILayout.ObjectField("Grabbed Prefab", grabbedPrefabProp.objectReferenceValue, typeof(GameObject), false);
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.ObjectField("Grabbed Object", grabbedObjectProp.objectReferenceValue, typeof(GameObject), false);
EditorGUI.EndDisabledGroup();
if (grabbedPrefab != grabbedPrefabProp.objectReferenceValue) {
if (grabbedPrefab != null)
GrabPrefab(handTarget, grabbedObjectProp, grabbedPrefab);
else {
LetGoObject(handTarget, grabbedObjectProp);
}
}
serializedObject.Update();
grabbedPrefabProp.objectReferenceValue = grabbedPrefab;
}
}
private void GrabPrefab(HandTarget handTarget, SerializedProperty grabbedObjectProp, GameObject prefab) {
if (grabbedObjectProp.objectReferenceValue != null)
LetGoObject(handTarget, grabbedObjectProp);
GameObject obj = Instantiate(prefab, handTarget.transform.position, handTarget.transform.rotation);
//HandInteraction.NetworkedGrab(handTarget, obj, false);
handTarget.Grab(obj, false);
if (handTarget.grabbedObject == null)
Debug.LogWarning("Could not grab object");
else {
grabbedObjectProp.objectReferenceValue = obj;
Handle handle = handTarget.grabbedHandle;
if (handle == null) {
Handle.Create(obj, handTarget);
}
}
}
private void LetGoObject(HandTarget handTarget, SerializedProperty grabbedObjectProp) {
GameObject grabbedObject = (GameObject)grabbedObjectProp.objectReferenceValue;
handTarget.LetGo();
DestroyImmediate(grabbedObject, true);
grabbedObjectProp.objectReferenceValue = null;
}
#endregion
#region Events
protected SerializedProperty touchEventProp;
protected SerializedProperty grabEventProp;
protected SerializedProperty poseEventProp;
protected virtual void InitEvents() {
touchEventProp = serializedObject.FindProperty("touchEvent");
grabEventProp = serializedObject.FindProperty("grabEvent");
poseEventProp = serializedObject.FindProperty("poseEvent");
}
protected int selectedEvent = -1;
protected int selectedSubEvent;
protected bool showEvents;
protected virtual void EventsInspector() {
showEvents = EditorGUILayout.Foldout(showEvents, "Events", true);
if (showEvents) {
EditorGUI.indentLevel++;
IntEvent_Editor.EventInspector(poseEventProp, handTarget.poseEvent, ref selectedEvent, ref selectedSubEvent);
GameObjectEvent_Editor.EventInspector(touchEventProp, handTarget.touchEvent, ref selectedEvent, ref selectedSubEvent);
GameObjectEvent_Editor.EventInspector(grabEventProp, handTarget.grabEvent, ref selectedEvent, ref selectedSubEvent);
EditorGUI.indentLevel--;
}
}
#endregion
#region Buttons
private void InteractionPointerButton(HandTarget handTarget) {
InteractionPointer interactionPointer = handTarget.transform.GetComponentInChildren<InteractionPointer>();
if (interactionPointer != null)
return;
GUILayout.BeginHorizontal();
if (GUILayout.Button("Add Interaction Pointer"))
AddInteractionPointer();
if (GUILayout.Button("Add Teleporter"))
AddTeleporter();
GUILayout.EndHorizontal();
}
private void AddInteractionPointer() {
InteractionPointer pointer = InteractionPointer.Add(handTarget.transform, InteractionPointer.PointerType.Ray);
if (handTarget.isLeft) {
pointer.transform.localPosition = new Vector3(-0.21F, -0.02F, 0.01F);
pointer.transform.localRotation = Quaternion.Euler(-180, 90, 180);
}
else {
pointer.transform.localPosition = new Vector3(0.21F, -0.02F, 0.01F);
pointer.transform.localRotation = Quaternion.Euler(-180, -90, -180);
}
pointer.active = false;
ControllerInput controllerInput = humanoid.GetComponent<ControllerInput>();
if (controllerInput != null) {
controllerInput.SetEventHandler(handTarget.isLeft, ControllerInput.SideButton.Button1, pointer.Activation);
controllerInput.SetEventHandler(handTarget.isLeft, ControllerInput.SideButton.Trigger1, pointer.Click);
}
}
private void AddTeleporter() {
Teleporter teleporter = Teleporter.Add(handTarget.transform);
if (handTarget.isLeft) {
teleporter.transform.localPosition = new Vector3(-0.21F, -0.02F, 0.01F);
teleporter.transform.localRotation = Quaternion.Euler(-180, 90, 180);
}
else {
teleporter.transform.localPosition = new Vector3(0.21F, -0.02F, 0.01F);
teleporter.transform.localRotation = Quaternion.Euler(-180, -90, -180);
}
ControllerInput controllerInput = humanoid.GetComponent<ControllerInput>();
if (controllerInput != null) {
//ControllerEventHandlers button1Input = controllerInput.GetInputEvent(handTarget.isLeft, ControllerInput.SideButton.Button1);
//ControllerEvent_Editor.SetBoolMethod(controllerInput.gameObject, button1Input, EventHandler.Type.OnChange, teleporter.Activation);
//ControllerEvent_Editor.SetEventHandlerBool(button1Input, EventHandler.Type.OnChange, teleporter, "Activation");
controllerInput.SetEventHandler(handTarget.isLeft, ControllerInput.SideButton.Button1, teleporter.Activation);
//ControllerEventHandlers trigger1Input = controllerInput.GetInputEvent(handTarget.isLeft, ControllerInput.SideButton.Trigger1);
//ControllerEvent_Editor.SetBoolMethod(controllerInput.gameObject, trigger1Input, EventHandler.Type.OnChange, teleporter.Click);
//ControllerEvent_Editor.SetEventHandlerBool(trigger1Input, EventHandler.Type.OnChange, teleporter, "Click");
controllerInput.SetEventHandler(handTarget.isLeft, ControllerInput.SideButton.Trigger1, teleporter.Click);
}
}
#endregion
#endregion
#region Scene
protected void OnSceneGUI() {
HandTarget handTarget = (HandTarget)target;
if (humanoid == null)
return;
if (Application.isPlaying)
return;
Pose_Editor.UpdateScene(humanoid, handTarget.fingers, handTarget.poseMixer, ref selectedBone, handTarget.isLeft ? Side.Left : Side.Right);
handTarget.poseMixer.ShowPose(humanoid, handTarget.side);
if (humanoid.pose != null) {
if (humanoid.editPose)
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
handTarget.CopyRigToTarget();
}
}
// update the target rig from the current hand target
handTarget.CopyTargetToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose
humanoid.MatchTargetsToAvatar();
// and update all targets to match the target rig
humanoid.CopyRigToTargets();
// Update the sensors to match the updated targets
humanoid.UpdateSensorsFromTargets();
}
#endregion
public abstract class TargetProps {
public SerializedProperty enabledProp;
public SerializedProperty sensorTransformProp;
public SerializedProperty sensor2TargetPositionProp;
public SerializedProperty sensor2TargetRotationProp;
public HandTarget handTarget;
public Humanoid.ArmSensor sensor;
public TargetProps(SerializedObject serializedObject, Humanoid.ArmSensor _sensor, HandTarget _handTarget, string unitySensorName) {
enabledProp = serializedObject.FindProperty(unitySensorName + ".enabled");
sensorTransformProp = serializedObject.FindProperty(unitySensorName + ".sensorTransform");
sensor2TargetPositionProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetPosition");
sensor2TargetRotationProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetRotation");
handTarget = _handTarget;
sensor = _sensor;
sensor.Init(handTarget);
}
public virtual void SetSensor2Target() {
sensor.SetSensor2Target();
}
public abstract void Inspector();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0dd34aad8039ffd41b5585e0da454192
timeCreated: 1459000174
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,536 @@
using UnityEditor;
using UnityEngine;
namespace Passer.Humanoid {
[CanEditMultipleObjects]
[CustomEditor(typeof(HeadTarget), true)]
public class HeadTarget_Editor : Editor {
private HeadTarget headTarget;
private HumanoidControl humanoid;
private TargetProps[] allProps;
#region Enable
public void OnEnable() {
headTarget = (HeadTarget)target;
if (headTarget.humanoid == null)
headTarget.humanoid = GetHumanoid(headTarget);
humanoid = headTarget.humanoid;
InitEditors();
headTarget.InitSensors();
InitSensors();
#if hFACE
FaceTarget_Editor.OnEnable(serializedObject, headTarget);
#endif
}
private void InitEditors() {
allProps = new TargetProps[] {
#if pUNITYXR
new UnityXR_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hSTEAMVR && UNITY_STANDALONE_WIN
#if hVIVETRACKER
//new ViveTracker_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#endif
#if hWINDOWSMR && UNITY_WSA_10_0
new WindowsMR_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hWAVEVR
new WaveVR_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hVRTK
new Vrtk_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hREALSENSE
new Realsense_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hKINECT1
new Kinect1_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hKINECT2
new Kinect2_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hKINECT4
new Kinect4_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hORBBEC
new Astra_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hOPTITRACK
new Optitrack_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hNEURON
new Neuron_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hTOBII
new Tobii_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hARKIT
new ArKit_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hDLIB
new Dlib_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hPUPIL
new Tracking.Pupil.Pupil_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hANTILATENCY
new Antilatency_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
#if hCUSTOM
new Custom_Editor.HeadTargetProps(serializedObject, headTarget),
#endif
};
}
#endregion
#region Disable
public void OnDisable() {
if (humanoid == null) {
// This target is not connected to a humanoid, so we delete it
DestroyImmediate(headTarget, true);
return;
}
if (!Application.isPlaying) {
SetSensor2Target();
}
#if hFACE
FaceTarget_Editor.OnDisable(serializedObject, headTarget);
#endif
}
private void SetSensor2Target() {
if (allProps != null)
foreach (TargetProps props in allProps)
props.SetSensor2Target();
}
#endregion
#region Inspector
public override void OnInspectorGUI() {
if (headTarget == null || humanoid == null)
return;
serializedObject.Update();
SensorInspectors(headTarget);
if (headTarget.humanoid != null) {
#if hFACE
SerializedProperty faceTargetProp = serializedObject.FindProperty("face");
FaceTarget_Editor.OnInspectorGUI(faceTargetProp, headTarget);
#endif
ConfigurationInspector(headTarget);
#if hFACE
FaceTarget_Editor.ExpressionsInspector(headTarget.face);
#endif
}
PoseInspector();
SettingsInspector(headTarget);
#if hFACE
FaceTarget_Editor.FocusObjectInspector(headTarget.face);
#endif
EventsInspector();
GazeInteractionButton(headTarget);
serializedObject.ApplyModifiedProperties();
}
private static HumanoidControl GetHumanoid(HumanoidTarget target) {
HumanoidControl foundHumanoid = target.transform.GetComponentInParent<HumanoidControl>();
if (foundHumanoid != null)
return foundHumanoid;
HumanoidControl[] humanoids = GameObject.FindObjectsOfType<HumanoidControl>();
for (int i = 0; i < humanoids.Length; i++)
if (humanoids[i].headTarget.transform == target.transform)
foundHumanoid = humanoids[i];
return foundHumanoid;
}
#region Sensors
#if hFACE
private SerializedProperty microphoneEnabledProp;
#endif
private void InitSensors() {
#if hFACE
microphoneEnabledProp = serializedObject.FindProperty("microphone.enabled");
#endif
}
private bool showControllers = true;
private void SensorInspectors(HeadTarget headTarget) {
showControllers = EditorGUILayout.Foldout(showControllers, "Controllers", true);
if (showControllers) {
EditorGUI.indentLevel++;
FirstPersonCameraInspector(headTarget);
ScreenInspector(headTarget);
foreach (TargetProps props in allProps)
props.Inspector();
AnimatorInspector(headTarget);
EditorGUI.indentLevel--;
}
}
private void FirstPersonCameraInspector(HeadTarget headTarget) {
#if pUNITYXR || hLEGACYXR
if (headTarget.unityXR == null)
return;
#endif
#if hOPENVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
EditorGUI.BeginDisabledGroup(headTarget.humanoid.openVR.enabled && headTarget.viveTracker.enabled);
#endif
#if pUNITYXR || hLEGACYXR
bool wasEnabled
= headTarget.unityXR.enabled;
#endif
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
#if hLEGACYXR
#if hOPENVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
if (headTarget.humanoid.openVR.enabled && headTarget.viveTracker.enabled)
headTarget.unity.enabled = false;
#endif
#endif
#pragma warning disable 219
bool enabled
#if pUNITYXR || hLEGACYXR
= EditorGUILayout.ToggleLeft(headTarget.unityXR.name, headTarget.unityXR.enabled, GUILayout.MinWidth(80));
if (EditorGUI.EndChangeCheck()) {
Undo.RecordObject(headTarget, enabled ? "Enabled " : "Disabled " + headTarget.unityXR.name);
headTarget.unityXR.enabled = enabled;
}
#else
= false;
#endif
#pragma warning restore 219
EditorGUILayout.EndHorizontal();
#if hFACE
if (enabled) { // && microphoneEnabledProp != null) {
EditorGUI.indentLevel++;
microphoneEnabledProp.boolValue = EditorGUILayout.ToggleLeft("Microphone", microphoneEnabledProp.boolValue);
EditorGUI.indentLevel--;
}
#endif
#if pUNITYXR
//if (!Application.isPlaying) {
// //Passer.Tracking.UnityXRHmd.CheckCamera(headTarget);
// if (!wasEnabled && headTarget.unity.enabled) {
// Passer.Tracking.UnityXRHmd.AddCamera(headTarget.unity);
// }
// else if (wasEnabled && !headTarget.unity.enabled) {
// Passer.Tracking.UnityXRHmd.RemoveCamera(headTarget.unity);
// }
//}
#endif
#if hOPENVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
EditorGUI.EndDisabledGroup();
#endif
}
private void ScreenInspector(HeadTarget headTarget) {
if (headTarget.virtual3d && headTarget.humanoid.showRealObjects) {
if (headTarget.screenTransform == null)
CreateScreen(headTarget);
headTarget.screenTransform.gameObject.SetActive(true);
}
else if (headTarget.screenTransform != null)
headTarget.screenTransform.gameObject.SetActive(false);
}
private void CreateScreen(HeadTarget headTarget) {
GameObject realWorld = HumanoidControl.GetRealWorld(headTarget.humanoid.transform);
headTarget.screenTransform = realWorld.transform.Find("Screen");
if (headTarget.screenTransform == null) {
GameObject screenObj = GameObject.CreatePrimitive(PrimitiveType.Cube); //new GameObject("Screen");
screenObj.name = "Screen";
headTarget.screenTransform = screenObj.transform;
headTarget.screenTransform.parent = realWorld.transform;
headTarget.screenTransform.localPosition = headTarget.transform.position + headTarget.transform.forward;
headTarget.screenTransform.rotation = headTarget.transform.rotation * Quaternion.AngleAxis(180, Vector3.up);
headTarget.screenTransform.localScale = new Vector3(0.476F, 0.2677F, 0.02F); // 21.5 inch 16:9 screen size
}
}
private void AnimatorInspector(HeadTarget headTarget) {
if (headTarget.humanoid == null)
return;
if (headTarget.humanoid.animatorEnabled) {
headTarget.headAnimator.enabled = EditorGUILayout.ToggleLeft("Procedural Animation", headTarget.headAnimator.enabled, GUILayout.MinWidth(80));
if (headTarget.headAnimator.enabled) {
EditorGUI.indentLevel++;
//headTarget.headAnimator.headAnimation = EditorGUILayout.ToggleLeft("Head Animation", headTarget.headAnimator.headAnimation);
#if hFACE
headTarget.face.behaviour.enabled = EditorGUILayout.ToggleLeft("Eye Behaviour", headTarget.face.behaviour.enabled);
#endif
EditorGUI.indentLevel--;
}
}
}
#endregion
#region Configuration
private bool showConfiguration;
private bool showLeftEye;
private bool showRightEye;
private void ConfigurationInspector(HeadTarget headTarget) {
if (headTarget.humanoid == null)
return;
showConfiguration = EditorGUILayout.Foldout(showConfiguration, "Configuration", true);
if (showConfiguration) {
EditorGUI.indentLevel++;
#if hFACE
SerializedProperty faceProp = serializedObject.FindProperty("face");
FaceTarget_Editor.ConfigurationInspector(faceProp, headTarget.face);
#endif
HeadConfigurationInspector(ref headTarget.head);
NeckConfigurationInspector(ref headTarget.neck);
EditorGUI.indentLevel--;
}
}
private void HeadConfigurationInspector(ref HeadTarget.TargetedHeadBone head) {
head.bone.transform = (Transform)EditorGUILayout.ObjectField("Head", head.bone.transform, typeof(Transform), true);
if (head.bone.transform != null) {
EditorGUI.indentLevel++;
EditorGUILayout.BeginHorizontal();
head.bone.maxAngle = EditorGUILayout.Slider("Max Angle", head.bone.maxAngle, 0, 180);
if (GUILayout.Button("R", GUILayout.Width(20))) {
head.bone.maxAngle = HeadTarget.maxHeadAngle;
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
}
private void NeckConfigurationInspector(ref HeadTarget.TargetedNeckBone neck) {
neck.bone.transform = (Transform)EditorGUILayout.ObjectField("Neck", neck.bone.transform, typeof(Transform), true);
if (neck.bone.transform != null) {
EditorGUI.indentLevel++;
EditorGUILayout.BeginHorizontal();
neck.bone.maxAngle = EditorGUILayout.Slider("Max Angle", neck.bone.maxAngle, 0, 180);
if (GUILayout.Button("R", GUILayout.Width(20))) {
neck.bone.maxAngle = HeadTarget.maxNeckAngle;
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
}
#endregion
#region Pose
private void PoseInspector() {
if (!Application.isPlaying && humanoid.pose != null && humanoid.editPose)
humanoid.pose.UpdatePose(humanoid);
}
#endregion
#region Settings
private bool showSettings;
private void SettingsInspector(HeadTarget headTarget) {
showSettings = EditorGUILayout.Foldout(showSettings, "Settings", true);
if (showSettings) {
EditorGUI.indentLevel++;
CollisionFaderInspector();
EditorGUI.indentLevel--;
}
}
private void CollisionFaderInspector() {
SerializedProperty collisionFaderProp = serializedObject.FindProperty("collisionFader");
collisionFaderProp.boolValue = EditorGUILayout.Toggle("Collision Fader", collisionFaderProp.boolValue);
}
#endregion
#region Events
protected int selectedEventSource = -1;
protected int selectedEvent;
protected bool showEvents;
protected virtual void EventsInspector() {
showEvents = EditorGUILayout.Foldout(showEvents, "Events", true);
if (showEvents) {
EditorGUI.indentLevel++;
TrackingEventInspector();
AudioEventInspector();
#if hFACE
FocusEventInspector();
BlinkEventInspector();
#endif
InsideColliderInspector();
EditorGUI.indentLevel--;
}
}
protected void TrackingEventInspector() {
SerializedProperty trackingEventProp = serializedObject.FindProperty("trackingEvent");
BoolEvent_Editor.EventInspector(trackingEventProp, headTarget.trackingEvent, ref selectedEventSource, ref selectedEvent);
}
protected void AudioEventInspector() {
SerializedProperty audioEventProp = serializedObject.FindProperty("audioEvent");
FloatEvent_Editor.EventInspector(audioEventProp, headTarget.audioEvent, ref selectedEventSource, ref selectedEvent);
}
#if hFACE
protected void FocusEventInspector() {
SerializedProperty focusEventProp = serializedObject.FindProperty("focusEvent");
GameObjectEvent_Editor.EventInspector(focusEventProp, headTarget.focusEvent, ref selectedEventSource, ref selectedEvent);
}
protected void BlinkEventInspector() {
SerializedProperty blinkEventProp = serializedObject.FindProperty("blinkEvent");
BoolEvent_Editor.EventInspector(blinkEventProp, headTarget.blinkEvent, ref selectedEventSource, ref selectedEvent);
}
#endif
protected void InsideColliderInspector() {
SerializedProperty insideColliderEventProp = serializedObject.FindProperty("insideColliderEvent");
BoolEvent_Editor.EventInspector(insideColliderEventProp, headTarget.insideColliderEvent, ref selectedEventSource, ref selectedEvent);
}
// protected void EventDetails(int selectedEvent) {
// switch (selectedEvent) {
// case 0:
// FloatEvent_Editor.DetailsInspector(headTarget.audioEvent, audioEventProp, "Audio");
// break;
//#if hFACE
// case 1:
// GameObjectEvent_Editor.DetailsInspector(focusEventProp, "Focus");
// break;
// case 2:
// BoolEvent_Editor.DetailsInspector(blinkEventProp, "Blink");
// break;
//#endif
// }
// }
#endregion
#region Buttons
private void GazeInteractionButton(HeadTarget headTarget) {
InteractionPointer interactionPointer = headTarget.transform.GetComponentInChildren<InteractionPointer>();
if (interactionPointer != null)
return;
GUILayout.BeginHorizontal();
if (GUILayout.Button("Add Interaction Pointer"))
AddInteractionPointer();
if (GUILayout.Button("Add Teleporter"))
AddTeleporter();
GUILayout.EndHorizontal();
}
private void AddInteractionPointer() {
}
private void AddTeleporter() {
}
#endregion
#endregion
#region Scene
public void OnSceneGUI() {
if (Application.isPlaying)
return;
if (headTarget == null || headTarget.humanoid == null)
return;
#if hFACE
FaceTarget_Editor.UpdateScene(headTarget.face);
#endif
if (humanoid.pose != null) {
if (humanoid.editPose)
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
headTarget.CopyRigToTarget();
}
}
// update the target rig from the current head target
headTarget.CopyTargetToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose
humanoid.MatchTargetsToAvatar();
// and update all targets to match the target rig
humanoid.CopyRigToTargets();
// Update the sensors to match the updated targets
humanoid.UpdateSensorsFromTargets();
}
#endregion
public abstract class TargetProps {
public SerializedProperty enabledProp;
public SerializedProperty sensorTransformProp;
public SerializedProperty sensor2TargetPositionProp;
public SerializedProperty sensor2TargetRotationProp;
public HeadTarget headTarget;
public HeadSensor sensor;
public TargetProps(SerializedObject serializedObject, HeadSensor _sensor, HeadTarget _headTarget, string unitySensorName) {
enabledProp = serializedObject.FindProperty(unitySensorName + ".enabled");
sensorTransformProp = serializedObject.FindProperty(unitySensorName + ".sensorTransform");
sensor2TargetPositionProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetPosition");
sensor2TargetRotationProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetRotation");
headTarget = _headTarget;
sensor = _sensor;
sensor.Init(headTarget);
}
public virtual void SetSensor2Target() {
if (sensor.sensorTransform == null)
return;
sensor2TargetRotationProp.quaternionValue = Quaternion.Inverse(sensor.sensorTransform.rotation) * headTarget.head.target.transform.rotation;
sensor2TargetPositionProp.vector3Value = -headTarget.head.target.transform.InverseTransformPoint(sensor.sensorTransform.position);
}
public abstract void Inspector();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 363b5edd875938247a1df60350426519
timeCreated: 1455896583
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,316 @@
using UnityEditor;
using UnityEngine;
namespace Passer {
using Humanoid;
[CanEditMultipleObjects]
[CustomEditor(typeof(HipsTarget), true)]
public class HipsTarget_Editor : Editor {
private HipsTarget hipsTarget;
private HumanoidControl humanoid;
private TargetProps[] allProps;
#region Enable
public void OnEnable() {
hipsTarget = (HipsTarget)target;
if (hipsTarget.humanoid == null)
hipsTarget.humanoid = GetHumanoid(hipsTarget);
humanoid = hipsTarget.humanoid;
if (humanoid == null)
return;
InitEditors();
hipsTarget.InitSensors();
InitConfiguration(hipsTarget);
InitSettings();
}
private void InitEditors() {
allProps = new TargetProps[] {
#if hOPENVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
new ViveTracker_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
#if hKINECT1
new Kinect1_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
#if hKINECT2
new Kinect2_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
#if hKINECT4
new Kinect4_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
#if hORBBEC
new Astra_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
#if hNEURON
new Neuron_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
#if hOPTITRACK
new Optitrack_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
#if hCUSTOM
new Custom_Editor.HipsTargetProps(serializedObject, hipsTarget),
#endif
};
}
#endregion
#region Disable
public void OnDisable() {
if (humanoid == null) {
// This target is not connected to a humanoid, so we delete it
DestroyImmediate(hipsTarget, true);
return;
}
if (!Application.isPlaying) {
SetSensor2Target();
}
}
private void SetSensor2Target() {
foreach (TargetProps props in allProps)
props.SetSensor2Target();
}
#endregion
#region Inspector
public override void OnInspectorGUI() {
if (hipsTarget == null || humanoid == null)
return;
serializedObject.Update();
SensorInspectors(hipsTarget);
ConfigurationInspector(hipsTarget);
SettingsInspector();
serializedObject.ApplyModifiedProperties();
}
public static HumanoidControl GetHumanoid(HumanoidTarget target) {
HumanoidControl foundHumanoid = target.transform.GetComponentInParent<HumanoidControl>();
if (foundHumanoid != null)
return foundHumanoid;
HumanoidControl[] humanoids = GameObject.FindObjectsOfType<HumanoidControl>();
for (int i = 0; i < humanoids.Length; i++)
if (humanoids[i].hipsTarget.transform == target.transform)
foundHumanoid = humanoids[i];
return foundHumanoid;
}
#region Sensors
public bool showSensors = true;
private void SensorInspectors(HipsTarget hipsTarget) {
showSensors = EditorGUILayout.Foldout(showSensors, "Controllers", true);
if (showSensors) {
EditorGUI.indentLevel++;
foreach (TargetProps props in allProps)
props.Inspector();
if (humanoid.animatorEnabled)
hipsTarget.torsoAnimator.enabled = EditorGUILayout.ToggleLeft("Procedural Animation", hipsTarget.torsoAnimator.enabled, GUILayout.MinWidth(80));
EditorGUI.indentLevel--;
}
}
#endregion
#region Configuration
private void InitConfiguration(HipsTarget target) {
if (target.humanoid.avatarRig == null)
return;
InitChestConfiguration(target.chest);
InitSpineConfiguration(target.spine);
InitHipsConfiguration(target.hips);
}
private bool showConfiguration;
private void ConfigurationInspector(HipsTarget hipsTarget) {
hipsTarget.RetrieveBones();
showConfiguration = EditorGUILayout.Foldout(showConfiguration, "Configuration", true);
if (showConfiguration) {
EditorGUI.indentLevel++;
ChestConfigurationInspector(ref hipsTarget.chest);
SpineConfigurationInspector(ref hipsTarget.spine);
HipsConfigurationInspector(ref hipsTarget.hips);
EditorGUI.indentLevel--;
}
}
private void UpdateBones(HipsTarget target) {
if (target.humanoid.avatarRig == null)
return;
UpdateHipsBones(target.hips);
UpdateSpineBones(target.spine);
UpdateChestBones(target.chest);
}
#region Chest
private void InitChestConfiguration(HipsTarget.TargetedChestBone upperLeg) {
}
private void ChestConfigurationInspector(ref HipsTarget.TargetedChestBone chest) {
chest.bone.transform = (Transform)EditorGUILayout.ObjectField("Chest", chest.bone.transform, typeof(Transform), true);
if (chest.bone.transform != null) {
EditorGUI.indentLevel++;
EditorGUILayout.BeginHorizontal();
chest.bone.maxAngle = EditorGUILayout.Slider("Max Angle", chest.bone.maxAngle, 0, 180);
if (GUILayout.Button("R", GUILayout.Width(20))) {
chest.bone.maxAngle = HipsTarget.maxChestAngle;
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
}
private void UpdateChestBones(HipsTarget.TargetedChestBone chest) {
}
#endregion
#region Spine
private void InitSpineConfiguration(HipsTarget.TargetedSpineBone spine) {
}
private void SpineConfigurationInspector(ref HipsTarget.TargetedSpineBone spine) {
spine.bone.transform = (Transform)EditorGUILayout.ObjectField("Spine", spine.bone.transform, typeof(Transform), true);
if (spine.bone.transform != null) {
EditorGUI.indentLevel++;
EditorGUILayout.BeginHorizontal();
spine.bone.maxAngle = EditorGUILayout.Slider("Max Angle", spine.bone.maxAngle, 0, 180);
if (GUILayout.Button("R", GUILayout.Width(20))) {
spine.bone.maxAngle = HipsTarget.maxSpineAngle;
}
EditorGUILayout.EndHorizontal();
EditorGUI.indentLevel--;
}
}
private void UpdateSpineBones(HipsTarget.TargetedSpineBone spine) {
}
#endregion
#region Hips
private void InitHipsConfiguration(HipsTarget.TargetedHipsBone hips) {
}
private void HipsConfigurationInspector(ref HipsTarget.TargetedHipsBone hips) {
hips.bone.transform = (Transform)EditorGUILayout.ObjectField("Hips", hips.bone.transform, typeof(Transform), true);
}
private void UpdateHipsBones(HipsTarget.TargetedHipsBone hips) {
}
#endregion
#endregion
#region Settings
protected SerializedProperty bodyRotationProp;
protected void InitSettings() {
SerializedProperty animatorProp = serializedObject.FindProperty("torsoAnimator");
bodyRotationProp = animatorProp.FindPropertyRelative("bodyRotation");
}
public bool showSettings;
protected void SettingsInspector() {
showSettings = EditorGUILayout.Foldout(showSettings, "Settings", true);
if (showSettings) {
EditorGUI.indentLevel++;
bodyRotationProp.intValue = (int)(TorsoAnimator.BodyRotation)EditorGUILayout.EnumPopup("Body Rotation", (TorsoAnimator.BodyRotation)bodyRotationProp.intValue);
EditorGUI.indentLevel--;
}
}
#endregion
#endregion
#region Scene
public void OnSceneGUI() {
if (Application.isPlaying)
return;
if (hipsTarget == null || humanoid == null)
return;
if (humanoid.pose != null) {
if (humanoid.editPose)
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
hipsTarget.CopyRigToTarget();
}
}
// update the target rig from the current hips target
hipsTarget.CopyTargetToRig();
// update the avatar bones to match the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose
humanoid.MatchTargetsToAvatar();
// and update all targets to match the target rig
humanoid.CopyRigToTargets();
// Update the sensors to match the updated targets
humanoid.UpdateSensorsFromTargets();
}
#endregion
public abstract class TargetProps {
public SerializedProperty enabledProp;
public SerializedProperty sensorTransformProp;
public SerializedProperty sensor2TargetPositionProp;
public SerializedProperty sensor2TargetRotationProp;
public HipsTarget hipsTarget;
public TorsoSensor sensor;
public TargetProps(SerializedObject serializedObject, TorsoSensor _sensor, HipsTarget _hipsTarget, string unitySensorName) {
enabledProp = serializedObject.FindProperty(unitySensorName + ".enabled");
sensorTransformProp = serializedObject.FindProperty(unitySensorName + ".sensorTransform");
sensor2TargetPositionProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetPosition");
sensor2TargetRotationProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetRotation");
hipsTarget = _hipsTarget;
sensor = _sensor;
sensor.Init(hipsTarget);
}
public virtual void SetSensor2Target() {
if (sensor.sensorTransform == null)
return;
sensor2TargetRotationProp.quaternionValue = Quaternion.Inverse(sensor.sensorTransform.rotation) * hipsTarget.hips.target.transform.rotation;
sensor2TargetPositionProp.vector3Value = -hipsTarget.hips.target.transform.InverseTransformPoint(sensor.sensorTransform.position);
}
public abstract void Inspector();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bfaf25c142fe67b49969e7693e8db940
timeCreated: 1462300882
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,389 @@
using UnityEditor;
using UnityEngine;
namespace Passer.Humanoid {
public static class HumanoidTarget_Editor {
public static Target Inspector(Target target, string name) {
if (target == null)
return target;
EditorGUILayout.BeginHorizontal();
Transform defaultTargetTransform = null; // target.GetDefaultTarget(target.humanoid);
Transform targetTransform = target.transform ?? defaultTargetTransform;
targetTransform = (Transform)EditorGUILayout.ObjectField(name, targetTransform, typeof(Transform), true);
if (!Application.isPlaying) {
if (targetTransform == defaultTargetTransform && GUILayout.Button("Show", GUILayout.MaxWidth(60))) {
// Call static method CreateTarget on target
target = (HumanoidTarget)target.GetType().GetMethod("CreateTarget").Invoke(null, new object[] { target });
//} else if (targetTransform != target.transform) {
// target = (HumanoidTarget)target.GetType().GetMethod("SetTarget").Invoke(null, new object[] { target.humanoid, targetTransform });
}
}
EditorGUILayout.EndHorizontal();
return target;
}
public static HumanoidTarget Inspector(HumanoidTarget target, string name) {
if (target == null)
return target;
EditorGUILayout.BeginHorizontal();
Transform defaultTargetTransform = target.GetDefaultTarget(target.humanoid);
Transform targetTransform = target.transform ?? defaultTargetTransform;
GUIContent text = new GUIContent(
name,
"The transform controlling the " + name
);
targetTransform = (Transform)EditorGUILayout.ObjectField(text, targetTransform, typeof(Transform), true);
if (!Application.isPlaying) {
if (targetTransform == defaultTargetTransform && GUILayout.Button("Show", GUILayout.MaxWidth(60))) {
// Call static method CreateTarget on target
target = (HumanoidTarget)target.GetType().GetMethod("CreateTarget").Invoke(null, new object[] { target });
} else if (targetTransform != target.transform) {
target = (HumanoidTarget)target.GetType().GetMethod("SetTarget").Invoke(null, new object[] { target.humanoid, targetTransform });
}
}
EditorGUILayout.EndHorizontal();
return target;
}
public static bool ControllerInspector(HumanoidSensor controller) {
EditorGUILayout.BeginHorizontal();
controller.enabled = EditorGUILayout.ToggleLeft(controller.name, controller.enabled, GUILayout.MinWidth(80));
if (controller.enabled && Application.isPlaying)
EditorGUILayout.EnumPopup(controller.status);
EditorGUILayout.EndHorizontal();
return controller.enabled;
}
public static bool ControllerInspector(HumanoidSensor controller, Target target) {
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
GUIContent text = new GUIContent(
controller.name,
"Activate " + controller.name + " support for this humanoid"
);
bool enabled = EditorGUILayout.ToggleLeft(text, controller.enabled, GUILayout.MinWidth(80));
if (EditorGUI.EndChangeCheck()) {
Undo.RecordObject(target, enabled ? "Enabled " : "Disabled " + controller.name);
controller.enabled = enabled;
}
if (Application.isPlaying && enabled)
EditorGUILayout.EnumPopup(controller.status);
EditorGUILayout.EndHorizontal();
return enabled;
}
public static void BoneAngleInspector(SerializedProperty minProperty, SerializedProperty maxProperty, float defaultMin, float defaultMax, string boneAxisName, string label) {
float min = minProperty.floatValue;
float max = maxProperty.floatValue;
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(label, GUILayout.MinWidth(70));
min = EditorGUILayout.FloatField(min, GUILayout.Width(65));
GUI.SetNextControlName(boneAxisName + "1");
EditorGUILayout.MinMaxSlider(ref min, ref max, -180, 180);
GUI.SetNextControlName(boneAxisName + "2");
max = EditorGUILayout.FloatField(max, GUILayout.Width(65));
if (GUILayout.Button("R")) {
min = defaultMin;
max = defaultMax;
GUI.FocusControl(boneAxisName + "1");
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck()) {
minProperty.floatValue = min;
maxProperty.floatValue = max;
}
SceneView.RepaintAll();
}
public static void BoneXAngleInspector(HumanoidTarget.TargetedBone bone, float defaultMin, float defaultMax) {
float oldMin = bone.bone.minAngles.x;
float oldMax = bone.bone.maxAngles.x;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("X Limits", GUILayout.MinWidth(70));
GUI.SetNextControlName(bone.bone.transform.name + "X1");
bone.bone.minAngles.x = EditorGUILayout.FloatField(bone.bone.minAngles.x, GUILayout.Width(65));
EditorGUILayout.MinMaxSlider(ref bone.bone.minAngles.x, ref bone.bone.maxAngles.x, -180, 180);
GUI.SetNextControlName(bone.bone.transform.name + "X2");
bone.bone.maxAngles.x = EditorGUILayout.FloatField(bone.bone.maxAngles.x, GUILayout.Width(65));
if (GUILayout.Button("R")) {
bone.bone.minAngles.x = defaultMin;
bone.bone.maxAngles.x = defaultMax;
GUI.FocusControl(bone.bone.transform.name + "X1");
}
EditorGUILayout.EndHorizontal();
if (bone.bone.maxAngles.x != oldMax || bone.bone.minAngles.x != oldMin)
SceneView.RepaintAll();
}
public static void BoneYAngleInspector(HumanoidTarget.TargetedBone bone, float defaultMin, float defaultMax) {
float oldMin = bone.bone.minAngles.y;
float oldMax = bone.bone.maxAngles.y;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Y Limits", GUILayout.MinWidth(70));
GUI.SetNextControlName(bone.bone.transform.name + "Y1");
bone.bone.minAngles.y = EditorGUILayout.FloatField(bone.bone.minAngles.y, GUILayout.Width(65));
EditorGUILayout.MinMaxSlider(ref bone.bone.minAngles.y, ref bone.bone.maxAngles.y, -180, 180);
GUI.SetNextControlName(bone.bone.transform.name + "Y2");
bone.bone.maxAngles.y = EditorGUILayout.FloatField(bone.bone.maxAngles.y, GUILayout.Width(65));
if (GUILayout.Button("R")) {
bone.bone.minAngles.y = defaultMin;
bone.bone.maxAngles.y = defaultMax;
GUI.FocusControl(bone.bone.transform.name + "Y1");
}
EditorGUILayout.EndHorizontal();
if (bone.bone.maxAngles.y != oldMax || bone.bone.minAngles.y != oldMin)
SceneView.RepaintAll();
}
public static void BoneYAngleInspector(HumanoidTarget.TargetedBone bone, SerializedProperty minProperty, SerializedProperty maxProperty, float defaultMin, float defaultMax) {
float min = minProperty.floatValue;
float max = maxProperty.floatValue;
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Limits Y", GUILayout.MinWidth(70));
min = EditorGUILayout.FloatField(min, GUILayout.Width(65));
GUI.SetNextControlName(bone.bone.transform.name + "Y1");
EditorGUILayout.MinMaxSlider(ref min, ref max, -180, 180);
GUI.SetNextControlName(bone.bone.transform.name + "Y2");
max = EditorGUILayout.FloatField(max, GUILayout.Width(65));
if (GUILayout.Button("R")) {
min = defaultMin;
max = defaultMax;
GUI.FocusControl(bone.bone.transform.name + "Y1");
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck()) {
minProperty.floatValue = min;
maxProperty.floatValue = max;
SceneView.RepaintAll();
}
}
public static void BoneZAngleInspector(HumanoidTarget.TargetedBone bone, float defaultMin, float defaultMax) {
float oldMin = bone.bone.minAngles.z;
float oldMax = bone.bone.maxAngles.z;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Z Limits", GUILayout.MinWidth(70));
GUI.SetNextControlName(bone.bone.transform.name + "Z1");
bone.bone.minAngles.z = EditorGUILayout.FloatField(bone.bone.minAngles.z, GUILayout.Width(65));
EditorGUILayout.MinMaxSlider(ref bone.bone.minAngles.z, ref bone.bone.maxAngles.z, -180, 180);
GUI.SetNextControlName(bone.bone.transform.name + "Z2");
bone.bone.maxAngles.z = EditorGUILayout.FloatField(bone.bone.maxAngles.z, GUILayout.Width(65));
if (GUILayout.Button("R")) {
bone.bone.minAngles.z = defaultMin;
bone.bone.maxAngles.z = defaultMax;
GUI.FocusControl(bone.bone.transform.name + "Z1");
}
EditorGUILayout.EndHorizontal();
if (bone.bone.maxAngles.y != oldMax || bone.bone.minAngles.y != oldMin)
SceneView.RepaintAll();
}
public static void BoneZAngleInspector(HumanoidTarget.TargetedBone bone, SerializedProperty minProperty, SerializedProperty maxProperty, float defaultMin, float defaultMax) {
float min = minProperty.floatValue;
float max = maxProperty.floatValue;
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Limits Z", GUILayout.MinWidth(70));
min = EditorGUILayout.FloatField(min, GUILayout.Width(65));
GUI.SetNextControlName(bone.bone.transform.name + "Z1");
EditorGUILayout.MinMaxSlider(ref min, ref max, -180, 180);
GUI.SetNextControlName(bone.bone.transform.name + "Z2");
max = EditorGUILayout.FloatField(max, GUILayout.Width(65));
if (GUILayout.Button("R")) {
min = defaultMin;
max = defaultMax;
GUI.FocusControl(bone.bone.transform.name + "Z1");
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck()) {
minProperty.floatValue = min;
maxProperty.floatValue = max;
SceneView.RepaintAll();
}
}
//public static void DrawTargetBone(HumanoidTarget.TargetedBone bone) {
// if (bone.target.transform != null) {
// Handles.color = Color.white;
// Handles.DrawLine(bone.target.transform.position, bone.target.transform.position + bone.target.transform.rotation * bone.target.normalDirection * bone.bone.length);
// }
//}
#region xArcs
public static void DrawXArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle) {
DrawXArcs(position, rotation, minAngle, maxAngle, rotation * Vector3.down);
}
public static void DrawXArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle, Vector3 zeroDirection) {
Vector3 planeNormal = rotation * Vector3.right;
DrawXArcs(position, rotation, minAngle, maxAngle, planeNormal, zeroDirection);
}
public static void DrawXArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle, Vector3 planeNormal, Vector3 zeroDirection) {
DrawArcs(position, rotation, minAngle, maxAngle, planeNormal, zeroDirection, Color.red);
}
#endregion
#region yArcs
public static void DrawYArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle) {
DrawYArcs(position, rotation, minAngle, maxAngle, rotation * Vector3.forward);
}
public static void DrawYArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle, Vector3 zeroDirection) {
Vector3 planeNormal = rotation * Vector3.up;
DrawYArcs(position, rotation, minAngle, maxAngle, planeNormal, zeroDirection);
}
public static void DrawYArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle, Vector3 planeNormal, Vector3 zeroDirection) {
DrawArcs(position, rotation, minAngle, maxAngle, planeNormal, zeroDirection, Color.green);
}
#endregion
#region zArcs
public static void DrawZArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle) {
DrawZArcs(position, rotation, minAngle, maxAngle, rotation * Vector3.down);
}
public static void DrawZArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle, Vector3 zeroDirection) {
Vector3 planeNormal = rotation * Vector3.forward;
DrawZArcs(position, rotation, minAngle, maxAngle, planeNormal, zeroDirection);
}
public static void DrawZArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle, Vector3 planeNormal, Vector3 zeroDirection) {
DrawArcs(position, rotation, minAngle, maxAngle, planeNormal, zeroDirection, Color.blue);
}
#endregion
public static void DrawArcs(Vector3 position, Quaternion rotation, float minAngle, float maxAngle, Vector3 planeNormal, Vector3 zeroDirection, Color color) {
color.a = 0.1F;
Handles.color = color;
Handles.DrawSolidArc(position, planeNormal, zeroDirection, minAngle, HandleUtility.GetHandleSize(position));
Handles.DrawSolidArc(position, planeNormal, zeroDirection, maxAngle, HandleUtility.GetHandleSize(position));
color.a = 1;
Handles.color = color;
Handles.DrawWireArc(position, planeNormal, zeroDirection, minAngle, HandleUtility.GetHandleSize(position));
Handles.DrawWireArc(position, planeNormal, zeroDirection, maxAngle, HandleUtility.GetHandleSize(position));
Handles.DrawLine(position, position + zeroDirection * HandleUtility.GetHandleSize(position));
}
#region MinMaxSlider
}
public class MinMaxSliderAttribute : PropertyAttribute {
public readonly string name;
public readonly float defaultMin;
public readonly float defaultMax;
public readonly float minLimit;
public readonly float maxLimit;
public MinMaxSliderAttribute(string _name, float _defaultMin, float _defaultMax, float _minLimit, float _maxLimit) {
name = _name;
defaultMin = _defaultMin;
defaultMax = _defaultMax;
minLimit = _minLimit;
maxLimit = _maxLimit;
}
}
[CustomPropertyDrawer(typeof(MinMaxSliderAttribute))]
class MinMaxSliderDrawer : PropertyDrawer {
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
if (property.propertyType == SerializedPropertyType.Vector2) {
Vector2 range = property.vector2Value;
float min = range.x;
float max = range.y;
MinMaxSliderAttribute attr = attribute as MinMaxSliderAttribute;
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(label, GUILayout.MinWidth(70));
min = EditorGUILayout.FloatField(min, GUILayout.Width(65));
GUI.SetNextControlName(attr.name + "1");
EditorGUI.MinMaxSlider(position, label, ref min, ref max, attr.minLimit, attr.maxLimit);
GUI.SetNextControlName(attr.name + "2");
max = EditorGUILayout.FloatField(max, GUILayout.Width(65));
if (GUILayout.Button("R")) {
min = attr.defaultMin;
max = attr.defaultMax;
GUI.FocusControl(attr.name + "Y1");
}
if (EditorGUI.EndChangeCheck()) {
range.x = min;
range.y = max;
property.vector2Value = range;
}
EditorGUILayout.EndHorizontal();
} else {
EditorGUI.LabelField(position, label, "Use only with Vector2");
}
}
}
#endregion
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dfaa18de9efae9e4692a96305b21d4e3
timeCreated: 1485418477
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
using UnityEditor;
using UnityEngine;
namespace Passer {
public static class Target_Editor {
public static Target Inspector(Target target, string name) {
if (target == null)
return target;
EditorGUILayout.BeginHorizontal();
Transform defaultTargetTransform = null; // target.GetDefaultTarget(target.humanoid);
Transform targetTransform = target.transform ?? defaultTargetTransform;
targetTransform = (Transform)EditorGUILayout.ObjectField(name, targetTransform, typeof(Transform), true);
if (!Application.isPlaying) {
if (targetTransform == defaultTargetTransform && GUILayout.Button("Show", GUILayout.MaxWidth(60))) {
// Call static method CreateTarget on target
target = (Target)target.GetType().GetMethod("CreateTarget").Invoke(null, new object[] { target });
//} else if (targetTransform != target.transform) {
// target = (HumanoidTarget)target.GetType().GetMethod("SetTarget").Invoke(null, new object[] { target.humanoid, targetTransform });
}
}
EditorGUILayout.EndHorizontal();
return target;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f51402f87211d494abb18fefb102f23b
timeCreated: 1553075920
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cde1d9ece214cd9459618e3f564ee3b2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,90 @@
using UnityEngine;
using UnityEditor;
namespace Passer.Humanoid {
[CustomEditor(typeof(AvatarManager))]
public class AvatarManager_Editor : Editor {
public void OnDisable() {
AvatarManager avatarManager = (AvatarManager)target;
Cleanup(avatarManager);
}
public override void OnInspectorGUI() {
AvatarManager avatarManager = (AvatarManager)target;
CurrentAvatarInspector(avatarManager);
if (avatarManager.fpAvatars.Length == 0 || avatarManager.fpAvatars[avatarManager.fpAvatars.Length - 1] != null)
avatarManager.fpAvatars = Extend(avatarManager.fpAvatars, avatarManager.fpAvatars.Length + 1);
if (avatarManager.tpAvatars.Length < avatarManager.fpAvatars.Length)
avatarManager.tpAvatars = Extend(avatarManager.tpAvatars, avatarManager.fpAvatars.Length);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("#", GUILayout.Width(20));
EditorGUILayout.LabelField("First Person", GUILayout.MinWidth(100));
#if hNW_UNET || hNW_PHOTON || hNW_BOLT || hNW_MIRROR
EditorGUILayout.LabelField("Third Person", GUILayout.MinWidth(100));
#endif
EditorGUILayout.EndHorizontal();
for (int i = 0; i < avatarManager.fpAvatars.Length; i++)
AvatarInspector(avatarManager, i);
//if (GUILayout.Button("Add Avatar"))
// AddAvatar(avatarManager);
}
private void CurrentAvatarInspector(AvatarManager avatarManager) {
int lastAvatarIndex = avatarManager.currentAvatarIndex;
avatarManager.currentAvatarIndex = EditorGUILayout.IntField("Current Avatar Index", avatarManager.currentAvatarIndex);
if (Application.isPlaying && avatarManager.currentAvatarIndex != lastAvatarIndex)
avatarManager.SetAvatar(avatarManager.currentAvatarIndex);
}
private void AvatarInspector(AvatarManager avatarManager, int i) {
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(i.ToString(), GUILayout.Width(20));
avatarManager.fpAvatars[i] = (Animator)EditorGUILayout.ObjectField(avatarManager.fpAvatars[i], typeof(Animator), false);
#if hNW_UNET || hNW_PHOTON || hNW_BOLT || hNW_MIRROR
avatarManager.tpAvatars[i] = (Animator) EditorGUILayout.ObjectField(avatarManager.tpAvatars[i], typeof(Animator), false);
#endif
EditorGUILayout.EndHorizontal();
}
private void AddAvatar(AvatarManager avatarManager) {
avatarManager.fpAvatars = Extend(avatarManager.fpAvatars, avatarManager.fpAvatars.Length + 1);
}
private Animator[] Extend(Animator[] animators, int n) {
Animator[] newAnimators = new Animator[n];
for (int i = 0; i < animators.Length; i++)
newAnimators[i] = animators[i];
return newAnimators;
}
private void Cleanup(AvatarManager avatarManager) {
int nNonNullEntries = 0;
foreach (Animator animator in avatarManager.fpAvatars) {
if (animator != null)
nNonNullEntries++;
}
if (nNonNullEntries == avatarManager.fpAvatars.Length)
return;
Animator[] newFpAvatars = new Animator[nNonNullEntries];
int j = 0;
for (int i = 0; i < avatarManager.fpAvatars.Length; i++) {
if (avatarManager.fpAvatars[i] != null) {
newFpAvatars[j] = avatarManager.fpAvatars[i];
j++;
}
}
avatarManager.fpAvatars = newFpAvatars;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 43744b1e9fbbc154da0167e2af1c5fd5
timeCreated: 1513776933
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
using UnityEngine;
using UnityEditor;
namespace Passer.Humanoid {
[CustomEditor(typeof(ColoringInteractionPointer), true)]
public class ColoringInteractionPointer_Editor : InteractionPointer_Editor {
#region Inspector
public override void OnInspectorGUI() {
base.OnInspectorGUI();
SerializedProperty validMaterialProp = serializedObject.FindProperty("validMaterial");
SerializedProperty invalidMaterialProp = serializedObject.FindProperty("invalidMaterial");
validMaterialProp.objectReferenceValue = EditorGUILayout.ObjectField("Valid Material", validMaterialProp.objectReferenceValue, typeof(Material), false);
invalidMaterialProp.objectReferenceValue = EditorGUILayout.ObjectField("Invalid Material", invalidMaterialProp.objectReferenceValue, typeof(Material), false);
serializedObject.ApplyModifiedProperties();
}
#endregion
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d02dc353189558b4ea8595963c421445
timeCreated: 1575542779
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
/*
using UnityEditor;
namespace Passer.Humanoid {
[CustomEditor(typeof(HumanoidInteractionPointer), true)]
public class HumanoidInteractionPointer_Editor : InteractionPointer_Editor { }
}
*/

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9960a3766953271488d78fb0a36223a6
timeCreated: 1520436447
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
using UnityEditor;
namespace Passer.Humanoid {
[CustomEditor(typeof(Telegrabber))]
public class Telegrabber_Editor : InteractionPointer_Editor { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f20a7e0a71465de4bab00c177aa6af18
timeCreated: 1536833107
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
using UnityEditor;
using UnityEngine;
namespace Passer {
using Passer.Tracking;
[CustomEditor(typeof(TrackedRigidbody))]
public class TrackedRigidbody_Editor : Editor {
public override void OnInspectorGUI() {
serializedObject.Update();
SensorInspector();
HybridPhysics.PhysicsMode physicsMode = PhysicsModeInspector();
if (physicsMode != HybridPhysics.PhysicsMode.Kinematic) {
StrengthInspector();
if (physicsMode == HybridPhysics.PhysicsMode.HybridKinematic)
KinematicMass();
}
serializedObject.ApplyModifiedProperties();
}
protected virtual void SensorInspector() {
SerializedProperty sensorComponentProp = serializedObject.FindProperty("target");
Transform sensorTransform = (Transform)sensorComponentProp.objectReferenceValue;
SensorComponent sensorComponent =
sensorTransform != null ?
sensorTransform.GetComponent<SensorComponent>() :
null;
sensorComponent = (SensorComponent)EditorGUILayout.ObjectField("Sensor", sensorComponent, typeof(SensorComponent), true);
sensorComponentProp.objectReferenceValue =
sensorComponent != null ?
sensorComponent.transform :
null;
}
protected virtual HybridPhysics.PhysicsMode PhysicsModeInspector() {
SerializedProperty modeProp = serializedObject.FindProperty("mode");
HybridPhysics.PhysicsMode physicsMode = (HybridPhysics.PhysicsMode)EditorGUILayout.EnumPopup("Physics Mode", (HybridPhysics.PhysicsMode)modeProp.intValue);
modeProp.intValue = (int)physicsMode;
return physicsMode;
}
protected virtual void StrengthInspector() {
SerializedProperty strengthProp = serializedObject.FindProperty("strength");
strengthProp.floatValue = EditorGUILayout.FloatField("Strength", strengthProp.floatValue);
}
protected virtual void KinematicMass() {
SerializedProperty kinematicMassProp = serializedObject.FindProperty("kinematicMass");
kinematicMassProp.floatValue = EditorGUILayout.FloatField("Kinematic Mass", kinematicMassProp.floatValue);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f7c0372c48e713242be42a6c0b6332ba
timeCreated: 1569481259
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,55 @@
using UnityEngine;
using UnityEditor;
namespace Passer.Humanoid {
public class Tracker_Editor : Editor {
public static void Inspector(HumanoidControl humanoid, HumanoidTracker tracker, SerializedProperty enabledProp, string resourceName) {
EditorGUILayout.BeginHorizontal();
//EditorGUI.BeginChangeCheck();
bool wasEnabled = enabledProp.boolValue;
enabledProp.boolValue = EditorGUILayout.ToggleLeft(tracker.name, enabledProp.boolValue, GUILayout.MinWidth(80));
if (Application.isPlaying && enabledProp.boolValue)
EditorGUILayout.EnumPopup(tracker.status);
EditorGUILayout.EndHorizontal();
PrefabAssetType prefabType = PrefabUtility.GetPrefabAssetType(humanoid);
if (prefabType != PrefabAssetType.NotAPrefab)
return;
if (tracker.humanoid == null)
tracker.humanoid = humanoid;
//if (enabledProp.boolValue && resourceName != null)
// tracker.AddTracker(humanoid, resourceName);
//else if (wasEnabled) {
// RemoveTracker(tracker);
//}
//tracker.ShowTracker(humanoid.showRealObjects && enabledProp.boolValue);
}
public static void Inspector(HumanoidTracker tracker, SerializedProperty enabledProp) {
EditorGUILayout.BeginHorizontal();
//EditorGUI.BeginChangeCheck();
enabledProp.boolValue = EditorGUILayout.ToggleLeft(tracker.name, enabledProp.boolValue, GUILayout.MinWidth(80));
if (Application.isPlaying && enabledProp.boolValue)
EditorGUILayout.EnumPopup(tracker.status);
EditorGUILayout.EndHorizontal();
}
protected static void RemoveTracker(HumanoidTracker tracker) {
if (tracker.trackerComponent == null)
return;
DestroyImmediate(tracker.trackerComponent.gameObject, true);
}
public static Transform RemoveTransform(Transform trackerTransform) {
if (trackerTransform != null) {
DestroyImmediate(trackerTransform.gameObject, true);
}
return null;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ab47a0583b3b8d947ab63aef8be18bdb
timeCreated: 1487856438
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
{
"name": "PasserVR.HumanoidControl.Editor",
"references": [
"PasserVR.HumanoidControl",
"Passer.Visitors.Editor",
"PhotonUnityNetworking",
"PhotonVoice",
"PhotonVoice.PUN",
"PhotonRealtime",
"PhotonVoice.API"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8d71350a0583ead4aaa1142233af2cd7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b0e878c4acc46164b984c88512d3690e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEditor;
namespace Passer {
[CustomEditor(typeof(HumanoidAttachments))]
public class HumanoidAttachments_Editor : Editor {
}
}

View File

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

View File

@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Passer {
[CustomEditor(typeof(VisitorPossessions))]
public class PawnPossessions_Editor : Editor {
private VisitorPossessions humanoidPossessions;
private void OnEnable() {
humanoidPossessions = (VisitorPossessions)target;
}
public override void OnInspectorGUI() {
ClearOnAwakeInspector();
DefaultPossessionsInspector();
serializedObject.ApplyModifiedProperties();
if (Application.isPlaying) {
CurrentPossessions();
} else {
ScenePossessions();
}
}
protected virtual void ClearOnAwakeInspector() {
SerializedProperty clearOnAwakeProp = serializedObject.FindProperty("clearOnAwake");
EditorGUILayout.PropertyField(clearOnAwakeProp);
}
protected virtual void DefaultPossessionsInspector() {
SerializedProperty defaultPossessionsProp = serializedObject.FindProperty("defaultPossessions");
EditorGUILayout.PropertyField(defaultPossessionsProp, true);
}
protected void CurrentPossessions() {
EditorGUILayout.LabelField("Current Possessions");
EditorGUI.indentLevel++;
if (humanoidPossessions.possessions != null) {
List<VisitorPossessions.Possession> possessionList = humanoidPossessions.possessions;
foreach (VisitorPossessions.Possession possession in possessionList) {
EditorGUILayout.TextField(possession.name);
}
}
EditorGUI.indentLevel--;
}
protected void ScenePossessions() {
EditorGUILayout.LabelField("Possessions in this Scene");
EditorGUI.indentLevel++;
using (new EditorGUI.DisabledScope(true)) {
Possessable[] sitePossessions = FindObjectsOfType<Possessable>();
foreach (Possessable possession in sitePossessions) {
EditorGUILayout.ObjectField(possession, typeof(Possessable), true);
}
}
EditorGUI.indentLevel--;
}
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More