示例#1
0
        public GameObject(AssetLayout layout) :
            base(layout)
        {
            GameObjectLayout classLayout = layout.GameObject;

            if (classLayout.IsComponentTuple)
            {
                ComponentTuple = Array.Empty <Tuple <ClassIDType, PPtr <Component> > >();
            }
            else
            {
                Component = Array.Empty <ComponentPair>();
            }
            Name      = string.Empty;
            TagString = TagManager.UntaggedTag;
            IsActive  = true;
        }
示例#2
0
        public static GameObject Convert(IExportContainer container, GameObject origin)
        {
            GameObjectLayout layout   = container.Layout.GameObject;
            GameObjectLayout exlayout = container.ExportLayout.GameObject;
            GameObject       instance = new GameObject(container.ExportLayout);

            EditorExtensionConverter.Convert(container, origin, instance);
            instance.AssetInfo = origin.AssetInfo;
            if (exlayout.IsComponentTuple)
            {
                instance.ComponentTuple = origin.ComponentTuple.ToArray();
            }
            else
            {
                instance.Component = GetComponent(container, origin);
            }
            instance.IsActive = GetIsActive(container, origin);
            instance.Layer    = origin.Layer;
            instance.Name     = origin.Name;
            if (exlayout.HasTag)
            {
                instance.Tag = GetTag(container, origin);
            }
            if (exlayout.HasTagString)
            {
                instance.TagString = GetTagString(container, origin);
            }
#if UNIVERSAL
            if (layout.HasIcon)
            {
                instance.Icon = origin.Icon;
            }
            if (layout.HasNavMeshLayer)
            {
                instance.NavMeshLayer      = origin.NavMeshLayer;
                instance.StaticEditorFlags = origin.StaticEditorFlags;
            }
            else if (exlayout.HasIsStatic && layout.HasIsStatic)
            {
                instance.IsStatic = origin.IsStatic;
            }
#endif
            return(instance);
        }
示例#3
0
        public override IEnumerable <PPtr <Object> > FetchDependencies(DependencyContext context)
        {
            foreach (PPtr <Object> asset in base.FetchDependencies(context))
            {
                yield return(asset);
            }

            GameObjectLayout layout = context.Layout.GameObject;

            if (layout.IsComponentTuple)
            {
                foreach (PPtr <Object> asset in context.FetchDependencies(ComponentTuple.Select(t => t.Item2), layout.ComponentName))
                {
                    yield return(asset);
                }
            }
            else
            {
                foreach (PPtr <Object> asset in context.FetchDependencies(Component, layout.ComponentName))
                {
                    yield return(asset);
                }
            }
        }
示例#4
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode  node   = base.ExportYAMLRoot(container);
            GameObjectLayout layout = container.ExportLayout.GameObject;

            node.AddSerializedVersion(layout.Version);
            if (layout.IsComponentTuple)
            {
                node.Add(layout.ComponentName, ComponentTuple.ExportYAML(container, (t) => (int)t));
            }
            else
            {
                node.Add(layout.ComponentName, Component.ExportYAML(container));
            }

            if (layout.IsActiveFirst)
            {
                node.Add(layout.IsActiveName, IsActive);
            }

            node.Add(layout.LayerName, Layer);
            if (layout.IsNameFirst)
            {
                node.Add(layout.NameName, Name);
            }
            if (layout.HasTag)
            {
                node.Add(layout.TagName, Tag);
            }
            else
            {
                node.Add(layout.TagStringName, TagString);
            }

            if (layout.HasIcon && layout.IsIconFirst)
            {
                node.Add(layout.IconName, Icon.ExportYAML(container));
            }
            if (layout.HasNavMeshLayer)
            {
                node.Add(layout.NavMeshLayerName, NavMeshLayer);
                node.Add(layout.StaticEditorFlagsName, StaticEditorFlags);
            }
            if (!layout.IsNameFirst)
            {
                node.Add(layout.NameName, Name);
            }
            if (!layout.IsActiveFirst)
            {
                node.Add(layout.IsActiveName, IsActive);
            }
            if (layout.HasIsStatic)
            {
                node.Add(layout.IsStaticName, IsStatic);
            }
            if (layout.HasIcon && !layout.IsIconFirst)
            {
                node.Add(layout.IconName, Icon.ExportYAML(container));
            }
            return(node);
        }
示例#5
0
        public override void Write(AssetWriter writer)
        {
            base.Write(writer);

            GameObjectLayout layout = writer.Layout.GameObject;

            if (layout.IsComponentTuple)
            {
                ComponentTuple.Write(writer, (t) => (int)t);
            }
            else
            {
                Component.Write(writer);
            }

            if (layout.IsActiveFirst)
            {
                writer.Write(IsActive);
            }
            writer.Write(Layer);
            if (layout.IsNameFirst)
            {
                writer.Write(Name);
            }

            if (layout.HasTag)
            {
                writer.Write(Tag);
            }
#if UNIVERSAL
            else
            {
                writer.Write(TagString);
            }
            if (layout.HasIcon && layout.IsIconFirst)
            {
                Icon.Write(writer);
            }
            if (layout.HasNavMeshLayer)
            {
                writer.Write(NavMeshLayer);
                writer.Write(StaticEditorFlags);
            }
#endif
            if (!layout.IsNameFirst)
            {
                writer.Write(Name);
            }
            if (!layout.IsActiveFirst)
            {
                writer.Write(IsActive);
            }


#if UNIVERSAL
            if (layout.HasIsStatic)
            {
                writer.Write(IsStatic);
            }
            if (layout.HasIcon && !layout.IsIconFirst)
            {
                Icon.Write(writer);
            }
#endif
        }
示例#6
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            GameObjectLayout layout = reader.Layout.GameObject;

            if (layout.IsComponentTuple)
            {
                ComponentTuple = reader.ReadTupleEnum32TArray <ClassIDType, PPtr <Component> >((t) => (ClassIDType)t);
            }
            else
            {
                Component = reader.ReadAssetArray <ComponentPair>();
            }

            if (layout.IsActiveFirst)
            {
                IsActive = reader.ReadBoolean();
            }
            Layer = reader.ReadUInt32();
            if (layout.IsNameFirst)
            {
                Name = reader.ReadString();
            }

            if (layout.HasTag)
            {
                Tag = reader.ReadUInt16();
            }
#if UNIVERSAL
            else
            {
                TagString = reader.ReadString();
            }
            if (layout.HasIcon && layout.IsIconFirst)
            {
                Icon.Read(reader);
            }
            if (layout.HasNavMeshLayer)
            {
                NavMeshLayer      = reader.ReadUInt32();
                StaticEditorFlags = reader.ReadUInt32();
            }
#endif
            if (!layout.IsNameFirst)
            {
                Name = reader.ReadString();
            }
            if (!layout.IsActiveFirst)
            {
                IsActive = reader.ReadBoolean();
            }


#if UNIVERSAL
            if (layout.HasIsStatic)
            {
                IsStatic = reader.ReadBoolean();
            }
            if (layout.HasIcon && !layout.IsIconFirst)
            {
                Icon.Read(reader);
            }
#endif
        }