/// <summary> /// </summary> void SaveInitialPoses() { var ignored_layer = LayerMask.NameToLayer("IgnoredByNeodroid"); if (this._track_only_children) { this._tracked_game_objects = NeodroidUtilities.RecursiveChildGameObjectsExceptLayer(this.transform, ignored_layer); } else { this._tracked_game_objects = NeodroidUtilities.FindAllGameObjectsExceptLayer(ignored_layer); } var length = this._tracked_game_objects.Length; this._reset_positions = new Vector3[length]; this._reset_rotations = new Quaternion[length]; this._poses = new Transform[length]; for (var i = 0; i < length; i++) { var go = this._tracked_game_objects[i]; var trans = go.transform; this._reset_positions[i] = trans.position; this._reset_rotations[i] = trans.rotation; this._poses[i] = trans; var maybe_joint = go.GetComponent <Joint>(); if (maybe_joint != null) { var maybe_joint_fix = maybe_joint.GetComponent <JointFix>(); if (maybe_joint_fix == null) { // ReSharper disable once RedundantAssignment maybe_joint_fix = maybe_joint.gameObject.AddComponent <JointFix>(); } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Added a JointFix component to {maybe_joint_fix.name}"); } #endif } } }
void SaveInitialPoses() { var ignored_layer = LayerMask.NameToLayer("IgnoredByNeodroid"); this._child_game_objects = NeodroidUtilities.RecursiveChildGameObjectsExceptLayer(this.transform, ignored_layer); this._reset_positions = new Vector3[this._child_game_objects.Length]; this._reset_rotations = new Quaternion[this._child_game_objects.Length]; this._poses = new Transform[this._child_game_objects.Length]; for (var i = 0; i < this._child_game_objects.Length; i++) { this._reset_positions[i] = this._child_game_objects[i].transform.position; this._reset_rotations[i] = this._child_game_objects[i].transform.rotation; this._poses[i] = this._child_game_objects[i].transform; var maybe_joint = this._child_game_objects[i].GetComponent <Joint>(); if (maybe_joint != null) { maybe_joint.gameObject.AddComponent <JointFix>(); } } }