Example #1
0
        /// <summary>
        /// Creates a game settings asset that contains necessary data for starting up the game (for example initial scene).
        /// </summary>
        /// <param name="buildFolder">Absolute path to the root folder of the build. This is where the settings assets
        ///                           will be output.</param>
        /// <param name="info">Platform information about the current build.</param>
        private static void CreateStartupSettings(string buildFolder, PlatformInfo info)
        {
            IntPtr infoPtr = IntPtr.Zero;

            if (info != null)
            {
                infoPtr = info.GetCachedPtr();
            }

            Internal_CreateStartupSettings(buildFolder, infoPtr);
        }
Example #2
0
        /// <summary>
        /// Finds all used resources by the build and packages them into an output folder.
        /// </summary>
        /// <param name="buildFolder">Absolute path to the root folder of the build. This is where the packaged resource
        ///                           folder be placed.</param>
        /// <param name="info">Platform information about the current build.</param>
        private static void PackageResources(string buildFolder, PlatformInfo info)
        {
            IntPtr infoPtr = IntPtr.Zero;

            if (info != null)
            {
                infoPtr = info.GetCachedPtr();
            }

            Internal_PackageResources(buildFolder, infoPtr);
        }
Example #3
0
        /// <summary>
        /// Injects icons specified in <see cref="PlatformInfo"/> into an executable at the specified path.
        /// </summary>
        /// <param name="filePath">Absolute path to the executable to inject icons in.</param>
        /// <param name="info">Object containing references to icons to inject.</param>
        private static void InjectIcons(string filePath, PlatformInfo info)
        {
            IntPtr infoPtr = IntPtr.Zero;

            if (info != null)
            {
                infoPtr = info.GetCachedPtr();
            }

            Internal_InjectIcons(filePath, infoPtr);
        }
Example #4
0
        /// <summary>
        /// Builds the executable and packages the game.
        /// </summary>
        public static void Build()
        {
            PlatformType activePlatform = ActivePlatform;
            PlatformInfo platformInfo   = ActivePlatformInfo;

            string srcRoot  = GetBuildFolder(BuildFolder.SourceRoot, activePlatform);
            string destRoot = GetBuildFolder(BuildFolder.DestinationRoot, activePlatform);

            // Prepare clean destination folder
            if (Directory.Exists(destRoot))
            {
                Directory.Delete(destRoot, true);
            }

            Directory.CreateDirectory(destRoot);

            // Compile game assembly
            string bansheeAssemblyFolder;

            if (platformInfo.Debug)
            {
                bansheeAssemblyFolder = GetBuildFolder(BuildFolder.BansheeDebugAssemblies, activePlatform);
            }
            else
            {
                bansheeAssemblyFolder = GetBuildFolder(BuildFolder.BansheeReleaseAssemblies, activePlatform);
            }

            string srcBansheeAssemblyFolder  = Path.Combine(srcRoot, bansheeAssemblyFolder);
            string destBansheeAssemblyFolder = Path.Combine(destRoot, bansheeAssemblyFolder);

            Directory.CreateDirectory(destBansheeAssemblyFolder);
            CompilerInstance ci = ScriptCompiler.CompileAsync(ScriptAssemblyType.Game, ActivePlatform, platformInfo.Debug, destBansheeAssemblyFolder);

            // Copy engine assembly
            {
                string srcFile  = Path.Combine(srcBansheeAssemblyFolder, EditorApplication.EngineAssemblyName);
                string destFile = Path.Combine(destBansheeAssemblyFolder, EditorApplication.EngineAssemblyName);

                File.Copy(srcFile, destFile);
            }

            // Copy builtin data
            string dataFolder = GetBuildFolder(BuildFolder.Data, activePlatform);
            string srcData    = Path.Combine(srcRoot, dataFolder);
            string destData   = Path.Combine(destRoot, dataFolder);

            DirectoryEx.Copy(srcData, destData);

            // Copy native binaries
            string binaryFolder = GetBuildFolder(BuildFolder.NativeBinaries, activePlatform);
            string srcBin       = Path.Combine(srcRoot, binaryFolder);
            string destBin      = destRoot;

            string[] nativeBinaries = GetNativeBinaries(activePlatform);
            foreach (var entry in nativeBinaries)
            {
                string srcFile  = Path.Combine(srcBin, entry);
                string destFile = Path.Combine(destBin, entry);

                File.Copy(srcFile, destFile);
            }

            // Copy .NET framework assemblies
            string frameworkAssemblyFolder     = GetBuildFolder(BuildFolder.FrameworkAssemblies, activePlatform);
            string srcFrameworkAssemblyFolder  = Path.Combine(srcRoot, frameworkAssemblyFolder);
            string destFrameworkAssemblyFolder = Path.Combine(destRoot, frameworkAssemblyFolder);

            Directory.CreateDirectory(destFrameworkAssemblyFolder);

            string[] frameworkAssemblies = GetFrameworkAssemblies(activePlatform);
            foreach (var entry in frameworkAssemblies)
            {
                string srcFile  = Path.Combine(srcFrameworkAssemblyFolder, entry + ".dll");
                string destFile = Path.Combine(destFrameworkAssemblyFolder, entry + ".dll");

                File.Copy(srcFile, destFile);
            }

            // Copy Mono
            string monoFolder     = GetBuildFolder(BuildFolder.Mono, activePlatform);
            string srcMonoFolder  = Path.Combine(srcRoot, monoFolder);
            string destMonoFolder = Path.Combine(destRoot, monoFolder);

            DirectoryEx.Copy(srcMonoFolder, destMonoFolder);

            string srcExecFile  = GetMainExecutable(activePlatform);
            string destExecFile = Path.Combine(destBin, Path.GetFileName(srcExecFile));

            File.Copy(srcExecFile, destExecFile);

            InjectIcons(destExecFile, platformInfo);
            PackageResources(destRoot, platformInfo);
            CreateStartupSettings(destRoot, platformInfo);

            // Wait until compile finishes
            while (!ci.IsDone)
            {
                Thread.Sleep(200);
            }

            ci.Dispose();
        }
Example #5
0
        /// <summary>
        /// (Re)creates GUI with platform-specific options.
        /// </summary>
        private void BuildPlatformOptionsGUI()
        {
            optionsScrollArea.Layout.Clear();
            GUILayout layout = optionsScrollArea.Layout;

            PlatformInfo platformInfo = BuildManager.GetPlatformInfo(selectedPlatform);

            GUILabel options = new GUILabel(new LocEdString("Platform options"), EditorStyles.LabelCentered);

            GUIResourceField sceneField  = new GUIResourceField(typeof(Prefab), new LocEdString("Startup scene"));
            GUIToggleField   debugToggle = new GUIToggleField(new LocEdString("Debug"));

            GUIToggleField fullscreenField = new GUIToggleField(new LocEdString("Fullscreen"));
            GUIIntField    widthField      = new GUIIntField(new LocEdString("Window width"));
            GUIIntField    heightField     = new GUIIntField(new LocEdString("Window height"));

            GUITextField definesField = new GUITextField(new LocEdString("Defines"));

            layout.AddSpace(5);
            layout.AddElement(options);
            layout.AddSpace(5);
            layout.AddElement(sceneField);
            layout.AddElement(debugToggle);
            layout.AddElement(fullscreenField);
            layout.AddElement(widthField);
            layout.AddElement(heightField);
            layout.AddSpace(5);
            layout.AddElement(definesField);
            layout.AddSpace(5);

            sceneField.ValueRef   = platformInfo.MainScene;
            debugToggle.Value     = platformInfo.Debug;
            definesField.Value    = platformInfo.Defines;
            fullscreenField.Value = platformInfo.Fullscreen;
            widthField.Value      = platformInfo.WindowedWidth;
            heightField.Value     = platformInfo.WindowedHeight;

            if (platformInfo.Fullscreen)
            {
                widthField.Active  = false;
                heightField.Active = false;
            }

            sceneField.OnChanged      += x => platformInfo.MainScene = x.As <Prefab>();
            debugToggle.OnChanged     += x => platformInfo.Debug = x;
            definesField.OnChanged    += x => platformInfo.Defines = x;
            fullscreenField.OnChanged += x =>
            {
                widthField.Active  = !x;
                heightField.Active = !x;

                platformInfo.Fullscreen = x;
            };
            widthField.OnChanged  += x => platformInfo.WindowedWidth = x;
            heightField.OnChanged += x => platformInfo.WindowedHeight = x;

            switch (platformInfo.Type)
            {
            case PlatformType.Windows:
            {
                WinPlatformInfo winPlatformInfo = (WinPlatformInfo)platformInfo;

                GUITextField titleField = new GUITextField(new LocEdString("Title"));

                layout.AddElement(titleField);
                layout.AddSpace(5);

                GUITextureField iconField = new GUITextureField(new LocEdString("Icon"));
                layout.AddElement(iconField);

                titleField.Value     = winPlatformInfo.TitleText;
                iconField.TextureRef = winPlatformInfo.Icon;

                titleField.OnChanged += x => winPlatformInfo.TitleText = x;
                iconField.OnChanged  += x => winPlatformInfo.Icon = x.As <Texture>();
            }
            break;
            }
        }
Example #6
0
        /// <summary>
        /// Finds all used resources by the build and packages them into an output folder.
        /// </summary>
        /// <param name="buildFolder">Absolute path to the root folder of the build. This is where the packaged resource
        ///                           folder be placed.</param>
        /// <param name="info">Platform information about the current build.</param>
        private static void PackageResources(string buildFolder, PlatformInfo info)
        {
            IntPtr infoPtr = IntPtr.Zero;
            if (info != null)
                infoPtr = info.GetCachedPtr();

            Internal_PackageResources(buildFolder, infoPtr);
        }
Example #7
0
        /// <summary>
        /// Injects icons specified in <see cref="PlatformInfo"/> into an executable at the specified path.
        /// </summary>
        /// <param name="filePath">Absolute path to the executable to inject icons in.</param>
        /// <param name="info">Object containing references to icons to inject.</param>
        private static void InjectIcons(string filePath, PlatformInfo info)
        {
            IntPtr infoPtr = IntPtr.Zero;
            if (info != null)
                infoPtr = info.GetCachedPtr();

            Internal_InjectIcons(filePath, infoPtr);
        }
Example #8
0
        /// <summary>
        /// Creates a game settings asset that contains necessary data for starting up the game (for example initial scene).
        /// </summary>
        /// <param name="buildFolder">Absolute path to the root folder of the build. This is where the settings assets
        ///                           will be output.</param>
        /// <param name="info">Platform information about the current build.</param>
        private static void CreateStartupSettings(string buildFolder, PlatformInfo info)
        {
            IntPtr infoPtr = IntPtr.Zero;
            if (info != null)
                infoPtr = info.GetCachedPtr();

            Internal_CreateStartupSettings(buildFolder, infoPtr);
        }