private IEnumerable <DependencyViewerOperation> FindReferencesOnUnityObject( DependencyViewerNode node, UnityEngine.Object obj, AssetDependencyResolverOperation op, GameObject prefabRoot = null) { SerializedObject objSO = new SerializedObject(obj); SerializedProperty sp = objSO.GetIterator(); while (sp.NextVisible(true)) { if (IsPropertyADependency(sp, node)) { // Reference found! DependencyViewerNode reference = new DependencyViewerNode(obj); DependencyViewerGraph.CreateNodeLink(reference, node); if (prefabRoot != null) { reference.SetAsPrefabContainerInfo(prefabRoot, (obj as Component).gameObject.name); } } ++op.numProcessedProperties; if (op.numProcessedProperties > NumAssetPropertiesReferencesResolvedPerFrame) { op.AssetBeingProcessed = obj; op.numProcessedProperties = 0; yield return(op); } } }
private void FindDependencies(DependencyViewerNode node, UnityEngine.Object obj, int depth = 1, GameObject prefabRoot = null) { SerializedObject targetObjectSO = new SerializedObject(obj); SerializedProperty sp = targetObjectSO.GetIterator(); while (sp.NextVisible(true)) { if (sp.propertyType == SerializedPropertyType.ObjectReference && sp.objectReferenceValue != null && IsObjectAllowedBySettings(sp.objectReferenceValue)) { // Dependency found! DependencyViewerNode dependencyNode = new DependencyViewerNode(sp.objectReferenceValue); DependencyViewerGraph.CreateNodeLink(node, dependencyNode); if (prefabRoot != null) { Component comp = obj as Component; dependencyNode.SetAsPrefabContainerInfo(prefabRoot, comp.gameObject.name); } if (depth > 1) { FindDependencies(dependencyNode, sp.objectReferenceValue, depth - 1); } } } }