Пример #1
0
        private static IHierarchyElement ReadHieraerchyElement(UnsafeReader reader)
        {
            switch (reader.ReadInt32())
            {
            case 0:
                return(GameObjectHierarchy.Read(reader));

            case 1:
                return(ComponentHierarchy.Read(reader));

            case 2:
                return(PrefabInstanceHierarchy.Read(reader));

            case 3:
                return(ScriptComponentHierarchy.Read(reader));

            case 4:
                return(StrippedHierarchyElement.Read(reader));

            case 5:
                return(TransformHierarchy.Read(reader));

            default:
                throw new InvalidOperationException("Unknown type");
            }
        }
Пример #2
0
        private static object Read(UnsafeReader reader)
        {
            var otherCount       = reader.ReadInt32();
            var gameObjectsCount = reader.ReadInt32();
            var transformCount   = reader.ReadInt32();
            var scriptCount      = reader.ReadInt32();
            var componentsCount  = reader.ReadInt32();


            var result = new AssetDocumentHierarchyElement(otherCount, gameObjectsCount, transformCount, scriptCount, componentsCount);

            for (int i = 0; i < otherCount; i++)
            {
                var hierarchyElement = ReadHieraerchyElement(reader);
                result.myOtherBoxedElements.Add(hierarchyElement);
            }

            for (int i = 0; i < gameObjectsCount; i++)
            {
                result.myGameObjectHierarchies.Add(GameObjectHierarchy.Read(reader));
            }

            for (int i = 0; i < transformCount; i++)
            {
                result.myTransformElements.Add(TransformHierarchy.Read(reader));
            }

            for (int i = 0; i < scriptCount; i++)
            {
                result.myScriptComponentElements.Add(ScriptComponentHierarchy.Read(reader));
            }

            for (int i = 0; i < componentsCount; i++)
            {
                result.myComponentElements.Add(ComponentHierarchy.Read(reader));
            }

            return(result);
        }