public static List <ObjectOverride> GetObjectOverrides(GameObject prefabInstance, bool includeDefaultOverrides = false) { ThrowExceptionIfNullOrNotPartOfPrefabInstance(prefabInstance); var prefabInstanceRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(prefabInstance); // From root of instance traverse all child go and detect any GameObjects or components // that are not part of that source prefab objects component list (these must be added) TransformVisitor transformVisitor = new TransformVisitor(); var modifiedObjects = new List <ObjectOverride>(); if (PrefabUtility.IsDisconnectedFromPrefabAsset(prefabInstance)) { return(modifiedObjects); } Func <Transform, object, bool> checkMethod; if (includeDefaultOverrides) { checkMethod = CheckForModifiedObjectsIncludingDefaultOverrides; } else { checkMethod = CheckForModifiedObjectsExcludingDefaultOverrides; } transformVisitor.VisitPrefabInstanceTransforms(prefabInstanceRoot.transform, checkMethod, modifiedObjects); return(modifiedObjects); }
public static List <RemovedComponent> GetRemovedComponents(GameObject prefabInstance) { ThrowExceptionIfNullOrNotPartOfPrefabInstance(prefabInstance); var prefabInstanceRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(prefabInstance); // From root of asset traverse all children and detect any Components that are not present on the instance object (these must be deleted) var removedComponents = new List <RemovedComponent>(); TransformVisitor transformVisitor = new TransformVisitor(); transformVisitor.VisitPrefabInstanceTransforms(prefabInstanceRoot.transform, CheckForRemovedComponents, removedComponents); return(removedComponents); }
public static List <AddedComponent> GetAddedComponents(GameObject prefabInstance) { ThrowExceptionIfNullOrNotPartOfPrefabInstance(prefabInstance); var prefabInstanceRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(prefabInstance); // From root of instance traverse all child go and detect any components that are not part of that source prefab objects component list (these must be added) TransformVisitor transformVisitor = new TransformVisitor(); var addedComponents = new List <AddedComponent>(); transformVisitor.VisitPrefabInstanceTransforms(prefabInstanceRoot.transform, CheckForAddedComponents, addedComponents); return(addedComponents); }