/// <summary> /// Moves a SwarmItem to the active or inactive transforms. /// This is mainly used a visual aid in the editor to see which items are active or inactive /// </summary> /// <param name="item">The SwarmItem to move</param> /// <param name="parentTransform">The parent transform to move to</param> private void SetItemParentTransform(SwarmItem item, Transform parentTransform) { if (item == null) { throw new Exception("item can't be null"); } if (parentTransform == null) { throw new Exception("parentTransform can't be null"); } // reparent this item's transform item.ThisTransform.parent = parentTransform; // reset the position, rotation, and scale to unit values item.ThisTransform.localPosition = Vector3.zero; item.ThisTransform.localRotation = Quaternion.identity; item.ThisTransform.localScale = Vector3.one; // if the position, rotation, or scale need to be changed after reparenting, do it in the // item's OnSetParentTransform method item.OnSetParentTransform(); }
/// <summary> /// Moves a SwarmItem to the active or inactive transforms. /// This is mainly used a visual aid in the editor to see which items are active or inactive /// </summary> /// <param name="item">The SwarmItem to move</param> /// <param name="parentTransform">The parent transform to move to</param> private void SetItemParentTransform(SwarmItem item, Transform parentTransform) { // reparent this item's transform item.ThisTransform.parent = parentTransform; // reset the position, rotation, and scale to unit values item.ThisTransform.localPosition = Vector3.zero; item.ThisTransform.localRotation = Quaternion.identity; item.ThisTransform.localScale = Vector3.one; // if the position, rotation, or scale need to be changed after reparenting, do it in the // item's OnSetParentTransform method item.OnSetParentTransform(); }