Example #1
0
            /// <summary>
            /// Draw the object field that will allow the user to drag a transform from the scene and attach it to the hand binder data
            /// </summary>
            /// <param name="name"></param>
            /// <param name="boundBone"></param>
            /// <param name="autoAssignChildren"></param>
            /// <param name="fingerID"></param>
            /// <param name="boneID"></param>
            void DrawObjectField(string name, ref BoundBone boundBone, bool autoAssignChildren = false, int fingerID = 0, int boneID = 0)
            {
                GUILayout.BeginHorizontal();
                GUI.color = boundBone.boundTransform != null ? Color.green : Color.white;

                GUILayout.Label(name, editorSkin.label);
                GUI.color = Color.white;
                var newTransform = (Transform)EditorGUILayout.ObjectField(boundBone.boundTransform, typeof(Transform), true, GUILayout.MaxWidth(EditorGUIUtility.labelWidth * 2));

                if (newTransform != boundBone.boundTransform)
                {
                    Undo.RegisterFullObjectHierarchyUndo(handBinder, "Bound Object");
                    boundBone = HandBinderAutoBinder.AssignBoundBone(newTransform);

                    if (boundBone.boundTransform != null)
                    {
                        if (autoAssignChildren)
                        {
                            AutoAssignChildrenBones(newTransform, fingerID, boneID);
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }
Example #2
0
            /// <summary>
            /// Automatically assign any children of the selected transform to the hand binder for the user
            /// </summary>
            /// <param name="newT"></param>
            /// <param name="fingerID"></param>
            /// <param name="boneID"></param>
            private void AutoAssignChildrenBones(Transform newT, int fingerID, int boneID)
            {
                var firstChildList = new List <Transform>()
                {
                    newT
                };

                firstChildList = GetFirstChildren(newT, ref firstChildList);
                for (int i = 0; i < firstChildList.Count; i++)
                {
                    if (boneID + i <= 3)
                    {
                        handBinder.BoundHand.fingers[fingerID].boundBones[boneID + i] = HandBinderAutoBinder.AssignBoundBone(firstChildList[i]);
                    }
                }
            }