Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using System.Collections.Generic;
public static class GameObjectExtensions {
public static T[] GetComponentsInChildrenOfAsset<T>( this GameObject go ) where T : Component {
List<Transform> tfs = new List<Transform>();
CollectChildren( tfs, go.transform );
List<T> all = new List<T>();
for (int i = 0; i < tfs.Count; i++)
@FreyaHolmer
FreyaHolmer / TransformExtensions.cs
Created August 8, 2015 07:17
Adds WorldToLocal and LocalToWorld to transform components in Unity
using UnityEngine;
public enum TransformType { Point, Direction, Vector };
public static class TransformExtensions {
public static Vector3 WorldToLocal( this Transform tf, Vector3 v3, TransformType type = TransformType.Point ) {
if( type == TransformType.Point )
return tf.InverseTransformPoint( v3 );
else if( type == TransformType.Direction )
@FreyaHolmer
FreyaHolmer / ScriptableObjectSpawner.cs
Last active January 8, 2020 06:51
ScriptableObject asset spawner for Unity
// Adds a menu item for easy creation of your ScriptableObject types
// Usage: Right click in project view -> Create -> ScriptableObject... -> Select your type
// It will land in the root of your assets folder with the same name as your class
// Freya Holmér - webmaster@acegikmo.com
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System.Linq;
using System.IO;