void CalculatePrefabStatus() { m_PlayModeObjects = false; m_IsAsset = false; m_ImmutableSelf = false; m_ImmutableSourceAsset = false; m_IsDisconnected = false; m_IsMissing = false; m_IsPrefabInstanceAnyRoot = true; m_IsPrefabInstanceOutermostRoot = true; m_AllOfSamePrefabType = true; PrefabAssetType firstType = PrefabUtility.GetPrefabAssetType(targets[0]); PrefabInstanceStatus firstStatus = PrefabUtility.GetPrefabInstanceStatus(targets[0]); foreach (var o in targets) { var go = (GameObject)o; PrefabAssetType type = PrefabUtility.GetPrefabAssetType(go); PrefabInstanceStatus status = PrefabUtility.GetPrefabInstanceStatus(go); if (type != firstType || status != firstStatus) { m_AllOfSamePrefabType = false; } if (Application.IsPlaying(go)) { m_PlayModeObjects = true; } if (!PrefabUtility.IsAnyPrefabInstanceRoot(go)) { m_IsPrefabInstanceAnyRoot = false; // Conservative is false if any is false } if (!m_IsPrefabInstanceAnyRoot || !PrefabUtility.IsOutermostPrefabInstanceRoot(go)) { m_IsPrefabInstanceOutermostRoot = false; // Conservative is false if any is false } if (PrefabUtility.IsPartOfPrefabAsset(go)) { m_IsAsset = true; // Conservative is true if any is true } if (m_IsAsset && PrefabUtility.IsPartOfImmutablePrefab(go)) { m_ImmutableSelf = true; // Conservative is true if any is true } GameObject originalSourceOrVariant = PrefabUtility.GetOriginalSourceOrVariantRoot(go); if (originalSourceOrVariant != null && PrefabUtility.IsPartOfImmutablePrefab(originalSourceOrVariant)) { m_ImmutableSourceAsset = true; // Conservative is true if any is true } if (PrefabUtility.IsDisconnectedFromPrefabAsset(go)) { m_IsDisconnected = true; } if (PrefabUtility.IsPrefabAssetMissing(go)) { m_IsMissing = true; } } }
private void HandlePrefabInstanceOverrideStatus(GameObjectTreeViewItem goItem, Rect rect, bool selected, bool focused) { GameObject go = goItem.objectPPTR as GameObject; if (!go) { return; } if (PrefabUtility.IsOutermostPrefabInstanceRoot(go) && PrefabUtility.HasPrefabInstanceNonDefaultOverridesOrUnusedOverrides_CachedForUI(go)) { Rect overridesMarkerRect = new Rect(rect.x + SceneVisibilityHierarchyGUI.utilityBarWidth, rect.y + 1, 2, rect.height - 2); Color clr = (selected && focused) ? EditorGUI.k_OverrideMarginColorSelected : EditorGUI.k_OverrideMarginColor; EditorGUI.DrawRect(overridesMarkerRect, clr); } }
void CalculatePrefabStatus() { m_IsPrefabInstanceAnyRoot = false; m_IsAsset = false; m_AllOfSamePrefabType = true; PrefabAssetType firstType = PrefabUtility.GetPrefabAssetType(targets[0]); PrefabInstanceStatus firstStatus = PrefabUtility.GetPrefabInstanceStatus(targets[0]); foreach (GameObject go in targets) { PrefabAssetType type = PrefabUtility.GetPrefabAssetType(go); PrefabInstanceStatus status = PrefabUtility.GetPrefabInstanceStatus(go); if (type != firstType || status != firstStatus) { m_AllOfSamePrefabType = false; } if (PrefabUtility.IsAnyPrefabInstanceRoot(go)) { m_IsPrefabInstanceAnyRoot = true; } if (m_IsPrefabInstanceAnyRoot) { m_IsPrefabInstanceOutermostRoot = PrefabUtility.IsOutermostPrefabInstanceRoot(go); } if (PrefabUtility.IsPartOfPrefabAsset(go)) { m_IsAsset = true; } if (m_IsAsset && PrefabUtility.IsPartOfImmutablePrefab(go)) { m_ImmutableSelf = true; } GameObject originalSourceOrVariant = PrefabUtility.GetOriginalSourceOrVariantRoot(go); if (originalSourceOrVariant != null && PrefabUtility.IsPartOfImmutablePrefab(originalSourceOrVariant)) { m_ImmutableSourceAsset = true; } } }
static GameObject[] GetOutermostPrefabInstancesFromSelection() { var gos = new List <GameObject>(); var gameObjects = Selection.gameObjects; for (int i = 0; i < gameObjects.Length; i++) { var go = gameObjects[i]; if (go != null && PrefabUtility.IsPartOfNonAssetPrefabInstance(go) && PrefabUtility.IsOutermostPrefabInstanceRoot(go)) { gos.Add(go); } } return(gos.ToArray()); }