Пример #1
0
        /// <summary>
        /// Changes the rigidbody parent of the collider. Meant to be called from the Rigidbody itself.
        /// </summary>
        /// <param name="rigidbody">New rigidbody to assign as the parent to the collider.</param>
        /// <param name="isInternal">If true the rigidbody will just be changed internally, but parent rigidbody will not be
        ///                          notified.</param>
        internal void SetRigidbody(Rigidbody rigidbody, bool isInternal = false)
        {
            if (rigidbody == parent)
            {
                return;
            }

            if (native != null && !isInternal)
            {
                if (parent != null)
                {
                    parent.RemoveCollider(this);
                }

                NativeRigidbody nativeRigidbody = null;

                if (rigidbody != null)
                {
                    nativeRigidbody = rigidbody.native;
                }

                native.Rigidbody = nativeRigidbody;

                if (rigidbody != null)
                {
                    rigidbody.AddCollider(this);
                }
            }

            parent = rigidbody;
            UpdateCollisionReportMode();
        }
Пример #2
0
        /// <summary>
        /// Changes the rigidbody parent of the collider. Meant to be called from the Rigidbody itself. 
        /// </summary>
        /// <param name="rigidbody">New rigidbody to assign as the parent to the collider.</param>
        /// <param name="isInternal">If true the rigidbody will just be changed internally, but parent rigidbody will not be
        ///                          notified.</param>
        internal void SetRigidbody(Rigidbody rigidbody, bool isInternal = false)
        {
            if (rigidbody == parent)
                return;

            if (native != null && !isInternal)
            {
                if (parent != null)
                    parent.RemoveCollider(this);

                NativeRigidbody nativeRigidbody = null;

                if (rigidbody != null)
                    nativeRigidbody = rigidbody.native;

                native.Rigidbody = nativeRigidbody;

                if (rigidbody != null)
                    rigidbody.AddCollider(this);
            }

            parent = rigidbody;
            UpdateCollisionReportMode();
        }