예제 #1
0
        public string Write(WriteParameters parameters)
        {
            HtmlWriteParameters p = parameters as HtmlWriteParameters;
            var boards            = p.Boards;

            if (boards.Count == 0)
            {
                return(null);
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("var sites = [");
            foreach (var b in boards)
            {
                Color c = p.ColorsProvider.GetBoardColor(b);
                sb.Append("[");
                sb.Append(b.Location.ToString()).Append(",");
                sb.Append("'<div style=\"text-align:center\">").Append($"<br><img src=\"{b.Photo.ToString()}\" width=\"384\" height=\"288\"><br>").Append("</div>'").Append(",");
                sb.Append($"\"Rgb({c.R},{c.G},{c.B})\"").AppendLine("],");
            }
            sb.AppendLine("];");
            string   markers = sb.ToString();
            Location center  = GetMapCenter(boards.Select(a => a.Location));
            string   mapsize = $"<div id = \"map_canvas\" style = \"width: {p.MapSize.Width}px; height: {p.MapSize.Height-10}px;\"></div>";

            string html = Properties.Resources.SimpleHtmlPage;

            html = html.Replace("point_apikey_to_insert", p.ApiKey);
            html = html.Replace("point_boards_to_insert", markers);
            html = html.Replace("point_mapcenter_to_insert", center.ToString());
            html = html.Replace("point_mapsize_to_insert", mapsize);

            return(html);
        }
        public static bool BuildAssetBundle(string manifestPath, GUID assetGuid, string cacheFilePath, BuildTarget target, HashSet <Entities.Hash128> dependencies, HashSet <System.Type> types, long fileIdent)
        {
            using (new BuildInterfacesWrapper())
            {
                Directory.CreateDirectory(k_TempBuildPath);

                // Used for naming
                var fixedGUID = assetGuid;
                if (fileIdent != -1)
                {
                    GUIDHelper.PackBuiltinExtraWithFileIdent(ref fixedGUID, fileIdent);
                }

                string assetGUIDString = fixedGUID.ToString();

                // Deterministic ID Generator
                var generator = new Unity5PackedIdentifiers();

                // Target platform settings & script information
                var settings = new BuildSettings
                {
                    buildFlags = ContentBuildFlags.None,
                    target     = target,
                    group      = BuildPipeline.GetBuildTargetGroup(target),
                    typeDB     = null
                };

                if (assetGuid == GUIDHelper.UnityBuiltinResources)
                {
                    FilterBuiltinResourcesObjectManifest(manifestPath);
                }

                if (assetGuid == GUIDHelper.UnityBuiltinExtraResources)
                {
                    FilterBuiltinExtraResourcesObjectManifest(manifestPath);
                }

                // Collect all the objects we need for this asset & bundle (returned array order is deterministic)
                var manifestObjects = ContentBuildInterface.GetPlayerObjectIdentifiersInSerializedFile(manifestPath, settings.target);

                // Collect all the objects we need to reference for this asset (returned array order is deterministic)
                var manifestDependencies = ContentBuildInterface.GetPlayerDependenciesForObjects(manifestObjects, settings.target, settings.typeDB);

                // Scene / Project lighting information
                var globalUsage = ContentBuildInterface.GetGlobalUsageFromGraphicsSettings();
                globalUsage = ForceKeepInstancingVariants(globalUsage);

                // Inter-asset feature usage (shader features, used mesh channels)
                var usageSet = new BuildUsageTagSet();
                ContentBuildInterface.CalculateBuildUsageTags(manifestDependencies, manifestDependencies, globalUsage, usageSet); // TODO: Cache & Append to the assets that are influenced by this usageTagSet, ideally it would be a nice api to extract just the data for a given asset or object from the result

                // Bundle all the needed write parameters
                var writeParams = new WriteParameters
                {
                    // Target platform settings & script information
                    settings = settings,

                    // Scene / Project lighting information
                    globalUsage = globalUsage,

                    // Inter-asset feature usage (shader features, used mesh channels)
                    usageSet = usageSet,

                    // Serialized File Layout
                    writeCommand = new WriteCommand
                    {
                        fileName         = generator.GenerateInternalFileName(assetGUIDString),
                        internalName     = generator.GenerateAssetBundleInternalFileName(fixedGUID),
                        serializeObjects = new List <SerializationInfo>() // Populated Below
                    },

                    // External object references
                    referenceMap = new BuildReferenceMap(), // Populated Below

                    // Asset Bundle object layout
                    bundleInfo = new AssetBundleInfo
                    {
                        bundleName = assetGUIDString,
                        // What is loadable from this bundle
                        bundleAssets = new List <AssetLoadInfo>
                        {
                            // The manifest object and it's dependencies
                            new AssetLoadInfo
                            {
                                address           = assetGUIDString,
                                asset             = assetGuid,                // TODO: Remove this as it is unused in C++
                                includedObjects   = manifestObjects.ToList(), // TODO: In our effort to modernize the public API design we over complicated it trying to take List or return ReadOnlyLists. Should have just stuck with Arrays[] in all places
                                referencedObjects = manifestDependencies.ToList()
                            }
                        }
                    }
                };

                // The requirement is that a single asset bundle only contains the ObjectManifest and the objects that are directly part of the asset, objects for external assets will be in their own bundles. IE: 1 asset per bundle layout
                // So this means we need to take manifestObjects & manifestDependencies and filter storing them into writeCommand.serializeObjects and/or referenceMap based on if they are this asset or other assets

                // For the Manifest Objects, we only have the ScriptableObject `AssetObjectManifest` which is not referenced outside of this bundle.
                // This creates a deterministic ID for it, regardless of the path of the manifest file
                var linearGenerator = new LinearPackedIdentifiers(2);
                foreach (var obj in manifestObjects)
                {
                    var index = linearGenerator.SerializationIndexFromObjectIdentifier(obj);
                    writeParams.writeCommand.serializeObjects.Add(new SerializationInfo {
                        serializationObject = obj, serializationIndex = index
                    });
                    writeParams.referenceMap.AddMapping(writeParams.writeCommand.internalName, index, obj);
                }

                foreach (var obj in manifestDependencies)
                {
                    // MonoScripts need to live beside the MonoBehavior (in this case ScriptableObject) and loaded first. We could move it to it's own bundle, but this is safer and it's a lightweight object
                    var type = ContentBuildInterface.GetTypeForObject(obj);
                    if (obj.guid == GUIDHelper.UnityBuiltinResources)
                    {
                        // For Builtin Resources, we can reference them directly
                        // TODO: Once we switch to using GlobalObjectId for SBP, we will need a mapping for certain special cases of GUID <> FilePath for Builtin Resources
                        writeParams.referenceMap.AddMapping(obj.filePath, obj.localIdentifierInFile, obj);
                    }
                    else if (type == typeof(MonoScript))
                    {
                        writeParams.writeCommand.serializeObjects.Add(new SerializationInfo {
                            serializationObject = obj, serializationIndex = generator.SerializationIndexFromObjectIdentifier(obj)
                        });
                        writeParams.referenceMap.AddMapping(writeParams.writeCommand.internalName, generator.SerializationIndexFromObjectIdentifier(obj), obj);
                    }
                    else if (obj.guid == assetGuid)
                    {
                        // If we are a specific built-in asset, only add the built-in asset
                        if (fileIdent != -1 && obj.localIdentifierInFile != fileIdent)
                        {
                            continue;
                        }

                        writeParams.writeCommand.serializeObjects.Add(new SerializationInfo {
                            serializationObject = obj, serializationIndex = generator.SerializationIndexFromObjectIdentifier(obj)
                        });
                        writeParams.referenceMap.AddMapping(writeParams.writeCommand.internalName, generator.SerializationIndexFromObjectIdentifier(obj), obj);
                    }
                    else if (obj.guid == GUIDHelper.UnityBuiltinExtraResources)
                    {
                        var convGUID = obj.guid;
                        GUIDHelper.PackBuiltinExtraWithFileIdent(ref convGUID, obj.localIdentifierInFile);
                        writeParams.referenceMap.AddMapping(generator.GenerateAssetBundleInternalFileName(convGUID), generator.SerializationIndexFromObjectIdentifier(obj), obj);

                        dependencies.Add(convGUID);
                    }
                    else if (!obj.guid.Empty())
                    {
                        writeParams.referenceMap.AddMapping(generator.GenerateAssetBundleInternalFileName(obj.guid), generator.SerializationIndexFromObjectIdentifier(obj), obj);
                        dependencies.Add(obj.guid);
                    }
                    else
                    {
                        throw new Exception($"Invalid dependency! GUID={obj.guid}, type={type}");
                    }

                    if (type != null)
                    {
                        types.Add(type);
                    }
                }

                // Write the serialized file
                var result = ContentBuildInterface.WriteSerializedFile(k_TempBuildPath, writeParams);
                // Archive and compress the serialized & resource files for the previous operation
                var crc = ContentBuildInterface.ArchiveAndCompress(result.resourceFiles.ToArray(), cacheFilePath, UnityEngine.BuildCompression.Uncompressed);

                // Because the shader compiler progress bar hooks are absolute shit
                EditorUtility.ClearProgressBar();

                //Debug.Log($"Wrote '{writeParams.writeCommand.fileName}' to '{k_TempBuildPath}/{writeParams.writeCommand.internalName}' resulting in {result.serializedObjects.Count} objects in the serialized file.");
                //Debug.Log($"Archived '{k_TempBuildPath}/{writeParams.writeCommand.internalName}' to '{cacheFilePath}' resulting in {crc} CRC.");

                return(crc != 0);
            }
        }
        public static void BuildSubSceneBundle(string manifestPath, string bundleName, string bundlePath, BuildTarget target, HashSet <Entities.Hash128> dependencies)
        {
            using (new BuildInterfacesWrapper())
            {
                Directory.CreateDirectory(k_TempBuildPath);

                // Deterministic ID Generator
                var generator = new Unity5PackedIdentifiers();

                // Target platform settings & script information
                var buildSettings = new BuildSettings
                {
                    buildFlags = ContentBuildFlags.None,
                    target     = target,
                    group      = BuildPipeline.GetBuildTargetGroup(target),
                    typeDB     = null
                };

#if UNITY_2020_1_OR_NEWER
                // Collect all the objects we need for this asset & bundle (returned array order is deterministic)
                var manifestObjects =
                    ContentBuildInterface.GetPlayerObjectIdentifiersInSerializedFile(manifestPath, buildSettings.target);
#else
                var method = typeof(ContentBuildInterface).GetMethod("GetPlayerObjectIdentifiersInSerializedFile",
                                                                     System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
                // Collect all the objects we need for this asset & bundle (returned array order is deterministic)
                var manifestObjects =
                    (ObjectIdentifier[])method.Invoke(null, new object[] { manifestPath, buildSettings.target });
#endif
                // Collect all the objects we need to reference for this asset (returned array order is deterministic)
                var manifestDependencies =
                    ContentBuildInterface.GetPlayerDependenciesForObjects(manifestObjects, buildSettings.target,
                                                                          buildSettings.typeDB);

                // Scene / Project lighting information
                var globalUsage = ContentBuildInterface.GetGlobalUsageFromGraphicsSettings();
                globalUsage = ForceKeepInstancingVariants(globalUsage);

                // Inter-asset feature usage (shader features, used mesh channels)
                var usageSet = new BuildUsageTagSet();
                ContentBuildInterface.CalculateBuildUsageTags(manifestDependencies, manifestDependencies, globalUsage,
                                                              usageSet); // TODO: Cache & Append to the assets that are influenced by this usageTagSet, ideally it would be a nice api to extract just the data for a given asset or object from the result

                // Bundle all the needed write parameters
                var writeParams = new WriteParameters
                {
                    // Target platform settings & script information
                    settings = buildSettings,

                    // Scene / Project lighting information
                    globalUsage = globalUsage,

                    // Inter-asset feature usage (shader features, used mesh channels)
                    usageSet = usageSet,

                    // Serialized File Layout
                    writeCommand = new WriteCommand
                    {
                        fileName         = generator.GenerateInternalFileName(bundleName),
                        internalName     = generator.GenerateAssetBundleInternalFileName(bundleName),
                        serializeObjects = new List <SerializationInfo>() // Populated Below
                    },

                    // External object references
                    referenceMap = new BuildReferenceMap(), // Populated Below

                    // Asset Bundle object layout
                    bundleInfo = new AssetBundleInfo
                    {
                        bundleName = bundleName,
                        // What is loadable from this bundle
                        bundleAssets = new List <AssetLoadInfo>
                        {
                            // The manifest object and it's dependencies
                            new AssetLoadInfo
                            {
                                address         = bundleName,
                                asset           = new GUID(), // TODO: Remove this as it is unused in C++
                                includedObjects =
                                    manifestObjects
                                    .ToList(),     // TODO: In our effort to modernize the public API design we over complicated it trying to take List or return ReadOnlyLists. Should have just stuck with Arrays[] in all places
                                referencedObjects = manifestDependencies.ToList()
                            }
                        }
                    }
                };

                // The requirement is that a single asset bundle only contains the ObjectManifest and the objects that are directly part of the asset, objects for external assets will be in their own bundles. IE: 1 asset per bundle layout
                // So this means we need to take manifestObjects & manifestDependencies and filter storing them into writeCommand.serializeObjects and/or referenceMap based on if they are this asset or other assets
                foreach (var obj in manifestObjects)
                {
                    writeParams.writeCommand.serializeObjects.Add(new SerializationInfo
                    {
                        serializationObject = obj,
                        serializationIndex  = generator.SerializationIndexFromObjectIdentifier(obj)
                    });
                    writeParams.referenceMap.AddMapping(writeParams.writeCommand.internalName,
                                                        generator.SerializationIndexFromObjectIdentifier(obj), obj);
                }

                foreach (var obj in manifestDependencies)
                {
                    // MonoScripts need to live beside the MonoBehavior (in this case ScriptableObject) and loaded first. We could move it to it's own bundle, but this is safer and it's a lightweight object
                    var type = ContentBuildInterface.GetTypeForObject(obj);
                    if (obj.guid == k_UnityBuiltinResources)
                    {
                        // For Builtin Resources, we can reference them directly
                        // TODO: Once we switch to using GlobalObjectId for SBP, we will need a mapping for certain special cases of GUID <> FilePath for Builtin Resources
                        writeParams.referenceMap.AddMapping(obj.filePath, obj.localIdentifierInFile, obj);
                    }
                    else if (type == typeof(MonoScript))
                    {
                        writeParams.writeCommand.serializeObjects.Add(new SerializationInfo {
                            serializationObject = obj, serializationIndex = generator.SerializationIndexFromObjectIdentifier(obj)
                        });
                        writeParams.referenceMap.AddMapping(writeParams.writeCommand.internalName, generator.SerializationIndexFromObjectIdentifier(obj), obj);
                    }
                    else if (!obj.guid.Empty())
                    {
                        writeParams.referenceMap.AddMapping(
                            generator.GenerateAssetBundleInternalFileName(obj.guid.ToString()),
                            generator.SerializationIndexFromObjectIdentifier(obj), obj);
                    }

                    // This will be solvable after we move SBP into the asset pipeline as importers.
                    if (!obj.guid.Empty() && type != typeof(MonoScript))
                    {
                        var convGUID = obj.guid;
                        if (obj.guid == k_UnityBuiltinExtraResources)
                        {
                            PackBuiltinExtraWithFileIdent(ref convGUID, obj.localIdentifierInFile);
                        }

                        dependencies?.Add(convGUID);
                    }
                }

                // Write the serialized file
                var result = ContentBuildInterface.WriteSerializedFile(k_TempBuildPath, writeParams);
                // Archive and compress the serialized & resource files for the previous operation
                var crc = ContentBuildInterface.ArchiveAndCompress(result.resourceFiles.ToArray(), bundlePath,
                                                                   UnityEngine.BuildCompression.Uncompressed);

                // Because the shader compiler progress bar hooks are absolute shit
                EditorUtility.ClearProgressBar();

                //Debug.Log($"Wrote '{writeParams.writeCommand.fileName}' to '{k_TempBuildPath}/{writeParams.writeCommand.internalName}' resulting in {result.serializedObjects.Count} objects in the serialized file.");
                //Debug.Log($"Archived '{k_TempBuildPath}/{writeParams.writeCommand.internalName}' to '{cacheFilePath}' resulting in {crc} CRC.");

                Directory.Delete(k_TempBuildPath, true);
            }
        }
예제 #4
0
        public async Task <IActionResult> PostNodesAsync(string sessionName, [FromBody] WriteParameters writeParam)
        {
            foreach (var state in writeParam.listOfVaribleState)
            {
                if (state == null || !state.IsValid)
                {
                    return(BadRequest(new
                    {
                        error = "Insert a valid value for a Variable Node."
                    }));
                }
            }



            if (!(await _uaClient.CheckSession(sessionName)))
            {
                return(StatusCode(500, new
                {
                    error = "Session " + sessionName + " NotAvailable"
                }));
            }

            List <string> listOfNodeId = new List <string>();

            foreach (var node_id in writeParam.listOfNodeId)
            {
                var decodedNodeId = WebUtility.UrlDecode(node_id);
                listOfNodeId.Add(decodedNodeId);
            }

            List <Node> sourceNodes = new List <Node>();
            Node        sourceNode;

            foreach (var decodedNodeId in listOfNodeId)
            {
                try
                {
                    sourceNode = await _uaClient.ReadNodeAsync(sessionName, decodedNodeId);

                    if (sourceNode.NodeClass != NodeClass.Variable)
                    {
                        return(BadRequest(new
                        {
                            error = "There is no Value for the Node specified by the NodeId " + decodedNodeId
                        }));
                    }

                    sourceNodes.Add(sourceNode);
                }
                catch (ServiceResultException exc)
                {
                    switch (exc.StatusCode)
                    {
                    case StatusCodes.BadNodeIdUnknown:
                        return(NotFound(new
                        {
                            error = "Wrong ID: There is no Resource with ID " + decodedNodeId
                        }));

                    case StatusCodes.BadNodeIdInvalid:
                        return(BadRequest(new
                        {
                            error = "Provided ID is invalid"
                        }));

                    case StatusCodes.BadSessionIdInvalid:
                    case StatusCodes.BadSessionClosed:
                    case StatusCodes.BadSessionNotActivated:
                    case StatusCodes.BadTooManySessions:
                        return(StatusCode(500, new
                        {
                            error = "Connection Lost"
                        }));

                    default:
                        return(StatusCode(500, new
                        {
                            error = exc.Message
                        }));
                    }
                }
                catch (SessionNotAvailableException)
                {
                    return(StatusCode(500, new
                    {
                        error = "Session " + sessionName + " NotAvailable"
                    }));
                }
            }


            List <VariableNode> variablesNode = new List <VariableNode>();

            foreach (var node in sourceNodes)
            {
                VariableNode variableNode = (VariableNode)node;
                variablesNode.Add(variableNode);
            }


            try
            {
                await _uaClient.WriteNodeValuesAsync(sessionName, variablesNode, writeParam.listOfVaribleState);
            }
            catch (ValueToWriteTypeException exc)
            {
                return(BadRequest(new
                {
                    error = exc.Message
                }));
            }
            catch (NotImplementedException exc)
            {
                return(StatusCode(500, new
                {
                    error = exc.Message
                }));
            }
            catch (ServiceResultException exc)
            {
                switch (exc.StatusCode)
                {
                case (StatusCodes.BadTypeMismatch):
                    return(BadRequest(new
                    {
                        error = "Wrong Type - Check data and try again"
                    }));

                case StatusCodes.BadSessionIdInvalid:
                case StatusCodes.BadSessionClosed:
                case StatusCodes.BadSessionNotActivated:
                case StatusCodes.BadTooManySessions:
                    return(StatusCode(500, new
                    {
                        error = "Connection Lost"
                    }));

                default:
                    return(BadRequest(new
                    {
                        error = exc.Message
                    }));
                }
            }
            return(Ok("Write on Node {node_id} in the Data Set {ds_id} executed."));
        }
예제 #5
0
        public string Write(WriteParameters parameters)
        {
            KmlWriteParameters p = parameters as KmlWriteParameters;
            var boards           = p.Boards;

            if (boards.Count == 0)
            {
                return(null);
            }

            var colors = boards.Select(a => p.ColorsProvider.GetBoardColor(a)).Distinct().ToList();
            var styles = CreateStyles(colors).ToList();

            var document = new Document();

            document.Name = System.IO.Path.GetFileNameWithoutExtension(p.FilePath);

            foreach (var group in boards.GroupBy(a => a.Address.City))
            {
                Folder f = new Folder();
                f.Name = group.Key;
                foreach (var b in group)
                {
                    var    placemark = new Placemark();
                    var    c         = p.ColorsProvider.GetBoardColor(b);
                    string name      = string.IsNullOrEmpty(b.Code) ? (b.Address.ToShortString()) : (b.Code + " " + b.Address.ToShortString());
                    placemark.Name = name;
                    var styleId = styles.First(a => a.Id == $"colorIcon_{c.R}_{c.G}_{c.B}").Id;
                    placemark.StyleUrl = new Uri($"#{styleId}", UriKind.Relative);
                    placemark.Geometry = new SharpKml.Dom.Point
                    {
                        Coordinate = new Vector(b.Location.Latitude, b.Location.Longitude)
                    };

                    string description = $"{b.Type} {b.Size}, сторона {b.Side}";
                    if (b.Metrics != null && b.Metrics.OTS != 0)
                    {
                        description += $"<br>OTS: {b.Metrics.OTS} 000, GRP: {b.Metrics.GRP}";
                    }
                    description          += $"<img src=\"{b.Photo.ToString()}\" height =\"300px\" width=\"auto\"/>";
                    description           = $"<![CDATA[{description}]]>";
                    placemark.Description = new Description {
                        Text = description
                    };

                    f.AddFeature(placemark);
                }
                document.AddFeature(f);
            }

            foreach (var s in styles)
            {
                document.AddStyle(s);
            }

            KmlFile kml = KmlFile.Create(document, false);
            KmzFile k   = KmzFile.Create(kml);

            string path = p.FilePath;

            if (System.IO.File.Exists(path))
            {
                System.IO.File.Delete(path);
            }
            using (var stream = System.IO.File.OpenWrite(path))
            {
                k.Save(stream);
            }

            return(path);
        }
예제 #6
0
        public static NPath BuildSlimGameManagers(BuildTarget target, string[] scenes, bool development, string typeDBDirectory)
        {
            NPath tempPath;

            WriteManagerParameters mParams;
            WriteParameters        wParams;

            WriteCommand[] writeCommands;
            PreloadInfo    preloadInfo;

            // Setup
            {
                tempPath = TempDataPath;
                tempPath.CreateDirectory();
                tempPath.Combine("Resources").MakeAbsolute().CreateDirectory();

                //work around bug in unity's TypeDBHelper where it assumes Library/Type will exist
                new NPath("Library/Type").EnsureDirectoryExists();

                mParams = new WriteManagerParameters
                {
                    settings = new UnityEditor.Build.Content.BuildSettings
                    {
                        target     = target,
                        group      = UnityEditor.BuildPipeline.GetBuildTargetGroup(target),
                        buildFlags = development ? ContentBuildFlags.DevelopmentBuild : ContentBuildFlags.None,
                        typeDB     = TypeDbHelper.GetForPlayer(typeDBDirectory)
                    },
                    globalUsage  = ContentBuildInterface.GetGlobalUsageFromGraphicsSettings(),
                    referenceMap = new BuildReferenceMap()
                };

                wParams = new WriteParameters
                {
                    settings     = mParams.settings,
                    globalUsage  = mParams.globalUsage,
                    referenceMap = mParams.referenceMap,
                    usageSet     = new BuildUsageTagSet()
                };

                writeCommands = new[]
                {
                    new WriteCommand
                    {
                        fileName         = "unity_builtin_extra",
                        internalName     = "Resources/unity_builtin_extra",
                        serializeObjects = new List <SerializationInfo>()
                    },
                    new WriteCommand
                    {
                        fileName         = "globalgamemanagers.assets",
                        internalName     = "globalgamemanagers.assets",
                        serializeObjects = new List <SerializationInfo>()
                    }
                };

                preloadInfo = new PreloadInfo
                {
                    preloadObjects = new List <ObjectIdentifier>()
                };
            }

            // Dependency Calculation
            {
                var dependencyResults = ContentBuildInterface.CalculatePlayerDependenciesForGameManagers(mParams.settings, mParams.globalUsage, wParams.usageSet);

                var referencedObjects = dependencyResults.referencedObjects.ToArray();
                var types             = ContentBuildInterface.GetTypeForObjects(referencedObjects);

                for (int i = 0; i < referencedObjects.Length; i++)
                {
                    if (referencedObjects[i].guid == k_UnityBuiltinResources)
                    {
                        // unity default resources contain scripts that need to be preloaded
                        if (types[i] == typeof(MonoScript))
                        {
                            preloadInfo.preloadObjects.Add(referencedObjects[i]);
                        }

                        // Prebuild player specific default resources file, don't remap local identifiers
                        mParams.referenceMap.AddMapping("Library/unity default resources", referencedObjects[i].localIdentifierInFile, referencedObjects[i]);
                    }
                    else if (referencedObjects[i].guid == k_UnityBuiltinExtraResources)
                    {
                        if (types[i] == typeof(Shader))
                        {
                            var command = writeCommands[0];
                            // Resources/unity_builtin_extra
                            // Don't remap local identifiers
                            var info = new SerializationInfo
                            {
                                serializationObject = referencedObjects[i],
                                serializationIndex  = referencedObjects[i].localIdentifierInFile
                            };

                            command.serializeObjects.Add(info);
                            mParams.referenceMap.AddMapping(command.internalName, info.serializationIndex, info.serializationObject);
                        }
                        else
                        {
                            var command = writeCommands[1];
                            // globalgamemanagers.assets
                            // Squash / Remap local identifiers, starting at 2 (PreloadData 1)
                            var info = new SerializationInfo
                            {
                                serializationObject = referencedObjects[i],
                                serializationIndex  = command.serializeObjects.Count + 2
                            };

                            command.serializeObjects.Add(info);
                            mParams.referenceMap.AddMapping(command.internalName, info.serializationIndex, info.serializationObject);
                        }
                    }
                    else if (types[i] == typeof(MonoScript))
                    {
                        //globalgamemanagers.assets
                        //error because we can't support all the ggm features in slim builds
                    }
                    else
                    {
                        //globalgamemanagers.assets
                        //error because we can't support all the ggm features in slim builds
                    }
                }
            }

            // Writing globalgamemanagers
            {
                var writeResults = ContentBuildInterface.WriteGameManagersSerializedFile(tempPath.ToString(), mParams);
                EditorUtility.ClearProgressBar();
                //if (writeResults.serializedObjects.Count == 0) return "FAIL";
            }

            // Writing globalgamemanagers.assets
            {
                wParams.writeCommand = writeCommands[1];
                wParams.preloadInfo  = preloadInfo;
                var writeResults = ContentBuildInterface.WriteSerializedFile(tempPath.ToString(), wParams);
                EditorUtility.ClearProgressBar();
                //if (writeResults.serializedObjects.Count == 0) return "FAIL";
            }

            // Writing unity_builtin_extra"
            {
                wParams.writeCommand = writeCommands[0];
                wParams.preloadInfo  = null;

                // unity_builtin_extras requires absolutepath writing, so fixup the internalName and referenceMap for this
                wParams.writeCommand.internalName = tempPath.Combine(wParams.writeCommand.internalName).MakeAbsolute().ToString();
                wParams.referenceMap.AddMappings(wParams.writeCommand.internalName, wParams.writeCommand.serializeObjects.ToArray(), true);

                var writeResults = ContentBuildInterface.WriteSerializedFile(tempPath.Combine("Resources").ToString(), wParams);
                EditorUtility.ClearProgressBar();
                //if (writeResults.serializedObjects.Count == 0) return "FAIL";
            }

            {
                var parameters = new BundleBuildParameters(mParams.settings.target, mParams.settings.group, TempStreamingAssetsPath.ToString());
                parameters.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
                parameters.ScriptInfo        = mParams.settings.typeDB;

                // Writing scenes.bundle
                {
                    WriteSceneBundles(parameters, scenes);
                    //if (???) return "FAIL";
                }

                // Writing resources.bundle
                {
                    WriteResourcesBundles(parameters);
                    //if (???) return "FAIL";
                }

                {
                    WriteRenderPipelineBundles(parameters);
                    //if (???) return "FAIL";
                }
            }

            return(tempPath);
        }