Пример #1
0
        /// <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
                }
            }
        }