Table of Contents
Normalize a Value
normalizedValue = ( currentValue - min( currentValue )) / ( max( currentValue ) - min( currentValue ))
OS Independent Slash
Path.AltDirectorySeparatorChar
Extension Method for Class GameObject: Get Components in Children without its own component as List
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class GameObjectExtensions
{
public static List<T> GetComponentsInChildrenWithoutSelf<T>( this GameObject gameObj ) where T : Component
{
List<T> gComponentList = new List<T>( );
T[] components = gameObj.GetComponentsInChildren<T>( );
if ( components.Length > 0 )
{
foreach ( T component in components )
{
if ( gameObj.GetInstanceID( ) != component.gameObject.GetInstanceID( ) )
gComponentList.Add( component );
}
}
return gComponentList; //return as array: gComponentList.ToArray( );
}
}
Usage Example:
List<Collider> theColliders = gameObject.GetComponentsInChildrenWithoutSelf<Collider>( );
Debug.Log( theColliders.Count );