static public void CollectDependanciesRecursive(UnityEngine.Object obj, ref Dictionary <int, Object> dependencies)
{
if (!dependencies.ContainsKey(obj.GetHashCode()))
{
dependencies.Add(obj.GetHashCode(), obj);
SerializedObject objSO = new SerializedObject(obj);
SerializedProperty property = objSO.GetIterator();
do
{
if ((property.propertyType == SerializedPropertyType.ObjectReference) &&
(property.objectReferenceValue != null)
) //Don't go back up the hierarchy in transforms
{
CollectDependanciesRecursive(property.objectReferenceValue, ref dependencies);
if (obj.GetType() == typeof(Material))
{
var i = 0;
i++;
}
}
} while (property.Next(true));
}
}