Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Added transform extension to set all colliders active #244

Merged
merged 2 commits into from
Jul 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,20 @@ public static Transform FindCommonRoot(this Transform t1, Transform t2)

return null;
}

/// <summary>
/// Sets the collider and all child colliders active with the provided value.
/// </summary>
/// <param name="transform"></param>
/// <param name="isActive"></param>
public static void SetCollidersActive(this Transform transform, bool isActive)
{
var colliders = transform.GetComponentsInChildren<Collider>();

for (int i = 0; i < colliders.Length; i++)
{
colliders[i].enabled = isActive;
}
}
}
}