/* * Build the runtime representations of the ragdoll bones * * Adds the ragdoll components (Rigidbodies, joints, colliders...) if they werent * pre built in the editor. * * then the variables, (like joint limits and rigidbody masses), * are adjusted via the ragdoll profile */ void Awake() { if (!initializedValues) { initializedValues = true; Animator myAnimator = GetComponent <Animator>(); //if there werent any errros if (RagdollBuilder.BuildRagdollElements(myAnimator, out allElements, out boneElements)) { RagdollBuilder.BuildBones(myAnimator, ragdollProfile, !preBuilt, boneElements, out initialHeadOffsetFromChest); //set the bones to the ragdoll layer //SetLayer(LayerMask.NameToLayer("Ragdoll")); //get all renderers allRenderers = GetComponentsInChildren <Renderer>(); InitializeRagdollBoneComponents(); } //display errors else { CheckForErroredRagdoll("Awake"); } } }
void DrawBuildOptions() { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); SerializedProperty preBuiltProp = serializedObject.FindProperty("preBuilt"); bool isBuilt = preBuiltProp.boolValue; if (isBuilt) { if (GUILayout.Button(isBuilt ? "Clear Ragdoll" : "Pre Build Ragdoll")) { RagdollBuilder.EraseRagdoll(ragdoll.GetComponent <Animator>()); preBuiltProp.boolValue = !isBuilt; } } else { GUI.enabled = ragdoll.ragdollProfile != null; if (GUILayout.Button(isBuilt ? "Clear Ragdoll" : "Pre Build Ragdoll")) { System.Collections.Generic.Dictionary <HumanBodyBones, RagdollTransform> bones; RagdollBuilder.BuildRagdollElements(ragdoll.GetComponent <Animator>(), out _, out bones); RagdollBuilder.BuildBones(ragdoll.GetComponent <Animator>(), ragdoll.ragdollProfile, true, bones, out _); preBuiltProp.boolValue = !isBuilt; } GUI.enabled = true; } if (isBuilt) { GUI.enabled = ragdoll.ragdollProfile != null; // if (ragdoll.ragdollProfile) { if (GUILayout.Button("Update Ragdoll To Profile")) { System.Collections.Generic.Dictionary <HumanBodyBones, RagdollTransform> bones; RagdollBuilder.BuildRagdollElements(ragdoll.GetComponent <Animator>(), out _, out bones); RagdollBuilder.BuildBones(ragdoll.GetComponent <Animator>(), ragdoll.ragdollProfile, false, bones, out _); } GUI.enabled = true; // } } EditorGUILayout.EndHorizontal(); }