FinalIK
parent
852d367595
commit
f5378c39b2
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71fb31411335fcb47a200e5c52ca6ec1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,159 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using RootMotion.FinalIK;
|
||||
|
||||
namespace Autohand {
|
||||
[DefaultExecutionOrder(2), RequireComponent(typeof(VRIK))]
|
||||
public class AutoHandVRIK : MonoBehaviour {
|
||||
public Hand rightHand;
|
||||
public Hand leftHand;
|
||||
[Tooltip("The transform (or a child transform) of the Tracked VR controller")]
|
||||
public Transform rightTrackedController;
|
||||
[Tooltip("The transform (or a child transform) of the Tracked VR controller")]
|
||||
public Transform leftTrackedController;
|
||||
|
||||
[HideInInspector, Tooltip("Should be a transform under the Auto Hand, can be used to adjust the IK offset so the hands connect with the arms properly (This is the point where the wrists follow the hands)")]
|
||||
public Transform rightIKTarget = null;
|
||||
[HideInInspector, Tooltip("Should be a transform under the Auto Hand, can be used to adjust the IK offset so the hands connect with the arms properly (This is the point where the wrists follow the hands)")]
|
||||
public Transform leftIKTarget = null;
|
||||
[HideInInspector, Tooltip("Should be a transform under the IK Character hierarchy, can be used to adjust the IK offset so the hands connect with the arms properly")]
|
||||
public Transform rightHandFollowTarget = null;
|
||||
[HideInInspector, Tooltip("Should be a transform under the IK Character hierarchy, can be used to adjust the IK offset so the hands connect with the arms properly")]
|
||||
public Transform leftHandFollowTarget = null;
|
||||
|
||||
|
||||
VRIK visibleIK;
|
||||
VRIK invisibleIK;
|
||||
bool isCopy = false;
|
||||
bool resetQueued = false;
|
||||
|
||||
public void DesignateCopy() {
|
||||
isCopy = true;
|
||||
}
|
||||
|
||||
void Start() {
|
||||
visibleIK = GetComponent<VRIK>();
|
||||
|
||||
if (!isCopy)
|
||||
SetupIKCopy();
|
||||
|
||||
if(AutoHandPlayer.Instance != null)
|
||||
visibleIK.transform.position -= Vector3.up * AutoHandPlayer.Instance.heightOffset;
|
||||
|
||||
if(!isCopy && AutoHandPlayer.Instance != null)
|
||||
AutoHandPlayer.Instance.OnSnapTurn += AutoPlayerResetIKEvent;
|
||||
|
||||
if(!isCopy && AutoHandPlayer.Instance != null)
|
||||
AutoHandPlayer.Instance.OnTeleported += AutoPlayerResetIKEvent;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AutoPlayerResetIKEvent(AutoHandPlayer player) {
|
||||
resetQueued = true;
|
||||
}
|
||||
|
||||
private void LateUpdate() {
|
||||
if(resetQueued) {
|
||||
visibleIK.solver.Reset();
|
||||
invisibleIK.solver.Reset();
|
||||
visibleIK.UpdateSolverExternal();
|
||||
invisibleIK.UpdateSolverExternal();
|
||||
|
||||
rightHand.SetMoveTo();
|
||||
rightHand.SetHandLocation(rightHand.moveTo.position, rightHand.moveTo.rotation);
|
||||
leftHand.SetMoveTo();
|
||||
leftHand.SetHandLocation(leftHand.moveTo.position, leftHand.moveTo.rotation);
|
||||
|
||||
resetQueued = false;
|
||||
}
|
||||
}
|
||||
//private void Update() {
|
||||
// if(resetQueued) {
|
||||
// invisibleIK.solver.Reset();
|
||||
// invisibleIK.solver.Update();
|
||||
// visibleIK.solver.Reset();
|
||||
// visibleIK.solver.Update();
|
||||
// }
|
||||
//}
|
||||
|
||||
void SetupIKCopy() {
|
||||
if(rightIKTarget == null)
|
||||
{
|
||||
rightIKTarget = new GameObject().transform;
|
||||
rightIKTarget.name = "rightIKTarget";
|
||||
rightIKTarget.transform.parent = rightHand.transform;
|
||||
|
||||
rightIKTarget.transform.localPosition = Vector3.zero;
|
||||
rightIKTarget.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
if (leftIKTarget == null)
|
||||
{
|
||||
leftIKTarget = new GameObject().transform;
|
||||
leftIKTarget.name = "leftIKTarget";
|
||||
leftIKTarget.transform.parent = leftHand.transform;
|
||||
|
||||
leftIKTarget.transform.localPosition = Vector3.zero;
|
||||
leftIKTarget.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
if (rightHandFollowTarget == null)
|
||||
{
|
||||
rightHandFollowTarget = new GameObject().transform;
|
||||
rightHandFollowTarget.name = "rightHandTarget";
|
||||
rightHandFollowTarget.transform.parent = rightHand.transform.parent;
|
||||
|
||||
rightHandFollowTarget.transform.localPosition = rightHand.transform.localPosition;
|
||||
rightHandFollowTarget.transform.localRotation = rightHand.transform.localRotation;
|
||||
}
|
||||
if (leftHandFollowTarget == null)
|
||||
{
|
||||
leftHandFollowTarget = new GameObject().transform;
|
||||
leftHandFollowTarget.name = "leftHandTarget";
|
||||
leftHandFollowTarget.transform.parent = leftHand.transform.parent;
|
||||
leftHandFollowTarget.transform.localPosition = leftHand.transform.localPosition;
|
||||
leftHandFollowTarget.transform.localRotation = leftHand.transform.localRotation;
|
||||
}
|
||||
|
||||
rightHand.transform.parent = visibleIK.transform.parent;
|
||||
leftHand.transform.parent = visibleIK.transform.parent;
|
||||
|
||||
visibleIK.references.rightHand = rightHandFollowTarget;
|
||||
visibleIK.references.leftHand = leftHandFollowTarget;
|
||||
|
||||
invisibleIK = Instantiate(visibleIK.gameObject, visibleIK.transform.parent).GetComponent<VRIK>();
|
||||
invisibleIK.name = "Hidden IK Copy (Auto Hand + VRIK requirement)";
|
||||
DeactivateEverything(invisibleIK.transform);
|
||||
invisibleIK.enabled = true;
|
||||
|
||||
|
||||
if (invisibleIK.CanGetComponent<AutoHandVRIK>(out var autoIK)) {
|
||||
autoIK.DesignateCopy();
|
||||
autoIK.enabled = true;
|
||||
rightHand.follow = autoIK.rightHandFollowTarget;
|
||||
leftHand.follow = autoIK.leftHandFollowTarget;
|
||||
autoIK.invisibleIK = invisibleIK;
|
||||
autoIK.visibleIK = visibleIK;
|
||||
}
|
||||
|
||||
visibleIK.solver.rightArm.target = rightIKTarget;
|
||||
visibleIK.solver.leftArm.target = leftIKTarget;
|
||||
invisibleIK.solver.rightArm.target = rightTrackedController;
|
||||
invisibleIK.solver.leftArm.target = leftTrackedController;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DeactivateEverything(Transform deactivate) {
|
||||
var behaviours = deactivate.GetComponents<Component>();
|
||||
var childBehaviours = deactivate.GetComponentsInChildren<Component>();
|
||||
for(int j = behaviours.Length - 1; j >= 0; j--)
|
||||
if(!(behaviours[j] is Animator) && !(behaviours[j] is VRIK) && !(behaviours[j] is AutoHandVRIK) && !(behaviours[j] is Transform))
|
||||
Destroy(behaviours[j]);
|
||||
for(int j = childBehaviours.Length - 1; j >= 0; j--)
|
||||
if(!(childBehaviours[j] is Animator) && !(childBehaviours[j] is VRIK) && !(childBehaviours[j] is AutoHandVRIK) && !(childBehaviours[j] is Transform))
|
||||
Destroy(childBehaviours[j]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 550477788ad312b4c9f8616f9b8eb215
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15b1b958630b36b45ad5d22e80afc709
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61bbdfe2a1a5b5948abfa4cae0ae82e0
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,2 @@
|
||||
This package requires the FinalIK asset:
|
||||
https://assetstore.unity.com/packages/tools/animation/final-ik-14290?gclid=Cj0KCQiAmpyRBhC-ARIsABs2EApHCXO_6XW-sbQe-B1sW0SI4sNfS_K2kPIi5HBHBWt-1YYfEwf-SkoaAmIKEALw_wcB&gclsrc=aw.ds
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d63aae31d176a246ad326b2b9ce5f80
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0422cfa295b1a24482dac8e3e90b2f6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bf028df46ae5644c9287714b674fed9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47bf04154c11c5e45b94b1aec2c0baf6
|
||||
folderAsset: yes
|
||||
timeCreated: 1516620867
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d2079bf8fd63d640a121f8fea6f5c5f
|
||||
folderAsset: yes
|
||||
timeCreated: 1516620916
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 490fde02f41ae014abec4edfce28648f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f66200036e67da4998b9ac08649304f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: addea154dd3a3e442abb7c12a65ebf8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab14efce3fefe4f4982f0fa6911d0cd4
|
||||
timeCreated: 1516617114
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27b32efee52144c4e934e6c3272ceb2c
|
||||
timeCreated: 1516356533
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 15001
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e468ef7e80a87f94588b5eeb3a423b91
|
||||
folderAsset: yes
|
||||
timeCreated: 1516621025
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f9e403f0f8255c42b90254abc55f528
|
||||
timeCreated: 1516435305
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 582052db0a6096149a7b2b75914ef3a6
|
||||
timeCreated: 1516263395
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efcc0ec5ed265a340a1412edb9110337
|
||||
timeCreated: 1516287616
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 15000
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c41cf13236c01a747b3dfb963402b3a0
|
||||
folderAsset: yes
|
||||
timeCreated: 1516620909
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4b02f60233a6cf4eb1c424f90323213
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3451f091c656bfc429396cc701ac5b8d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,69 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Humanoid Baker Clip Sampler
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters: []
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
m_StateMachine: {fileID: 110737558}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1102 &110235224
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Clip 1
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 739b2627204c24240aa40c4f67f59d0e, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1107 &110737558
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Base Layer
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 110235224}
|
||||
m_Position: {x: 300, y: 36, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 110235224}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24d41cb619dc9dc42bf10705eb128c97
|
||||
timeCreated: 1516284817
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bd8d9a8cbacde343967c95c4458318e
|
||||
timeCreated: 1517387718
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3349a7526568cf042bf8609694db3327
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea198996b9a58624b82f921e56faf4ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39b6548830366c04697b5de123deec0a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe88a087b0795174f9c8ec2369f4ccb2
|
||||
folderAsset: yes
|
||||
timeCreated: 1516620937
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcf5801ad3ff7fa43b06824f09d82160
|
||||
timeCreated: 1516619065
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f544a5bc87054e74ac2e415889ba75a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73b96cf8495867d429c9c5b31ff6d6da
|
||||
folderAsset: yes
|
||||
timeCreated: 1516621014
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 054c55a0c5c10dc4fafcfd81aeaaec56
|
||||
timeCreated: 1516620625
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7edb6cbf0a3b9924d8f631c4c00fd38a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8139af98945e154885b65eedbb102cc
|
||||
timeCreated: 1516265598
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 403e73ed4eb874619a26a7b37fbb9c35
|
||||
folderAsset: yes
|
||||
timeCreated: 1436186156
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,38 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector for AimIK.
|
||||
* */
|
||||
[CustomEditor(typeof(AimIK))]
|
||||
public class AimIKInspector : IKInspector {
|
||||
|
||||
private AimIK script { get { return target as AimIK; }}
|
||||
|
||||
protected override MonoBehaviour GetMonoBehaviour(out int executionOrder) {
|
||||
executionOrder = 9997;
|
||||
return script;
|
||||
}
|
||||
|
||||
protected override void OnApplyModifiedProperties() {
|
||||
if (!Application.isPlaying) script.solver.Initiate(script.transform);
|
||||
}
|
||||
|
||||
protected override void AddInspector() {
|
||||
// Draw the inspector for IKSolverAim
|
||||
IKSolverAimInspector.AddInspector(solver, !Application.isPlaying);
|
||||
|
||||
// Warning box
|
||||
string message = string.Empty;
|
||||
if (!script.solver.IsValid(ref message)) AddWarningBox(message);
|
||||
}
|
||||
|
||||
void OnSceneGUI() {
|
||||
// Draw the scene veiw helpers
|
||||
IKSolverAimInspector.AddScene(script.solver, new Color(1f, 0f, 0.5f, 1f), true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a8f3f357746148a98faf7ccd416a2a6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 079587d3635eb48c3a5c0d57f8c3cc6f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07bc62a41db738b488fc9430a0a20772
|
||||
timeCreated: 1528379362
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,115 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector for Biped IK.
|
||||
* */
|
||||
[CustomEditor(typeof(BipedIK))]
|
||||
public class BipedIKInspector : Editor {
|
||||
|
||||
private BipedIK script { get { return target as BipedIK; }}
|
||||
|
||||
private int selectedSolver = -1;
|
||||
|
||||
private SerializedProperty references, solvers;
|
||||
private SerializedProperty[] solversProps;
|
||||
private SerializedContent fixTransforms;
|
||||
|
||||
public void OnEnable() {
|
||||
if (serializedObject == null) return;
|
||||
|
||||
// Store the MonoScript for changing script execution order
|
||||
if (!Application.isPlaying) {
|
||||
MonoScript monoScript = MonoScript.FromMonoBehaviour(script);
|
||||
|
||||
// Changing the script execution order to make sure BipedIK always executes after any other script except FullBodyBipedIK
|
||||
int executionOrder = MonoImporter.GetExecutionOrder(monoScript);
|
||||
if (executionOrder != 9998) MonoImporter.SetExecutionOrder(monoScript, 9998);
|
||||
}
|
||||
|
||||
references = serializedObject.FindProperty("references");
|
||||
solvers = serializedObject.FindProperty("solvers");
|
||||
solversProps = BipedIKSolversInspector.FindProperties(solvers);
|
||||
fixTransforms = new SerializedContent(serializedObject.FindProperty("fixTransforms"), new GUIContent("Fix Transforms", "If true, will fix all the Transforms used by the solver to their initial state in each Update. This prevents potential problems with unanimated bones and animator culling with a small cost of performance."));
|
||||
|
||||
// Automatically detecting references
|
||||
if (!Application.isPlaying) {
|
||||
if (script.references.isEmpty) {
|
||||
BipedReferences.AutoDetectReferences(ref script.references, script.transform, new BipedReferences.AutoDetectParams(false, true));
|
||||
|
||||
references.isExpanded = true;
|
||||
solvers.isExpanded = false;
|
||||
for (int i = 0; i < solversProps.Length; i++) solversProps[i].isExpanded = false;
|
||||
|
||||
// Setting default values and initiating
|
||||
script.InitiateBipedIK();
|
||||
script.SetToDefaults();
|
||||
EditorUtility.SetDirty(script);
|
||||
} else script.InitiateBipedIK();
|
||||
|
||||
Warning.logged = false;
|
||||
|
||||
string message = string.Empty;
|
||||
if (Application.isPlaying) {
|
||||
if (BipedReferences.SetupError(script.references, ref message) || BipedReferences.SetupWarning(script.references, ref message)) {
|
||||
Warning.Log(message, script.references.root, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Override the default warning box
|
||||
private void AddWarningBox(string message) {
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Invalid/incomplete setup, can't initiate solver. " + message, EditorStyles.helpBox);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
Inspector.AddContent(fixTransforms);
|
||||
string message = string.Empty;
|
||||
|
||||
// Editing References
|
||||
if (BipedReferencesInspector.AddModifiedInspector(references)) {
|
||||
if (!Application.isPlaying) {
|
||||
Warning.logged = false;
|
||||
|
||||
if (!BipedReferences.SetupError(script.references, ref message)) {
|
||||
script.InitiateBipedIK();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (BipedReferences.SetupError(script.references, ref message)) {
|
||||
// Warning box
|
||||
AddWarningBox(message);
|
||||
Warning.Log(message, script.transform, false);
|
||||
} else {
|
||||
// Editing Solvers
|
||||
BipedIKSolversInspector.AddInspector(solvers, solversProps);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void OnSceneGUI() {
|
||||
if (!script.enabled) return;
|
||||
|
||||
// Draw the scene view helpers for the solvers
|
||||
BipedIKSolversInspector.AddScene(script.solvers, ref selectedSolver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5864bb0a05eb491697063685c4d6cb3
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,120 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector and scene view tools for Biped IK Solvers.
|
||||
* */
|
||||
public class BipedIKSolversInspector: IKSolverInspector {
|
||||
|
||||
/*
|
||||
* Returns all solvers SeiralizedProperties
|
||||
* */
|
||||
public static SerializedProperty[] FindProperties(SerializedProperty prop) {
|
||||
SerializedProperty[] props = new SerializedProperty[8] {
|
||||
prop.FindPropertyRelative("leftFoot"),
|
||||
prop.FindPropertyRelative("rightFoot"),
|
||||
prop.FindPropertyRelative("leftHand"),
|
||||
prop.FindPropertyRelative("rightHand"),
|
||||
prop.FindPropertyRelative("spine"),
|
||||
prop.FindPropertyRelative("aim"),
|
||||
prop.FindPropertyRelative("lookAt"),
|
||||
prop.FindPropertyRelative("pelvis"),
|
||||
};
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws the custom inspector for BipedIK.Solvers
|
||||
* */
|
||||
public static void AddInspector(SerializedProperty prop, SerializedProperty[] props) {
|
||||
EditorGUILayout.PropertyField(prop, false);
|
||||
|
||||
if (prop.isExpanded) {
|
||||
for (int i = 0; i < props.Length; i++) {
|
||||
BeginProperty(props[i]);
|
||||
if (props[i].isExpanded) {
|
||||
if (i <= 3) IKSolverLimbInspector.AddInspector(props[i], false, false);
|
||||
else if (i == 4) IKSolverHeuristicInspector.AddInspector(props[i], false, false);
|
||||
else if (i == 5) IKSolverAimInspector.AddInspector(props[i], false);
|
||||
else if (i == 6) IKSolverLookAtInspector.AddInspector(props[i], false, false);
|
||||
else if (i == 7) ConstraintsInspector.AddInspector(props[i]);
|
||||
}
|
||||
EndProperty(props[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws the scene view helpers for BipedIK.Solvers
|
||||
* */
|
||||
public static void AddScene(BipedIKSolvers solvers, ref int selected) {
|
||||
// Draw limbs
|
||||
for (int i = 0; i < solvers.limbs.Length; i++) {
|
||||
IKSolverLimbInspector.AddScene(solvers.limbs[i] as IKSolverLimb, GetSolverColor(i), selected == i);
|
||||
}
|
||||
|
||||
// Draw spine
|
||||
IKSolverHeuristicInspector.AddScene(solvers.spine, GetSolverColor(4), selected == 4);
|
||||
|
||||
// Draw look at
|
||||
IKSolverLookAtInspector.AddScene(solvers.lookAt, GetSolverColor(5), selected == 5);
|
||||
|
||||
// Draw aim
|
||||
IKSolverAimInspector.AddScene(solvers.aim, GetSolverColor(6), selected == 6);
|
||||
|
||||
// Draw constraints
|
||||
ConstraintsInspector.AddScene(solvers.pelvis, GetSolverColor(7), selected == 7);
|
||||
|
||||
// Selecting solvers
|
||||
if (Application.isPlaying) {
|
||||
for (int i = 0; i < solvers.ikSolvers.Length; i++) {
|
||||
Handles.color = GetSolverColor(i);
|
||||
if (solvers.ikSolvers[i].GetIKPositionWeight() > 0 && selected != i && solvers.ikSolvers[i].initiated) {
|
||||
if (Inspector.DotButton(solvers.ikSolvers[i].GetIKPosition(), Quaternion.identity, GetHandleSize(solvers.ikSolvers[i].GetIKPosition()), GetHandleSize(solvers.ikSolvers[i].GetIKPosition()))) selected = i;
|
||||
}
|
||||
}
|
||||
|
||||
if ((solvers.pelvis.positionWeight > 0 || solvers.pelvis.rotationWeight > 0) && selected != solvers.ikSolvers.Length) {
|
||||
Handles.color = GetSolverColor(7);
|
||||
if (Inspector.DotButton(solvers.pelvis.position, Quaternion.identity, GetHandleSize(solvers.pelvis.position), GetHandleSize(solvers.pelvis.position))) selected = solvers.ikSolvers.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the color of the solver at index.
|
||||
* */
|
||||
private static Color GetSolverColor(int index) {
|
||||
if (index == 0 || index == 2) return new Color(0f, 0.8f, 1f, 1f); // Left limb
|
||||
if (index == 1 || index == 3) return new Color(0.3f, 1f, 0.3f, 1f); // Right limb
|
||||
if (index == 4) return new Color(1f, 0.5f, 0.5f, 1f); // Spine
|
||||
if (index == 5) return new Color(0.2f, 0.5f, 1f, 1f); // Look At
|
||||
if (index == 6) return new Color(1f, 0f, 0.5f, 1f); // Aim
|
||||
if (index == 7) return new Color(0.9f, 0.9f, 0.9f, 1f); // Pelvis
|
||||
return Color.white;
|
||||
}
|
||||
|
||||
/*
|
||||
* Begin property box
|
||||
* */
|
||||
private static void BeginProperty(SerializedProperty prop) {
|
||||
EditorGUI.indentLevel = 1;
|
||||
EditorGUILayout.BeginVertical("Box");
|
||||
|
||||
EditorGUILayout.PropertyField(prop, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* End Property box
|
||||
* */
|
||||
private static void EndProperty(SerializedProperty prop) {
|
||||
EditorGUILayout.EndVertical();
|
||||
if (prop.isExpanded) EditorGUILayout.Space();
|
||||
EditorGUI.indentLevel = 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0569aef68e5c24672b37607a948d3c92
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,38 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector for CCDIK.
|
||||
* */
|
||||
[CustomEditor(typeof(CCDIK))]
|
||||
public class CCDIKInspector : IKInspector {
|
||||
|
||||
private CCDIK script { get { return target as CCDIK; }}
|
||||
|
||||
protected override MonoBehaviour GetMonoBehaviour(out int executionOrder) {
|
||||
executionOrder = 9997;
|
||||
return script;
|
||||
}
|
||||
|
||||
protected override void OnApplyModifiedProperties() {
|
||||
if (!Application.isPlaying) script.solver.Initiate(script.transform);
|
||||
}
|
||||
|
||||
protected override void AddInspector() {
|
||||
// Draw the inspector for IKSolverCCD
|
||||
IKSolverHeuristicInspector.AddInspector(solver, !Application.isPlaying, true);
|
||||
|
||||
// Warning box
|
||||
string message = string.Empty;
|
||||
if (!script.solver.IsValid(ref message)) AddWarningBox(message);
|
||||
}
|
||||
|
||||
void OnSceneGUI() {
|
||||
// Draw the scene veiw helpers
|
||||
IKSolverHeuristicInspector.AddScene(script.solver, Color.cyan, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90fdc724098474c78a5ae764777a5008
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector and scene view tools for Constraints
|
||||
* */
|
||||
public class ConstraintsInspector: IKSolverInspector {
|
||||
|
||||
#region Public methods
|
||||
|
||||
/*
|
||||
* Draws the custom inspector for Constraints
|
||||
* */
|
||||
public static void AddInspector(SerializedProperty prop) {
|
||||
if (!prop.isExpanded) return;
|
||||
|
||||
// Main properties
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("target"), new GUIContent("Target", "Target transform for the pelvis (optional). If assigned, will overwrite pelvis.position in each update."));
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("positionOffset"), new GUIContent("Pos Offset", "Pelvis offset from animation. If there is no animation playing and Fix Transforms is unchecked, it will make the character fly away."));
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("positionWeight"), new GUIContent("Pos Weight", "The weight of lerping the pelvis to bipedIK.solvers.pelvis.position."));
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("rotationOffset"), new GUIContent("Rot Offset", "Pelvis rotation offset from animation. If there is no animation playing and Fix Transforms is unchecked, it will make the character spin."));
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("rotationWeight"), new GUIContent("Rot Weight", "The weiight of slerping the pelvis to bipedIK.solver.pelvis.rotation."));
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws the scene view helpers for Constraints
|
||||
* */
|
||||
public static void AddScene(Constraints constraints, Color color, bool modifiable) {
|
||||
if (!constraints.IsValid()) return;
|
||||
|
||||
Handles.color = color;
|
||||
GUI.color = color;
|
||||
|
||||
// Transform
|
||||
Inspector.SphereCap(0, constraints.transform.position, Quaternion.identity, GetHandleSize(constraints.transform.position));
|
||||
|
||||
// Target
|
||||
Handles.color = new Color(color.r, color.g, color.b, color.a * constraints.positionWeight);
|
||||
Handles.DrawLine(constraints.transform.position, constraints.position);
|
||||
Handles.color = color;
|
||||
|
||||
if (Application.isPlaying && modifiable && (constraints.positionWeight > 0 || constraints.rotationWeight > 0)) {
|
||||
Inspector.CubeCap(0, constraints.position, Quaternion.Euler(constraints.rotation), GetHandleSize(constraints.transform.position));
|
||||
|
||||
// Manipulating position and rotation
|
||||
switch(Tools.current) {
|
||||
case Tool.Move:
|
||||
constraints.position = Handles.PositionHandle(constraints.position, Quaternion.Euler(constraints.rotation));
|
||||
break;
|
||||
case Tool.Rotate:
|
||||
constraints.rotation = Handles.RotationHandle(Quaternion.Euler(constraints.rotation), constraints.position).eulerAngles;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Handles.color = Color.white;
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
|
||||
#endregion Public methods
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9903cbc6483347caadff80dc461c23f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bdb775e141709e40972e0ed29aecc04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,38 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector for FABRIK.
|
||||
* */
|
||||
[CustomEditor(typeof(FABRIK))]
|
||||
public class FABRIKInspector : IKInspector {
|
||||
|
||||
private FABRIK script { get { return target as FABRIK; }}
|
||||
|
||||
protected override MonoBehaviour GetMonoBehaviour(out int executionOrder) {
|
||||
executionOrder = 9997;
|
||||
return script;
|
||||
}
|
||||
|
||||
protected override void OnApplyModifiedProperties() {
|
||||
if (!Application.isPlaying) script.solver.Initiate(script.transform);
|
||||
}
|
||||
|
||||
protected override void AddInspector() {
|
||||
// Draw the inspector for IKSolverFABRIK
|
||||
IKSolverHeuristicInspector.AddInspector(solver, !Application.isPlaying, false);
|
||||
|
||||
// Warning box
|
||||
string message = string.Empty;
|
||||
if (!script.solver.IsValid(ref message)) AddWarningBox(message);
|
||||
}
|
||||
|
||||
void OnSceneGUI() {
|
||||
// Draw the scene veiw helpers
|
||||
IKSolverHeuristicInspector.AddScene(script.solver, Color.cyan, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35028d751824a4378ab31047db78a4ac
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97f4f303b23be42ddabd838850dd9c03
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa6fa0b5b780d4401b031336dd86cfa4
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1af94c10682a46c0849b487ad86dd40
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43cffbb650ededd4bbfb46bf19a74782
|
||||
timeCreated: 1487065127
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f11a75612fdb244758156ae2d26a95ec
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2d73247f9c4b4190a30f8e4cc054bc5
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,67 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Base abstract class for IK component inspectors.
|
||||
* */
|
||||
public abstract class IKInspector : Editor {
|
||||
|
||||
protected abstract void AddInspector();
|
||||
protected abstract MonoBehaviour GetMonoBehaviour(out int executionOrder);
|
||||
|
||||
protected SerializedProperty solver;
|
||||
protected SerializedContent fixTransforms;
|
||||
protected SerializedContent[] content;
|
||||
protected virtual void OnApplyModifiedProperties() {}
|
||||
protected virtual void OnEnableVirtual() {}
|
||||
|
||||
private MonoScript monoScript;
|
||||
|
||||
void OnEnable() {
|
||||
if (serializedObject == null) return;
|
||||
|
||||
// Changing the script execution order
|
||||
if (!Application.isPlaying) {
|
||||
int executionOrder = 0;
|
||||
monoScript = MonoScript.FromMonoBehaviour(GetMonoBehaviour(out executionOrder));
|
||||
int currentExecutionOrder = MonoImporter.GetExecutionOrder(monoScript);
|
||||
if (currentExecutionOrder != executionOrder) MonoImporter.SetExecutionOrder(monoScript, executionOrder);
|
||||
}
|
||||
|
||||
solver = serializedObject.FindProperty("solver");
|
||||
fixTransforms = new SerializedContent(serializedObject.FindProperty("fixTransforms"), new GUIContent("Fix Transforms", "If true, will fix all the Transforms used by the solver to their initial state in each Update. This prevents potential problems with unanimated bones and animator culling with a small cost of performance. Not recommended for CCD and FABRIK solvers."));
|
||||
|
||||
OnEnableVirtual();
|
||||
}
|
||||
|
||||
// Override the default warning box
|
||||
protected virtual void AddWarningBox(string message) {
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("Invalid/incomplete setup, can not initiate the solver. " + message, EditorStyles.helpBox);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
#region Inspector
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
if (serializedObject == null) return;
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
Inspector.AddContent(fixTransforms);
|
||||
|
||||
AddInspector();
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties()) {
|
||||
OnApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Inspector
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00e26cb6b10c641c49833ea4316e25cf
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,103 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector and scene view tools for IKSolverAim
|
||||
* */
|
||||
public class IKSolverAimInspector: IKSolverInspector {
|
||||
|
||||
#region Public methods
|
||||
|
||||
/// <summary>
|
||||
/// Draws the custom inspector for IKSolverAim
|
||||
/// </summary>
|
||||
public static void AddInspector(SerializedProperty prop, bool editHierarchy) {
|
||||
IKSolverHeuristicInspector.AddTarget(prop);
|
||||
if (!prop.FindPropertyRelative("XY").boolValue) EditorGUILayout.PropertyField(prop.FindPropertyRelative("poleTarget"), new GUIContent("Pole Target", "If assigned, will automatically set polePosition to the position of this Transform."));
|
||||
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("transform"), new GUIContent("Aim Transform", "The transform that you want to be aimed at the target. Needs to be a lineal descendant of the bone hierarchy. For example, if you wish to aim a gun, it should be the gun, one of its children or the hand bone."));
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("axis"), new GUIContent("Axis", "The local axis of the Transform that you want to be aimed at IKPosition."));
|
||||
if (!prop.FindPropertyRelative("XY").boolValue) EditorGUILayout.PropertyField(prop.FindPropertyRelative("poleAxis"), new GUIContent("Pole Axis", "Keeps that axis of the Aim Transform directed at the polePosition."));
|
||||
|
||||
EditorGUILayout.Space();
|
||||
IKSolverHeuristicInspector.AddIKPositionWeight(prop);
|
||||
|
||||
if (!prop.FindPropertyRelative("XY").boolValue) EditorGUILayout.PropertyField(prop.FindPropertyRelative("poleWeight"), new GUIContent("Pole Weight", "The weight of the Pole."));
|
||||
|
||||
IKSolverHeuristicInspector.AddProps(prop);
|
||||
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("clampWeight"), new GUIContent("Clamp Weight", "Clamping rotation of the solver. 0 is free rotation, 1 is completely clamped to transform axis."));
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("clampSmoothing"), new GUIContent("Clamp Smoothing", "Number of sine smoothing iterations applied on clamping to make the clamping point smoother."));
|
||||
|
||||
IKSolverHeuristicInspector.AddBones(prop, editHierarchy, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the scene view helpers for IKSolverAim
|
||||
/// </summary>
|
||||
public static void AddScene(IKSolverAim solver, Color color, bool modifiable) {
|
||||
// Protect from null reference errors
|
||||
if (solver.transform == null) return;
|
||||
if (Application.isPlaying && !solver.initiated) return;
|
||||
|
||||
if (!Application.isPlaying) {
|
||||
string message = string.Empty;
|
||||
if (!solver.IsValid(ref message)) return;
|
||||
}
|
||||
|
||||
Handles.color = color;
|
||||
GUI.color = color;
|
||||
|
||||
// Display the bones
|
||||
for (int i = 0; i < solver.bones.Length; i++) {
|
||||
IKSolver.Bone bone = solver.bones[i];
|
||||
|
||||
if (i < solver.bones.Length - 1) Handles.DrawLine(bone.transform.position, solver.bones[i + 1].transform.position);
|
||||
Inspector.SphereCap(0, solver.bones[i].transform.position, Quaternion.identity, GetHandleSize(solver.bones[i].transform.position));
|
||||
}
|
||||
|
||||
if (solver.axis != Vector3.zero) Inspector.ConeCap(0, solver.transform.position, Quaternion.LookRotation(solver.transform.rotation * solver.axis), GetHandleSize(solver.transform.position) * 2f);
|
||||
|
||||
// Selecting joint and manipulating IKPosition
|
||||
if (Application.isPlaying && solver.IKPositionWeight > 0) {
|
||||
if (modifiable) {
|
||||
Inspector.SphereCap(0, solver.IKPosition, Quaternion.identity, GetHandleSize(solver.IKPosition));
|
||||
|
||||
// Manipulating position
|
||||
solver.IKPosition = Handles.PositionHandle(solver.IKPosition, Quaternion.identity);
|
||||
}
|
||||
|
||||
// Draw a transparent line from transform to IKPosition
|
||||
Handles.color = new Color(color.r, color.g, color.b, color.a * solver.IKPositionWeight);
|
||||
Handles.DrawLine(solver.bones[solver.bones.Length - 1].transform.position, solver.transform.position);
|
||||
Handles.DrawLine(solver.transform.position, solver.IKPosition);
|
||||
}
|
||||
|
||||
Handles.color = color;
|
||||
|
||||
// Pole
|
||||
if (Application.isPlaying && solver.poleWeight > 0f) {
|
||||
if (modifiable) {
|
||||
Inspector.SphereCap(0, solver.polePosition, Quaternion.identity, GetHandleSize(solver.IKPosition) * 0.5f);
|
||||
|
||||
// Manipulating position
|
||||
solver.polePosition = Handles.PositionHandle(solver.polePosition, Quaternion.identity);
|
||||
}
|
||||
|
||||
// Draw a transparent line from transform to polePosition
|
||||
Handles.color = new Color(color.r, color.g, color.b, color.a * solver.poleWeight);
|
||||
Handles.DrawLine(solver.transform.position, solver.polePosition);
|
||||
}
|
||||
|
||||
Handles.color = Color.white;
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
|
||||
#endregion Public methods
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13082609a38964d0486119efce14e42c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2096c71e8e55def4bafe5d7f1604ea55
|
||||
timeCreated: 1528379406
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47b6cc68611af428d82361a2eb3d8505
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 533c5d8f60bd14648a10c7c1ad3f9ee5
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a32242b195b44820b383881d973c731
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,104 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Custom inspector and scene view tools for IK solvers extending IKSolverHeuristic
|
||||
* */
|
||||
public class IKSolverHeuristicInspector: IKSolverInspector {
|
||||
|
||||
#region Public methods
|
||||
|
||||
/*
|
||||
* Draws the custom inspector for IKSolverHeuristic
|
||||
* */
|
||||
public static void AddInspector(SerializedProperty prop, bool editHierarchy, bool editWeights) {
|
||||
AddTarget(prop);
|
||||
AddIKPositionWeight(prop);
|
||||
AddProps(prop);
|
||||
AddBones(prop, editHierarchy, editWeights);
|
||||
}
|
||||
|
||||
public static void AddTarget(SerializedProperty prop) {
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("target"), new GUIContent("Target", "The target Transform. Solver IKPosition will be automatically set to the position of the target."));
|
||||
}
|
||||
|
||||
public static void AddIKPositionWeight(SerializedProperty prop) {
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("IKPositionWeight"), new GUIContent("Weight", "Solver weight for smooth blending."));
|
||||
}
|
||||
|
||||
public static void AddProps(SerializedProperty prop) {
|
||||
AddClampedFloat(prop.FindPropertyRelative("tolerance"), new GUIContent("Tolerance", "Minimum offset from last reached position. Will stop solving if offset is less than tolerance. If tolerance is zero, will iterate until maxIterations."));
|
||||
AddClampedInt(prop.FindPropertyRelative("maxIterations"), new GUIContent("Max Iterations", "Max solver iterations per frame."), 0, int.MaxValue);
|
||||
}
|
||||
|
||||
public static void AddBones(SerializedProperty prop, bool editHierarchy, bool editWeights) {
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("useRotationLimits"), new GUIContent("Use Rotation Limits", "If true, rotation limits (if existing) will be applied on each iteration."));
|
||||
EditorGUILayout.PropertyField(prop.FindPropertyRelative("XY"), new GUIContent("2D", "If true, will solve only in the XY plane."));
|
||||
|
||||
EditorGUILayout.Space();
|
||||
weights = editWeights;
|
||||
if (editHierarchy || editWeights) {
|
||||
AddArray(prop.FindPropertyRelative("bones"), new GUIContent("Bones", string.Empty), editHierarchy, false, null, OnAddToArrayBone, DrawArrayElementLabelBone);
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws the scene view helpers for IKSolverHeuristic
|
||||
* */
|
||||
public static void AddScene(IKSolverHeuristic solver, Color color, bool modifiable) {
|
||||
// Protect from null reference errors
|
||||
if (Application.isPlaying && !solver.initiated) return;
|
||||
if (!Application.isPlaying && !solver.IsValid()) return;
|
||||
|
||||
Handles.color = color;
|
||||
GUI.color = color;
|
||||
|
||||
// Display the bones
|
||||
for (int i = 0; i < solver.bones.Length; i++) {
|
||||
IKSolver.Bone bone = solver.bones[i];
|
||||
|
||||
if (i < solver.bones.Length - 1) Handles.DrawLine(bone.transform.position, solver.bones[i + 1].transform.position);
|
||||
Inspector.SphereCap(0, solver.bones[i].transform.position, Quaternion.identity, GetHandleSize(solver.bones[i].transform.position));
|
||||
}
|
||||
|
||||
// Selecting joint and manipulating IKPosition
|
||||
if (Application.isPlaying && solver.IKPositionWeight > 0) {
|
||||
if (modifiable) {
|
||||
Inspector.CubeCap(0, solver.IKPosition, solver.GetRoot().rotation, GetHandleSize(solver.IKPosition));
|
||||
|
||||
// Manipulating position
|
||||
if (solver.target == null) solver.IKPosition = Handles.PositionHandle(solver.IKPosition, Quaternion.identity);
|
||||
}
|
||||
|
||||
// Draw a transparent line from last bone to IKPosition
|
||||
Handles.color = new Color(color.r, color.g, color.b, color.a * solver.IKPositionWeight);
|
||||
Handles.DrawLine(solver.bones[solver.bones.Length - 1].transform.position, solver.IKPosition);
|
||||
}
|
||||
|
||||
Handles.color = Color.white;
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
|
||||
#endregion Public methods
|
||||
|
||||
private static bool weights;
|
||||
|
||||
private static void DrawArrayElementLabelBone(SerializedProperty bone, bool editHierarchy) {
|
||||
AddObjectReference(bone.FindPropertyRelative("transform"), GUIContent.none, editHierarchy, 0, weights? 100: 200);
|
||||
if (weights) AddWeightSlider(bone.FindPropertyRelative("weight"));
|
||||
}
|
||||
|
||||
private static void OnAddToArrayBone(SerializedProperty bone) {
|
||||
bone.FindPropertyRelative("weight").floatValue = 1f;
|
||||
}
|
||||
|
||||
private static void AddWeightSlider(SerializedProperty prop) {
|
||||
GUILayout.Label("Weight", GUILayout.Width(45));
|
||||
EditorGUILayout.PropertyField(prop, GUIContent.none);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5806071df7484ff0bfa7330e9adb04e
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
namespace RootMotion.FinalIK {
|
||||
|
||||
/*
|
||||
* Contains helper methods for managing IKSolver's fields.
|
||||
* */
|
||||
public class IKSolverInspector: Inspector {
|
||||
|
||||
public static float GetHandleSize(Vector3 position) {
|
||||
float s = HandleUtility.GetHandleSize(position) * 0.1f;
|
||||
return Mathf.Lerp(s, 0.025f, 0.2f);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8fadad0d2804439bad44738bf137eb3
|
||||
MonoImporter:
|
||||
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
Loading…
Reference in New Issue