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); } System.Action <Transform, object> checkMethod; if (includeDefaultOverrides) { checkMethod = CheckForModifiedObjectsIncludingDefaultOverrides; } else { checkMethod = CheckForModifiedObjectsExcludingDefaultOverrides; } transformVisitor.VisitAll(prefabInstanceRoot.transform, checkMethod, modifiedObjects); return(modifiedObjects); }
public static List <AddedComponent> GetAddedComponents(GameObject 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.VisitAll(prefabInstanceRoot.transform, CheckForAddedComponents, addedComponents); return(addedComponents); }
public static List <RemovedComponent> GetRemovedComponents(GameObject 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) TransformVisitor transformVisitor = new TransformVisitor(); var removedComponents = new List <RemovedComponent>(); transformVisitor.VisitAll(prefabInstanceRoot.transform, CheckForRemovedComponents, removedComponents); return(removedComponents); }
public static List <AddedGameObject> GetAddedGameObjects(GameObject prefabInstance) { var prefabInstanceRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(prefabInstance); // From root instance traverse all children and detect any GameObjects that are not a prefab gameobject (these must be added) TransformVisitor transformVisitor = new TransformVisitor(); var addedGameObjects = new List <AddedGameObject>(); transformVisitor.VisitAll( prefabInstanceRoot.transform, CheckForAddedGameObject, new AddedGameObjectUserData() { addedGameObjects = addedGameObjects, contextGameObject = prefabInstanceRoot }); return(addedGameObjects); }
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>(); if (PrefabUtility.IsDisconnectedFromPrefabAsset(prefabInstance)) { return(removedComponents); } TransformVisitor transformVisitor = new TransformVisitor(); transformVisitor.VisitAll(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>(); if (PrefabUtility.IsDisconnectedFromPrefabAsset(prefabInstance)) { return(addedComponents); } transformVisitor.VisitAll(prefabInstanceRoot.transform, CheckForAddedComponents, addedComponents); return(addedComponents); }
static Scene LoadOrCreatePreviewScene(string environmentEditingScenePath) { Scene previewScene; if (!string.IsNullOrEmpty(environmentEditingScenePath)) { previewScene = EditorSceneManager.OpenPreviewScene(environmentEditingScenePath); var roots = previewScene.GetRootGameObjects(); var visitor = new TransformVisitor(); foreach (var root in roots) { visitor.VisitAll(root.transform, AppendEnvironmentName, null); } } else { previewScene = CreateDefaultPreviewScene(); } return(previewScene); }