This commit is contained in:
2026-05-30 09:16:35 +07:00
parent 2f87ce19a7
commit 1c0ee6efb7
4001 changed files with 3363438 additions and 1738 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b8e71356e2d292b489dd4dd276e40013
folderAsset: yes
timeCreated: 1558679563
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 783e14f694a800d49b30a1cb1fced871
folderAsset: yes
timeCreated: 1558653810
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 65f90c9aeb55c284db8781274114886a
folderAsset: yes
timeCreated: 1558664445
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d9f809d0fb9c3cc4c8b70e6e5b90075a
folderAsset: yes
timeCreated: 1558969115
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: No Name
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 65d5441e6a4c7d04287723684491347e
timeCreated: 1558969115
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,82 @@
fileFormatVersion: 2
guid: 6ab888cc164bf244db6f7d3860229e6e
timeCreated: 1558639332
licenseType: Store
ModelImporter:
serializedVersion: 19
fileIDToRecycleName:
100000: //RootNode
400000: //RootNode
2300000: //RootNode
3300000: //RootNode
4300000: Cone
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
importBlendShapes: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
importAnimation: 1
copyAvatar: 0
humanDescription:
serializedVersion: 2
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
rootMotionBoneName:
rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1}
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 0
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,133 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: boneMaterial
m_Shader: {fileID: 10101, guid: 0000000000000000e000000000000000, type: 0}
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailBump:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Difuse:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Emission:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainBump:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Normal:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _texcoord:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _ColorMask: 403.5
- _Cutoff: 0.5
- _DashFrequency: 51
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EmissionTransition: 100
- _Emissionpower: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1
- _Metallic: 0
- _Mode: 0
- _NormalPower: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Shininess: 0.2
- _Size: 0
- _Smoothness: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Stencil: 2.24
- _StencilComp: 8.04
- _StencilOp: 1
- _StencilReadMask: 255
- _StencilWriteMask: 219.2
- _Strength: 0.2
- _Thickness: 3.67
- _UVSec: 0
- _UseUIAlphaClip: 0
- _WireSize: 0.9
- _ZWrite: 1
- __dirty: 1
m_Colors:
- _Color: {r: 1, g: 0, b: 0, a: 0.297}
- _Emission: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
- _Specular: {r: 0, g: 0, b: 0, a: 0}
- _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}
- _WireColor: {r: 0, g: 0, b: 0, a: 1}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 27344df4b0a8b3b45a50e864896e41cc
timeCreated: 1558641603
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,185 @@
using UnityEditor;
using UnityEngine;
namespace Invector
{
[CustomEditor(typeof(vBodySnappingControl))]
public class vBodySnappingControlEditor : vEditorBase
{
SerializedProperty bones;
GUIContent warning;
vBodySnappingControl bcontrol;
float lineSize = 0.1f;
float coneSize = 0.015f;
float sphereSize = 0.04f;
float handlesAlpha = 0.8f;
GUIStyle fontLabelStyle = new GUIStyle();
private void OnSceneGUI()
{
if (bcontrol && bcontrol.boneSnappingList.Count > 0)
{
if (bcontrol.transform.parent)
{
bcontrol.transform.localPosition = Vector3.zero;
bcontrol.transform.rotation = bcontrol.transform.parent.rotation;
}
var color = Handles.color;
if (!Application.isPlaying)
{
for (int i = 0; i < bcontrol.boneSnappingList.Count; i++)
{
var bn = bcontrol.boneSnappingList[i];
if (bn.bone && bn.target)
{
Handles.color = Color.green * handlesAlpha;
if (Handles.Button(bn.target.position, Quaternion.identity, sphereSize, sphereSize, Handles.SphereHandleCap))
{
EditorGUIUtility.PingObject(bn.target);
}
Handles.color = Color.blue * handlesAlpha;
Handles.DrawLine(bn.target.position, bn.target.position + bn.target.forward * lineSize);
Handles.ConeHandleCap(0, bn.target.position + bn.target.forward * lineSize, Quaternion.LookRotation(bn.target.forward), coneSize, EventType.Repaint);
Handles.color = Color.red * handlesAlpha;
Handles.DrawLine(bn.target.position, bn.target.position + bn.target.right * lineSize);
Handles.ConeHandleCap(0, bn.target.position + bn.target.right * lineSize, Quaternion.LookRotation(bn.target.right), coneSize, EventType.Repaint);
Handles.color = Color.green * handlesAlpha;
Handles.DrawLine(bn.target.position, bn.target.position + bn.target.up * lineSize);
Handles.ConeHandleCap(0, bn.target.position + bn.target.up * lineSize, Quaternion.LookRotation(bn.target.up), coneSize, EventType.Repaint);
if (bcontrol.showLabels)
{
float zoom = Vector3.Distance(bn.bone.position, SceneView.currentDrawingSceneView.camera.transform.position);
int fontSize = 25;
fontLabelStyle.fontSize = Mathf.FloorToInt(fontSize / zoom);
fontLabelStyle.normal.textColor = Color.white;
fontLabelStyle.alignment = TextAnchor.MiddleCenter;
GUI.color = Color.white;
Handles.Label(bn.bone.position + Vector3.up * lineSize, bn.target.gameObject.name, fontLabelStyle);
}
bn.Snap();
}
}
}
}
}
//Vector3[] convecPoly = new Vector3[5];
protected override void OnEnable()
{
base.OnEnable(); bones = serializedObject.FindProperty("boneSnappingList");
warning = EditorGUIUtility.IconContent("console.erroricon");
bcontrol = (vBodySnappingControl)target;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
base.OnInspectorGUI();
if (bones != null)
{
GUILayout.Space(-10);
GUILayout.BeginVertical(skin.box);
GUILayout.BeginHorizontal();
if (bcontrol.boneSnappingList.Exists(b => b.bone == null))
{
warning.tooltip = ("One or more bones can't be found");
GUILayout.Label(warning, GUILayout.Width(20), GUILayout.Height(20));
}
bones.isExpanded = GUILayout.Toggle(bones.isExpanded, bones.arraySize > 0 ? bones.displayName + " " + bones.arraySize.ToString("(00)") : "None Bones", EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(true));
GUILayout.EndHorizontal();
if (bones.isExpanded)
{
for (int i = 0; i < bones.arraySize; i++)
{
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(bones.GetArrayElementAtIndex(i));
if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(15)))
{
bones.DeleteArrayElementAtIndex(i);
break;
}
GUILayout.EndHorizontal();
}
}
GUILayout.EndVertical();
}
if (GUI.changed) serializedObject.ApplyModifiedProperties();
}
}
[CustomPropertyDrawer(typeof(vBodySnappingControl.vBoneTransformSnapping))]
public class vBoneSnappingDrawer : PropertyDrawer
{
readonly float lineHeight = EditorGUIUtility.singleLineHeight;
readonly float labelWidth = EditorGUIUtility.labelWidth;
readonly float fieldSpace = 2f;
//readonly GUIContent[] rigType = { new GUIContent("Human"), new GUIContent("Generic") };
readonly GUISkin skin = Resources.Load("vSkin") as GUISkin;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var defaultSkin = GUI.skin;
GUI.skin = skin;
SerializedProperty name = property.FindPropertyRelative("name");
SerializedProperty bone = property.FindPropertyRelative("bone");
SerializedProperty targetTransform = property.FindPropertyRelative("target");
SerializedProperty showProperties = property.FindPropertyRelative("showProperties");
SerializedProperty orientation = property.FindPropertyRelative("orientation");
SerializedProperty onSnap = property.FindPropertyRelative("onSnap");
var color = GUI.color;
GUI.color = bone.objectReferenceValue ? color : Color.red;
GUI.Box(position, "", skin.box);
var fRc = position;
fRc.width = 20;
fRc.x += 15;
GUI.color = Color.white * 2;
showProperties.boolValue = EditorGUI.Foldout(fRc, showProperties.boolValue, GUIContent.none, false, EditorStyles.foldout);
GUI.color = color;
var rc = position;
rc.x += 20;
rc.height = lineHeight;
rc.y += fieldSpace;
rc.width = labelWidth;
GUI.enabled = bone.objectReferenceValue;
if (GUI.Button(rc, new GUIContent(name.stringValue, bone.objectReferenceValue ? "Ping " + name.stringValue + " Bone" : "Missing " + name.stringValue + " Bone\nAdd more generic names to your Body Struct target bone or Just remove if you don't need that bone"), EditorStyles.miniButton))
{
EditorGUIUtility.PingObject(bone.objectReferenceValue);
}
rc.width = (position.width - (labelWidth * 1.2f));
rc.x = (position.x + position.width) - rc.width;
EditorGUI.ObjectField(rc, targetTransform, GUIContent.none);
GUI.enabled = true;
GUI.skin = defaultSkin;
if (showProperties.boolValue)
{
rc.width = position.width - (fieldSpace * 10);
rc.x = position.x + fieldSpace * 5;
rc.y += lineHeight * 2f + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(rc, orientation);
rc.y += lineHeight;
EditorGUI.PropertyField(rc, onSnap);
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
SerializedProperty showProperties = property.FindPropertyRelative("showProperties");
float heightOpen = 0f;
if (showProperties.boolValue)
{
heightOpen += (lineHeight + EditorGUIUtility.standardVerticalSpacing) * 2;
SerializedProperty onSnap = property.FindPropertyRelative("onSnap");
heightOpen += EditorGUI.GetPropertyHeight(onSnap, new GUIContent(onSnap.displayName), true);
}
return ((lineHeight) + (fieldSpace * 2)) + heightOpen;
}
}
}

View File

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

View File

@@ -0,0 +1,147 @@
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(vBodyStruct))]
public class vBodyStructEditor : UnityEditor.Editor
{
SerializedProperty bones;
GUISkin skin;
private void OnEnable()
{
skin = Resources.Load("vSkin") as GUISkin;
bones = serializedObject.FindProperty("bones");
}
public override bool UseDefaultMargins()
{
return false;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
var oldSkin = GUI.skin;
GUI.skin = skin;
if (bones != null)
{
GUILayout.BeginVertical(skin.box);
GUILayout.BeginHorizontal();
bones.isExpanded = GUILayout.Toggle(bones.isExpanded, bones.arraySize > 0 ? bones.displayName : "None Bones", EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight));
GUILayout.Space(5);
GUILayout.BeginVertical(GUILayout.Width(20));
GUILayout.Space(-2);
if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(20), GUILayout.Height(20)))
{
bones.arraySize++;
}
GUILayout.EndVertical();
//bones.arraySize = EditorGUILayout.IntField(bones.arraySize, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.Width(50));
GUILayout.EndHorizontal();
GUILayout.Space(2);
if (bones.isExpanded)
{
for (int i = 0; i < bones.arraySize; i++)
{
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(bones.GetArrayElementAtIndex(i));
if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(15)))
{
bones.DeleteArrayElementAtIndex(i);
break;
}
GUILayout.EndHorizontal();
}
}
GUILayout.EndVertical();
//GUILayout.Space(-5);
//GUILayout.BeginHorizontal();
//GUILayout.FlexibleSpace();
//if (GUILayout.Button("+", skin.button, GUILayout.Width(26), GUILayout.Height(18)))
//{
// bones.arraySize++;
//}
//GUILayout.EndHorizontal();
}
if (GUI.changed) serializedObject.ApplyModifiedProperties();
GUI.skin = oldSkin;
}
}
[CustomPropertyDrawer(typeof(vBodyStruct.Bone))]
public class vBoneEditor : PropertyDrawer
{
readonly float lineHeight = EditorGUIUtility.singleLineHeight;
readonly float labelWidth = EditorGUIUtility.labelWidth;
readonly float fieldSpace = 2f;
readonly GUIContent[] rigType = { new GUIContent("Human"), new GUIContent("Generic") };
readonly GUISkin skin = Resources.Load("vSkin") as GUISkin;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var defaultSkin = GUI.skin;
GUI.skin = skin;
SerializedProperty name = property.FindPropertyRelative("name");
SerializedProperty humanBone = property.FindPropertyRelative("humanBone");
SerializedProperty genericBone = property.FindPropertyRelative("genericBone");
SerializedProperty isHuman = property.FindPropertyRelative("isHuman");
label = EditorGUI.BeginProperty(position, label, property);
EditorGUI.indentLevel = 0;
GUI.Box(position, "");
position.x += fieldSpace;
position.width -= fieldSpace * 2;
position.height = lineHeight;
position.y += fieldSpace;
Rect rc = position;
rc.width = labelWidth;
if (isHuman.boolValue)
{
EditorGUI.PropertyField(rc, humanBone, GUIContent.none);
name.stringValue = humanBone.enumNames[humanBone.enumValueIndex];
}
else
{
GUI.enabled = false;
GUI.Label(position, new GUIContent("Default Name", "Default Bone Name"));
GUI.enabled = true;
EditorGUI.PropertyField(rc, name, GUIContent.none);
}
rc.x += labelWidth;
rc.width = 80;
rc.x = (position.x + position.width) - rc.width;
EnumBollean(rc, isHuman);
position.y += lineHeight + fieldSpace;
if (!isHuman.boolValue)
{
GUI.enabled = false;
GUI.Label(position, new GUIContent("Generic bone names", "GENERIC BONE NAMES\nUse this to make possible names to bone separeted by (;)\nEx: Hips;CharHips;HipsBase;"));
GUI.enabled = true;
EditorGUI.PropertyField(position, genericBone, GUIContent.none);
}
EditorGUI.EndProperty();
GUI.skin = defaultSkin;
}
void EnumBollean(Rect rec, SerializedProperty property)
{
var selected = property.boolValue ? 0 : 1;
selected = EditorGUI.Popup(rec, GUIContent.none, selected, rigType);
if (GUI.changed)
{
property.boolValue = selected == 0;
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
bool isHuman = property.FindPropertyRelative("isHuman").boolValue;
return lineHeight * (isHuman ? 1 : 2f) + (fieldSpace * (isHuman ? 2 : 3f));
}
}

View File

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

View File

@@ -0,0 +1,230 @@
using Invector;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(vSnapToBody))]
public class vSnapToBodyEditor : UnityEditor.Editor
{
vSnapToBody snapToBody;
int index = 0;
GUIStyle fontLabelStyle = new GUIStyle();
public GUISkin skin;
private void OnEnable()
{
skin = Resources.Load("vSkin") as GUISkin;
snapToBody = target as vSnapToBody;
}
private void OnSceneGUI()
{
snapToBody.bodySnap = snapToBody.transform.root.GetComponentInChildren<vBodySnappingControl>();
if (Application.isPlaying)
{
return;
}
Handles.color = Color.white;
if (snapToBody)
{
var e = Event.current.type;
if (snapToBody.bodySnap != null)
{
if (snapToBody.bodySnap && snapToBody.bodySnap.boneSnappingList != null)
{
var boneList = snapToBody.bodySnap.boneSnappingList;
for (int i = 0; i < boneList.Count; i++)
{
var bodyPart = boneList[i];
if (bodyPart.bone)
{
var sameBone = bodyPart.bone == snapToBody.boneToSnap;
Handles.color = sameBone ? Color.green : Color.white * 0.8f;
if (sameBone)
{
Handles.SphereHandleCap(0, bodyPart.bone.transform.position, Quaternion.identity, 0.05f, EventType.Repaint);
}
else if (Handles.Button(bodyPart.bone.transform.position, Quaternion.identity, sameBone ? 0.05f : 0.025f, 0.05f, Handles.SphereHandleCap))
{
Undo.RecordObject(snapToBody, "BoneSelected");
snapToBody.boneName = bodyPart.name;
snapToBody.boneToSnap = bodyPart.bone;
index = i + 1;
EditorUtility.SetDirty(snapToBody);
serializedObject.ApplyModifiedProperties();
Repaint();
break;
}
switch (e)
{
case EventType.Repaint:
{
float dist = Vector2.Distance(Event.current.mousePosition, HandleUtility.WorldToGUIPoint(bodyPart.bone.position));
if (dist < 15f)
{
fontLabelStyle.fontSize = 15;
fontLabelStyle.normal.textColor = Color.green;
fontLabelStyle.fontStyle = FontStyle.Bold;
fontLabelStyle.alignment = TextAnchor.MiddleCenter;
GUI.color = Color.white;
Handles.Label(bodyPart.bone.position, bodyPart.name, fontLabelStyle);
break;
}
}
break;
}
}
}
}
}
if (index == 0 && snapToBody.boneToSnap != null)
{
Handles.color = Color.green;
Handles.SphereHandleCap(0, snapToBody.boneToSnap.position, Quaternion.identity, 0.05f, EventType.Repaint);
switch (e)
{
case EventType.Repaint:
{
float dist = Vector2.Distance(Event.current.mousePosition, HandleUtility.WorldToGUIPoint(snapToBody.boneToSnap.position));
if (dist < 15f)
{
fontLabelStyle.fontSize = 15;
fontLabelStyle.normal.textColor = Color.green;
fontLabelStyle.fontStyle = FontStyle.Bold;
fontLabelStyle.alignment = TextAnchor.MiddleCenter;
GUI.color = Color.white;
Handles.Label(snapToBody.boneToSnap.position, snapToBody.boneToSnap.name, fontLabelStyle);
break;
}
}
break;
}
}
}
Handles.color = Color.white;
}
public override void OnInspectorGUI()
{
var oldSkin = GUI.skin;
if (GUI.skin != skin)
{
GUI.skin = skin;
}
serializedObject.Update();
GUI.enabled = false;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));
GUI.enabled = true;
if (snapToBody)
{
GUI.color = snapToBody.bodySnap ? Color.white : Color.red;
GUILayout.BeginHorizontal("box");
GUILayout.Label("Target Body Snap Control", EditorStyles.largeLabel);
GUI.enabled = false;
snapToBody.bodySnap = (vBodySnappingControl)EditorGUILayout.ObjectField(snapToBody.bodySnap, typeof(vBodySnappingControl), true);
GUI.enabled = true;
GUILayout.EndHorizontal();
GUI.color = Color.white;
if (snapToBody.bodySnap == null)
{
EditorGUILayout.HelpBox("Without vBodySnapping Control component in the Character you will need to assign the bone manually\nPlease, create a GameObject with vBodySnapping Control component to easily find the bone target", MessageType.Info);
GUILayout.BeginHorizontal("box");
snapToBody.boneToSnap = (Transform)EditorGUILayout.ObjectField(snapToBody.boneToSnap, typeof(Transform), true);
GUI.enabled = false;
EditorGUI.BeginChangeCheck();
GUI.color = Color.red;
EditorGUILayout.Popup(0, new string[] { snapToBody.boneName });
GUI.color = Color.white;
GUI.enabled = true;
GUILayout.EndHorizontal();
}
if (snapToBody.bodySnap)
{
if (snapToBody.bodySnap && snapToBody.bodySnap.boneSnappingList != null)
{
try
{
string[] bones = new string[snapToBody.bodySnap.boneSnappingList.Count + 1];
bones[0] = vSnapToBody.manuallyAssignBone;
for (int i = 1; i < bones.Length; i++)
{
bones[i] = snapToBody.bodySnap.boneSnappingList[i - 1].name;
}
if (index > 0 && string.IsNullOrEmpty(snapToBody.boneName) && snapToBody.boneToSnap != null)
{
var _bodyParty = snapToBody.bodySnap.boneSnappingList.Find(b => b.bone.Equals(snapToBody.boneToSnap));
if (_bodyParty != null)
{
index = snapToBody.bodySnap.boneSnappingList.IndexOf(_bodyParty) + 1;
snapToBody.boneName = snapToBody.bodySnap.boneSnappingList[index - 1].name;
}
}
var bodyParty = snapToBody.bodySnap.boneSnappingList.Find(b => b.name.Equals(snapToBody.boneName));
if (bodyParty != null)
{
index = snapToBody.bodySnap.boneSnappingList.IndexOf(bodyParty) + 1;
snapToBody.boneToSnap = snapToBody.bodySnap.boneSnappingList[index - 1].bone;
}
GUILayout.BeginHorizontal("box");
GUI.enabled = index == 0;
snapToBody.boneToSnap = (Transform)EditorGUILayout.ObjectField(snapToBody.boneToSnap, typeof(Transform), true);
GUI.enabled = true;
EditorGUI.BeginChangeCheck();
index = EditorGUILayout.Popup(index, bones);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(snapToBody, "BoneSelected");
if (index > 0)
{
snapToBody.boneToSnap = snapToBody.bodySnap.boneSnappingList[index - 1].bone;
}
snapToBody.boneName = bones[index];
EditorUtility.SetDirty(snapToBody);
serializedObject.ApplyModifiedProperties();
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal("box");
GUI.enabled = snapToBody.boneToSnap;
if (snapToBody.boneToSnap && GUILayout.Button("SnapToPosition", EditorStyles.miniButtonLeft))
{
Undo.RecordObject(snapToBody.transform, "BoneTransformAlignment");
snapToBody.transform.position = snapToBody.boneToSnap.transform.position;
}
if (snapToBody.boneToSnap && GUILayout.Button("SnapToRotation", EditorStyles.miniButtonLeft))
{
Undo.RecordObject(snapToBody.transform, "BoneTransformAlignment");
snapToBody.transform.rotation = snapToBody.boneToSnap.transform.rotation;
}
GUILayout.EndHorizontal();
GUI.enabled = true;
}
catch { }
}
}
}
serializedObject.ApplyModifiedProperties();
if (GUI.skin != oldSkin)
{
GUI.skin = oldSkin;
}
}
}

View File

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

View File

@@ -0,0 +1,216 @@
using System.Collections.Generic;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
namespace Invector
{
[vClassHeader("Body Snapping Control", openClose = false)]
public class vBodySnappingControl : vMonoBehaviour
{
[vButton("Create New BodyStruct", "NewBodyStruct", typeof(vBodySnappingControl), false)]
[vButton("Load Bones", "LoadBones", typeof(vBodySnappingControl), false)]
//[vHelpBox("To create a new BodyStruct for a new Character to go: \n<b>*Menu Create/Invector/New Body Struct</b>, you can set for both Humanoid or Generic Rig")]
public vBodyStruct bodyStruct;
public bool showLabels;
[HideInInspector] public List<vBoneTransformSnapping> boneSnappingList = new List<vBoneTransformSnapping>();
private bool bonesIsLoaded;
protected virtual void Reset()
{
LoadBones();
}
#if UNITY_EDITOR
public void NewBodyStruct()
{
vBodyStruct newBodyStruct = ScriptableObject.CreateInstance<vBodyStruct>();
AssetDatabase.CreateAsset(newBodyStruct, "Assets/BodyStruct@" + gameObject.transform.parent.name + ".asset");
AssetDatabase.SaveAssets();
SerializedObject serializedObj = new SerializedObject(this);
this.bodyStruct = newBodyStruct;
serializedObj.ApplyModifiedProperties();
}
#endif
public virtual void LoadBones()
{
var animator = GetComponentInParent<Animator>();
var bones = bodyStruct ? bodyStruct.bones : vBodyStruct.GetHumanBones();
if (bodyStruct)
{
var needToRemove = boneSnappingList.FindAll(_b => !bones.Exists(_b2 => _b2.name.Equals(_b.name)));
for (int i = 0; i < needToRemove.Count; i++)
{
boneSnappingList.Remove(needToRemove[i]);
}
}
if (bones.Count > 0)
{
for (int i = 0; i < bones.Count; i++)
{
Transform bone = null;
if (bones[i].isHuman && animator && animator.isHuman)
{
bone = animator.GetBoneTransform(bones[i].humanBone);
}
else
{
bone = GetBoneByName(bones[i].genericBone);
}
vBoneTransformSnapping b = boneSnappingList.Find(_b => _b.name.Equals(bones[i].name));
if (b == null)
{
b = new vBoneTransformSnapping();
b.name = bones[i].name;
b.bone = bone;
boneSnappingList.Add(b);
}
else
{
b.bone = bone;
}
}
}
boneSnappingList = boneSnappingList
.OrderBy(x => x.bone != null && x.name.ToUpper().Contains("LEFT"))
.ThenBy(x => x.bone != null && x.name.ToUpper().Contains("RIGHT"))
.ToList();
if (!Application.isPlaying)
{
bonesIsLoaded = true;
}
}
protected virtual void Awake()
{
LoadBones();
SnapAll();
}
public virtual void SnapAll()
{
foreach (var bt in boneSnappingList)
{
bt.Snap();
}
}
public virtual Transform GetBone(string name)
{
if (!bonesIsLoaded)
{
LoadBones();
}
var bone = boneSnappingList.Find(b => b.name.Equals(name));
return bone != null ? bone.bone : null;
}
protected virtual Transform GetBoneByName(string name)
{
var animator = GetComponentInParent<Animator>();
if (!animator) return null;
var root = animator.GetBoneTransform(HumanBodyBones.Hips);
if (root == null)
{
root = animator.transform;
}
List<Transform> childrens = root.gameObject.GetComponentsInChildren<Transform>(true).vToList();
Transform t = null;
if (childrens.Count > 0)
{
if (!string.IsNullOrEmpty(name.Trim()))
{
string[] nameSplited = name.Trim().Split(';');
t = childrens.Find(child => ContainsName(nameSplited, child.gameObject.name.Trim()));
}
}
return t;
}
protected virtual bool ContainsName(string[] nameSplited, string targetName)
{
bool contains = false;
for (int i = 0; i < nameSplited.Length; i++)
{
if (targetName.Contains(nameSplited[i]))
{
contains = true;
break;
}
}
return contains;
}
[System.Serializable]
public class vBoneTransformSnapping
{
public string name;
public Transform bone;
public Transform target;
public Orientation orientation;
public UnityEngine.Events.UnityEvent onSnap;
#if UNITY_EDITOR
[SerializeField]
private bool showProperties;
#endif
public void Snap()
{
if (bone && target)
{
if (Application.isPlaying && target.parent != bone)
{
target.parent = bone;
onSnap.Invoke();
}
target.rotation = targetRotation;
target.position = bone.position;
}
}
public enum Orientation
{
Forward, Back, Right, Left, Up, Down
}
public Quaternion targetRotation
{
get
{
Quaternion rot = Quaternion.LookRotation(Vector3.forward);
Vector3 lookAt = Vector3.forward;
if (bone && target && bone.parent)
{
switch (orientation)
{
case Orientation.Back:
lookAt = Vector3.back;
break;
case Orientation.Right:
lookAt = Vector3.right;
break;
case Orientation.Left:
lookAt = Vector3.left;
break;
case Orientation.Up:
lookAt = Vector3.up;
break;
case Orientation.Down:
lookAt = Vector3.down;
break;
}
rot = Quaternion.LookRotation(bone.TransformDirection(lookAt), bone.up);
}
return rot;
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 80594385e4f69be409516ae62219c6f9
timeCreated: 1558653779
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,70 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
[CreateAssetMenu(menuName = "Invector/SnapBody/New Body Struct")]
public class vBodyStruct : ScriptableObject
{
public List<Bone> bones = new List<Bone>();
[System.Serializable]
public class Bone
{
public string name;
public HumanBodyBones humanBone;
public string genericBone;
public bool isHuman = true;
}
protected virtual void Reset()
{
bones.Clear();
bones = GetHumanBones();
}
#region Static
public static List<Bone> GetHumanBones()
{
List<Bone> bones = new List<Bone>();
string[] humanBoneName = System.Enum.GetNames(typeof(HumanBodyBones));
for (int i = 0; i < humanBoneName.Length; i++)
{
if (IsIgnoredBone(humanBoneName[i])) continue;
HumanBodyBones humanBone = HumanBodyBones.Chest;
if (humanBoneName[i].ToEnum(ref humanBone))
{
Bone b = new Bone();
b.isHuman = true;
b.name = humanBoneName[i];
b.genericBone = humanBoneName[i];
b.humanBone = humanBone;
bones.Add(b);
}
}
return bones.OrderBy(x => x.name.ToUpper().Contains("LEFT")).ThenBy(x => x.name.ToUpper().Contains("RIGHT")).ToList();
}
static string[] ignoreBones { get { return new string[] { "Thumb", "Distal", "Little", "Middle", "Index", "Ring", "Eye", "Toes", "Jaw", "LastBone" }; } }
static bool IsIgnoredBone(string bone)
{
bool ignored = false;
for (int i = 0; i < ignoreBones.Length; i++)
{
if (bone.Contains(ignoreBones[i]))
{
ignored = true;
break;
}
}
return ignored;
}
#endregion
}
public static class vBodyStructHelper
{
public static bool ToEnum<T>(this string value, ref T enumTarget)
{
var enumValue = System.Enum.Parse(typeof(T), value);
if (enumValue != null) enumTarget = (T)enumValue;
return enumValue != null;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0a71bb1e533fbeb47923da3d71727828
timeCreated: 1558679522
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 4bf53de60edd82845b73148913d56195, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using Invector;
using UnityEngine;
public class vSnapToBody : MonoBehaviour
{
public const string manuallyAssignBone = "ManuallyAssign";
public vBodySnappingControl bodySnap;
public Transform boneToSnap;
public string boneName;
private void Start()
{
bodySnap = transform.root.GetComponentInChildren<vBodySnappingControl>(true);
if (boneName != manuallyAssignBone)
{
if (bodySnap != null && bodySnap.boneSnappingList != null)
{
boneToSnap = bodySnap.GetBone(boneName);
}
}
if (boneToSnap)
{
transform.parent = boneToSnap;
}
}
}

View File

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

View File

@@ -0,0 +1,94 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0a71bb1e533fbeb47923da3d71727828, type: 3}
m_Name: Vbot_BodyBones
m_EditorClassIdentifier:
bones:
- name: Hips
humanBone: 0
genericBone: Hips
isHuman: 1
- name: Spine
humanBone: 7
genericBone: Spine
isHuman: 1
- name: Chest
humanBone: 8
genericBone: Chest
isHuman: 1
- name: Neck
humanBone: 9
genericBone: Neck
isHuman: 1
- name: Head
humanBone: 10
genericBone: Head
isHuman: 1
- name: UpperChest
humanBone: 54
genericBone: UpperChest
isHuman: 1
- name: RightUpperLeg
humanBone: 2
genericBone: RightUpperLeg
isHuman: 1
- name: RightLowerLeg
humanBone: 4
genericBone: RightLowerLeg
isHuman: 1
- name: RightFoot
humanBone: 6
genericBone: RightFoot
isHuman: 1
- name: RightShoulder
humanBone: 12
genericBone: RightShoulder
isHuman: 1
- name: RightUpperArm
humanBone: 14
genericBone: RightUpperArm
isHuman: 1
- name: RightLowerArm
humanBone: 16
genericBone: RightLowerArm
isHuman: 1
- name: RightHand
humanBone: 18
genericBone: RightHand
isHuman: 1
- name: LeftUpperLeg
humanBone: 1
genericBone: LeftUpperLeg
isHuman: 1
- name: LeftLowerLeg
humanBone: 3
genericBone: LeftLowerLeg
isHuman: 1
- name: LeftFoot
humanBone: 5
genericBone: LeftFoot
isHuman: 1
- name: LeftShoulder
humanBone: 11
genericBone: LeftShoulder
isHuman: 1
- name: LeftUpperArm
humanBone: 13
genericBone: LeftUpperArm
isHuman: 1
- name: LeftLowerArm
humanBone: 15
genericBone: LeftLowerArm
isHuman: 1
- name: LeftHand
humanBone: 17
genericBone: LeftHand
isHuman: 1

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c8f7df5fda0d3814bbbbc0501161e420
timeCreated: 1558678474
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: