public GameObjectContainer(GameObject gameObject, SerializationMetadata metadata) { m_GameObject = gameObject; m_Components = new List <Component>(); #if UNITY_EDITOR if (PrefabUtility.IsPartOfPrefabInstance(gameObject)) { PrefabMetadataContainer = new PrefabMetadataContainer(gameObject, metadata); return; } #endif var prefabMetadata = gameObject.GetComponent <PrefabMetadata>(); if (prefabMetadata != null) { PrefabMetadataContainer = new PrefabMetadataContainer(prefabMetadata, metadata); return; } gameObject.GetComponents(k_TempComponents); foreach (var component in k_TempComponents) { //TODO: Insert null component for missing scripts if (component == null) { Debug.LogWarningFormat("Found missing script on {0} during serialization", gameObject.name); continue; } if (component.GetType() != typeof(PrefabMetadata) && (component.hideFlags & HideFlags.DontSave) != 0) { continue; } m_Components.Add(component); } m_Children = new List <GameObjectContainer>(); foreach (Transform child in gameObject.transform) { var childGameObject = child.gameObject; if ((childGameObject.hideFlags & HideFlags.DontSave) != 0) { continue; } m_Children.Add(new GameObjectContainer(childGameObject, metadata)); } }
internal void FinalizePrefab(PrefabMetadataContainer metadataContainer, SerializationMetadata metadata) { var removedComponents = metadataContainer.RemovedComponents; if (removedComponents != null) { HandleRemovedComponents(removedComponents); } if (Application.isPlaying) { m_GameObject.AddComponent <PrefabMetadata>().Setup(metadataContainer); } var overrides = metadataContainer.PropertyOverrides; if (overrides == null) { return; } metadata.EnqueuePostSerializationAction(() => { HandlePropertyOverrides(overrides, metadata); }); }