Unity Code Extensions

Unity already provides a bunch of methods to perform the most tasks a lot faster. However, still there is a gap for some useful extensions. The extensions I came up with are listed below. In addition, you can find the .cs file as an attachment.

Some of the extensions are related to the game I am currently building. Thus, do not expect every extension to be a useful one.


  • GetFullPath
  • SetLayerRecursively
  • ApplyLayerCacheRecursively
  • GetParentRoot
  • GetComponentsExecpt
  • RemoveComponentsExecpt
  • FindSameHierarchicalGameObjectWithName
  • GetComponentsInAllChildren
  • ClearTransform
  • AddComponentIfNotExistent
  • RemoveComponentIfExistent
  • CalculateLocalBounds


  • GetFullPath
  • EnumerateHierarchy
  • EnumerateHierarchyCore
  • GetColliderBounds
  • IsParentOrChildOf
  • RotateYToPoint
  • FindRecursively
  • FindRecursivelyByTag
  • FindSeveralRecursivelyByTag
  • GetComponentWithAttribute


  • SetXAxisToZero
  • SetYAxisToZero
  • SetZAxisToZero
  • WorldToCanvas
  • CalculateVelocity
  • Mult


  • WorldToCanvasPosition
  • ScreenToCanvasPosition
  • ViewportToCanvasPosition


  • PositionOfMouseOnCollider
  • PositionOfMouseOnColliderOnly


  • GetAttribute


  • RayCastHit
  • RayCastHits
  • FindFirstParentWithComponent

For a faster access through the whole source-code, the “QuickAccess.cs” provides some common functionality. It won’t compile, since it contains enums which aren’t attached to this thread.

Source-Code is available via download (.zip)

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.