Example #1
0
        public override IEnumerable <PPtr <Object> > FetchDependencies(DependencyContext context)
        {
            PrefabInstanceLayout layout = context.Layout.PrefabInstance;

            if (layout.IsModificationFormat)
            {
                foreach (PPtr <Object> asset in FetchDependenciesObject(context))
                {
                    yield return(asset);
                }

                if (layout.HasRootGameObject)
                {
                    yield return(context.FetchDependency(RootGameObject, layout.RootGameObjectName));
                }
                foreach (PPtr <Object> asset in context.FetchDependencies(Modification, layout.ModificationName))
                {
                    yield return(asset);
                }
                yield return(context.FetchDependency(SourcePrefab, layout.SourcePrefabName));
            }
            else
            {
                foreach (PPtr <Object> asset in context.FetchDependencies(Objects, layout.ObjectsName))
                {
                    yield return(asset);
                }
                yield return(context.FetchDependency(Father, layout.FatherName));

                foreach (PPtr <Object> asset in base.FetchDependencies(context))
                {
                    yield return(asset);
                }
            }
        }
Example #2
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            PrefabInstanceLayout layout = container.ExportLayout.PrefabInstance;

            if (layout.IsModificationFormat)
            {
                YAMLMappingNode node = ExportYAMLRootObject(container);
                node.AddSerializedVersion(layout.Version);
                if (layout.HasRootGameObject && layout.IsRootGameObjectFirst)
                {
                    node.Add(layout.RootGameObjectName, RootGameObject.ExportYAML(container));
                }

                node.Add(layout.ModificationName, Modification.ExportYAML(container));
                node.Add(layout.SourcePrefabInvariantName, SourcePrefab.ExportYAML(container));
                if (!layout.IsRootGameObjectFirst)
                {
                    node.Add(layout.RootGameObjectName, RootGameObject.ExportYAML(container));
                }
                if (layout.HasIsPrefabAssetInvariant)
                {
                    node.Add(layout.IsPrefabAssetInvariantName, IsPrefabAsset);
                }
                if (layout.HasIsExploded)
                {
                    node.Add(layout.IsExplodedName, IsExploded);
                }
                return(node);
            }
            else
            {
                YAMLMappingNode node = new YAMLMappingNode();
                node.Add(layout.LastMergeIdentifierName, LastMergeIdentifier.ExportYAML(container));
                if (layout.HasLastTemplateIdentifier)
                {
                    node.Add(layout.LastTemplateIdentifierName, LastTemplateIdentifier.ExportYAML(container));
                }
                node.Add(layout.ObjectsName, Objects.ExportYAML(container));
                node.Add(layout.FatherName, Father.ExportYAML(container));
                node.Add(layout.IsDataTemplateName, IsDataTemplate);

                YAMLMappingNode baseNode = base.ExportYAMLRoot(container);
                node.Append(baseNode);
                return(node);
            }
        }
Example #3
0
        public override void Write(AssetWriter writer)
        {
            PrefabInstanceLayout layout = writer.Layout.PrefabInstance;

            if (layout.IsModificationFormat)
            {
                WriteObject(writer);

                if (layout.HasRootGameObject && layout.IsRootGameObjectFirst)
                {
                    RootGameObject.Write(writer);
                }

                Modification.Write(writer);
                SourcePrefab.Write(writer);
                if (!layout.IsRootGameObjectFirst)
                {
                    RootGameObject.Write(writer);
                }
                if (layout.HasIsPrefabAsset)
                {
                    writer.Write(IsPrefabAsset);
                }
                if (layout.HasIsExploded)
                {
                    writer.Write(IsExploded);
                }
                writer.AlignStream();
            }
            else
            {
                LastMergeIdentifier.Write(writer);
                if (layout.HasLastTemplateIdentifier)
                {
                    LastTemplateIdentifier.Write(writer);
                }
                Objects.Write(writer);
                Father.Write(writer);
                writer.Write(IsDataTemplate);
                writer.AlignStream();

                base.Write(writer);
            }
        }
Example #4
0
        public override void Read(AssetReader reader)
        {
            PrefabInstanceLayout layout = reader.Layout.PrefabInstance;

            if (layout.IsModificationFormat)
            {
                ReadObject(reader);

                if (layout.HasRootGameObject && layout.IsRootGameObjectFirst)
                {
                    RootGameObject.Read(reader);
                }

                Modification.Read(reader);
                SourcePrefab.Read(reader);
                if (!layout.IsRootGameObjectFirst)
                {
                    RootGameObject.Read(reader);
                }
                if (layout.HasIsPrefabAsset)
                {
                    IsPrefabAsset = reader.ReadBoolean();
                }
                if (layout.HasIsExploded)
                {
                    IsExploded = reader.ReadBoolean();
                }
                reader.AlignStream();
            }
            else
            {
                LastMergeIdentifier.Read(reader);
                if (layout.HasLastTemplateIdentifier)
                {
                    LastTemplateIdentifier.Read(reader);
                }
                Objects        = reader.ReadAssetArray <PPtr <EditorExtension> >();
                Father         = reader.ReadAsset <PPtr <PrefabInstance> >();
                IsDataTemplate = reader.ReadBoolean();
                reader.AlignStream();

                base.Read(reader);
            }
        }