public override string ToString() { var name = Name != null ? Name.Name + ": " : ""; var genArgs = BoundTypes.Select(arg => arg.ToString()).InterleaveCommas(); return($"{name}{BaseType.ToString()}<{genArgs}>"); }
/// <summary> /// Draw any bone offsets that the user want to set up /// </summary> void DrawBoneOffsets() { for (int offsetIndex = 0; offsetIndex < offsets.arraySize; offsetIndex++) { SerializedProperty boundType = offsets.GetArrayElementAtIndex(offsetIndex); BoundTypes previousBoundType = myTarget.Offsets[offsetIndex]; SerializedProperty offsetProperty = BoundTypeToOffsetProperty((BoundTypes)boundType.intValue); SerializedProperty offsetRotation = offsetProperty.FindPropertyRelative("rotation"); SerializedProperty offsetPosition = offsetProperty.FindPropertyRelative("position"); GUILayout.BeginVertical(editorSkin.box); GUILayout.BeginHorizontal(editorSkin.box); EditorGUILayout.PropertyField(boundType, GUIContent.none, editorSkin); if (GUILayout.Button("-", editorSkin.button)) { if (boundType.intValue != (int)BoundTypes.WRIST) { offsetRotation.vector3Value = Vector3.zero; offsetPosition.vector3Value = Vector3.zero; } offsets.DeleteArrayElementAtIndex(offsetIndex); break; } GUILayout.EndHorizontal(); //Check to see if the user has changed the value if ((int)previousBoundType != boundType.intValue) { //Check to see if any of the offsets are the same as this one if (myTarget.Offsets.Any(x => (int)x == boundType.intValue)) { boundType.intValue = (int)previousBoundType; } else { offsetRotation.vector3Value = Vector3.zero; offsetPosition.vector3Value = Vector3.zero; offsetProperty = BoundTypeToOffsetProperty((BoundTypes)boundType.intValue); offsetRotation = offsetProperty.FindPropertyRelative("rotation"); offsetPosition = offsetProperty.FindPropertyRelative("position"); } } EditorGUILayout.PropertyField(offsetPosition, editorSkin); EditorGUILayout.PropertyField(offsetRotation, editorSkin); GUILayout.EndVertical(); EditorGUILayout.Space(); GUILayout.Label(dividerLine); EditorGUILayout.Space(); } }
/// <summary> /// Convert a BoundType to the offsetProperty for the bound transform /// </summary> /// <param name="id"></param> /// <returns></returns> private SerializedProperty BoundTypeToOffsetProperty(BoundTypes boundType) { if (boundType == BoundTypes.WRIST) { return(boundHand.FindPropertyRelative("wrist").FindPropertyRelative("offset")); } else if (boundType == BoundTypes.ELBOW) { return(boundHand.FindPropertyRelative("elbow").FindPropertyRelative("offset")); } else if (!HandBinderUtilities.boundTypeMapping.ContainsKey(boundType)) { return(null); } (Finger.FingerType fingerType, Bone.BoneType boneType)fingerBoneType = HandBinderUtilities.boundTypeMapping[boundType]; return(FingerOffsetPropertyFromLeapTypes(fingerBoneType.fingerType, fingerBoneType.boneType)); }
/// <summary> /// Gets html string placed between passed strings /// </summary> /// <param name="originalString">String to be processed.</param> /// <param name="before">Before string</param> /// <param name="after">After string</param> /// <param name="boundType">BoundTypes value</param> /// <param name="comparison">StringComparison type</param> /// <returns>First found Html string</returns> public static string GetHtmlString(this string originalString, string before, string after, BoundTypes boundType = BoundTypes.None, StringComparison comparison = StringComparison.OrdinalIgnoreCase) { if (string.IsNullOrEmpty(originalString)) { return(string.Empty); } if (string.IsNullOrEmpty(before)) { return(string.Empty); } if (string.IsNullOrEmpty(after)) { return(string.Empty); } int a = originalString.IndexOf(before, 0, comparison); if (a == -1) { return(string.Empty); } int val_start_idx = a + before.Length; int b = originalString.IndexOf(after, val_start_idx, comparison); if (b == -1) { return(string.Empty); } int backup_a = originalString.LastIndexOf(before, b - 1, b - a, comparison); if (backup_a != -1) { a = backup_a; val_start_idx = a + before.Length; } string[] bx = new string[] { string.Empty, before, string.Empty, before }; string[] ax = new string[] { string.Empty, string.Empty, after, after }; return(string.Concat(bx[(int)boundType], originalString.Substring(val_start_idx, b - val_start_idx), ax[(int)boundType]).Trim()); }
private void ShowFineTuningOptions() { //Draw the fine tuning options fineTuning.boolValue = GUILayout.Toggle(fineTuning.boolValue, !fineTuning.boolValue ? "Show Fine Tuning Options" : "Hide Fine Tuning Options", subButtonStyle); EditorGUILayout.Space(); if (fineTuning.boolValue) { EditorGUILayout.Space(); GUI.color = Color.white; GUILayout.BeginVertical("Box"); EditorGUILayout.PropertyField(boundHand.FindPropertyRelative("wrist").FindPropertyRelative("offset").FindPropertyRelative("position"), new GUIContent("Wrist Position Offset")); EditorGUILayout.PropertyField(boundHand.FindPropertyRelative("wrist").FindPropertyRelative("offset").FindPropertyRelative("rotation"), new GUIContent("Wrist Rotation Offset")); EditorGUILayout.Space(); GUI.color = previousCol; GUILayout.EndVertical(); EditorGUILayout.PropertyField(globalFingerRotationOffset); EditorGUILayout.Space(); if (Selection.gameObjects.Length == 1 && GUILayout.Button("Recalculate Offsets")) { Undo.RegisterFullObjectHierarchyUndo(myTarget.gameObject, "Recalculate Offsets"); HandBinderAutoRigger.EstimateWristRotationOffset(myTarget); } EditorGUILayout.Space(); GUILayout.Label(dividerLine); EditorGUILayout.Space(); for (int offsetIndex = 0; offsetIndex < offsets.arraySize; offsetIndex++) { SerializedProperty boundType = offsets.GetArrayElementAtIndex(offsetIndex); BoundTypes previousBoundType = myTarget.offsets[offsetIndex]; SerializedProperty offsetProperty = BoundTypeToOffsetProperty((BoundTypes)boundType.intValue); SerializedProperty offsetRotation = offsetProperty.FindPropertyRelative("rotation"); SerializedProperty offsetPosition = offsetProperty.FindPropertyRelative("position"); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal("Box"); EditorGUILayout.PropertyField(boundType, GUIContent.none); if (GUILayout.Button(EditorGUIUtility.IconContent("d_Toolbar Minus"))) { if (boundType.intValue != (int)BoundTypes.WRIST) { offsetRotation.vector3Value = Vector3.zero; offsetPosition.vector3Value = Vector3.zero; } SceneView.RepaintAll(); offsets.DeleteArrayElementAtIndex(offsetIndex); break; } GUILayout.EndHorizontal(); //Check to see if the user has changed the value if ((int)previousBoundType != boundType.intValue) { //Check to see if any of the offsets are the same as this one if (myTarget.offsets.Any(x => (int)x == boundType.intValue)) { boundType.intValue = (int)previousBoundType; } else { offsetRotation.vector3Value = Vector3.zero; offsetPosition.vector3Value = Vector3.zero; offsetProperty = BoundTypeToOffsetProperty((BoundTypes)boundType.intValue); offsetRotation = offsetProperty.FindPropertyRelative("rotation"); offsetPosition = offsetProperty.FindPropertyRelative("position"); SceneView.RepaintAll(); } } EditorGUILayout.PropertyField(offsetPosition); EditorGUILayout.PropertyField(offsetRotation); GUILayout.EndVertical(); EditorGUILayout.Space(); GUILayout.Label(dividerLine); EditorGUILayout.Space(); } GUILayout.BeginHorizontal("Box"); GUILayout.Label("Add Finger Offset"); if (GUILayout.Button(EditorGUIUtility.IconContent("d_Toolbar Plus"))) { if (offsets.arraySize < 22) { offsets.InsertArrayElementAtIndex(offsets.arraySize); var offset = offsets.GetArrayElementAtIndex(offsets.arraySize - 1); var enumList = new List <int>(); for (int i = 0; i < 22; i++) { enumList.Add(i); } var result = enumList.Where(typeA => myTarget.offsets.All(typeB => (int)typeB != typeA)).FirstOrDefault(); offset.intValue = result; } } GUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.Label(dividerLine); EditorGUILayout.Space(); } }