Example #1
0
    protected void GenerateFileFromTemplate(string InTemplateFile, string InOutputFile, ProjectParams Params, ConfigHierarchy ConfigCache)
    {
        bool   IsContentOnly        = !Params.IsCodeBasedProject;
        string ProjectConfiguration = Params.ClientConfigsToBuild[0].ToString();

        string UE4GameName = IsContentOnly ? "UE4Game" : Params.ShortProjectName;
        string ProjectName = Params.ShortProjectName;

        if (ProjectConfiguration != "Development")
        {
            UE4GameName += "-HTML5-" + ProjectConfiguration;
            ProjectName += "-HTML5-" + ProjectConfiguration;
        }

        string CanvasScaleMode;

        ConfigCache.GetString("/Script/HTML5PlatformEditor.HTML5TargetSettings", "CanvasScalingMode", out CanvasScaleMode);

        string HeapSize = HTML5SDKInfo.HeapSize(ConfigCache, ProjectConfiguration).ToString();

        StringBuilder outputContents = new StringBuilder();

        using (StreamReader reader = new StreamReader(InTemplateFile))
        {
            string LineStr = null;
            while (reader.Peek() != -1)
            {
                LineStr = reader.ReadLine();
                if (LineStr.Contains("%TIMESTAMP%"))
                {
                    string TimeStamp = DateTime.UtcNow.ToString("yyyyMMddHHmm");
                    LineStr = LineStr.Replace("%TIMESTAMP%", TimeStamp);
                }

                if (LineStr.Contains("%SHORTNAME%"))
                {
                    LineStr = LineStr.Replace("%SHORTNAME%", Params.ShortProjectName);
                }

                if (LineStr.Contains("%UE4GAMENAME%"))
                {
                    LineStr = LineStr.Replace("%UE4GAMENAME%", UE4GameName);
                }

                if (LineStr.Contains("%PROJECTNAME%"))
                {
                    LineStr = LineStr.Replace("%PROJECTNAME%", ProjectName);
                }

                if (LineStr.Contains("%SERVE_COMPRESSED%"))
                {
                    LineStr = LineStr.Replace("%SERVE_COMPRESSED%", Compressed ? "true" : "false");
                }

                if (LineStr.Contains("%DISABLE_INDEXEDDB%"))
                {
                    LineStr = LineStr.Replace("%DISABLE_INDEXEDDB%",
                                              enableIndexedDB ? "" : "enableReadFromIndexedDB = false;\nenableWriteToIndexedDB = false;");
                }

                if (LineStr.Contains("%HEAPSIZE%"))
                {
                    LineStr = LineStr.Replace("%HEAPSIZE%", HeapSize + " * 1024 * 1024");
                }

                if (LineStr.Contains("%UE4CMDLINE%"))
                {
                    string ArgumentString = "'../../../" + Params.ShortProjectName + "/" + Params.ShortProjectName + ".uproject',";
                    ArgumentString += "'-stdout',";                     // suppress double printing to console.log
                    LineStr         = LineStr.Replace("%UE4CMDLINE%", ArgumentString);
                }

                if (LineStr.Contains("%CANVASSCALEMODE%"))
                {
                    string mode = "2 /*ASPECT*/";                     // default
                    if (CanvasScaleMode.Equals("stretch", StringComparison.InvariantCultureIgnoreCase))
                    {
                        mode = "1 /*STRETCH*/";
                    }
                    else if (CanvasScaleMode.Equals("fixed", StringComparison.InvariantCultureIgnoreCase))
                    {
                        mode = "3 /*FIXED*/";
                    }
                    LineStr = LineStr.Replace("%CANVASSCALEMODE%", mode);
                }

                outputContents.AppendLine(LineStr);
            }
        }

        if (outputContents.Length > 0)
        {
            // Save the file
            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(InOutputFile));
                File.WriteAllText(InOutputFile, outputContents.ToString(), Encoding.UTF8);
            }
            catch (Exception)
            {
                // Unable to write to the project file.
            }
        }
    }
Example #2
0
    public void AddGameObject(GameObject go, CanvasAnchor anchor = 0, bool destroyOnSceneLoad = false, CanvasScaleMode scaleMode = 1)
    {
        CanvasAnchors anchors = (scaleMode != CanvasScaleMode.HEIGHT) ? this.m_widthScale : this.m_heightScale;

        TransformUtil.AttachAndPreserveLocalTransform(go.transform, anchors.GetAnchor(anchor));
        if (destroyOnSceneLoad)
        {
            this.DestroyOnSceneLoad(go);
        }
    }
Example #3
0
 public void AddGameObject(GameObject go, CanvasAnchor anchor, bool destroyOnSceneLoad, CanvasScaleMode scaleMode)
 {
     object[] objArray1 = new object[] { go, anchor, destroyOnSceneLoad, scaleMode };
     base.method_8("AddGameObject", objArray1);
 }
    protected void GenerateFileFromTemplate(string InTemplateFile, string InOutputFile, ProjectParams Params, DeploymentContext SC, ConfigHierarchy ConfigCache)
    {
        bool   IsContentOnly        = !Params.IsCodeBasedProject;
        string ProjectConfiguration = Params.ClientConfigsToBuild[0].ToString();

        string UE4GameName = IsContentOnly ? "UE4Game" : (Params.HasClientCookedTargets ? Params.ClientCookedTargets[0] : Params.ShortProjectName);
        string ProjectName = Params.ShortProjectName;

        if (ProjectConfiguration != "Development")
        {
            UE4GameName += "-HTML5-" + ProjectConfiguration;
            ProjectName += "-HTML5-" + ProjectConfiguration;
        }

        string CanvasScaleMode;

        ConfigCache.GetString("/Script/HTML5PlatformEditor.HTML5TargetSettings", "CanvasScalingMode", out CanvasScaleMode);

        StringBuilder outputContents = new StringBuilder();

        using (StreamReader reader = new StreamReader(InTemplateFile))
        {
            string LineStr = null;
            while (reader.Peek() != -1)
            {
                LineStr = reader.ReadLine();
                if (LineStr.Contains("%TIMESTAMP%"))
                {
                    string TimeStamp = DateTime.UtcNow.ToString("yyyyMMddHHmm");
                    LineStr = LineStr.Replace("%TIMESTAMP%", TimeStamp);
                }

                if (LineStr.Contains("%SHORTNAME%"))
                {
                    LineStr = LineStr.Replace("%SHORTNAME%", Params.ShortProjectName);
                }

                if (LineStr.Contains("%UE4GAMENAME%"))
                {
                    LineStr = LineStr.Replace("%UE4GAMENAME%", UE4GameName);
                }

                if (LineStr.Contains("%PROJECTNAME%"))
                {
                    LineStr = LineStr.Replace("%PROJECTNAME%", ProjectName);
                }

                if (LineStr.Contains("%SERVE_COMPRESSED%"))
                {
                    LineStr = LineStr.Replace("%SERVE_COMPRESSED%", Compressed ? "true" : "false");
                }

                if (LineStr.Contains("%DISABLE_INDEXEDDB%"))
                {
                    LineStr = LineStr.Replace("%DISABLE_INDEXEDDB%",
                                              enableIndexedDB ? "" : "enableReadFromIndexedDB = false;\nenableWriteToIndexedDB = false;");
                }

                if (LineStr.Contains("%UE4CMDLINE%"))
                {
                    string ArgumentString = "'../../../" + Params.ShortProjectName + "/" + Params.ShortProjectName + ".uproject',";

                    if (Params.MapToRun.Length > 0)
                    {
                        ArgumentString += "'" + Params.MapToRun + "',";
                    }
                    ArgumentString += "'-stdout',";                     // suppress double printing to console.log
                    LineStr         = LineStr.Replace("%UE4CMDLINE%", ArgumentString);
                }

                if (LineStr.Contains("%CANVASSCALEMODE%"))
                {
                    string mode = "2 /*ASPECT*/";                     // default
                    if (CanvasScaleMode.Equals("stretch", StringComparison.InvariantCultureIgnoreCase))
                    {
                        mode = "1 /*STRETCH*/";
                    }
                    else if (CanvasScaleMode.Equals("fixed", StringComparison.InvariantCultureIgnoreCase))
                    {
                        mode = "3 /*FIXED*/";
                    }
                    LineStr = LineStr.Replace("%CANVASSCALEMODE%", mode);
                }

                if (LineStr.Contains("%MULTITHREADED%"))
                {
                    LineStr = LineStr.Replace("%MULTITHREADED%", enableMultithreading ? "true" : "false");
                }

                if (LineStr.Contains("%OFFSCREENCANVAS%"))
                {
                    LineStr = LineStr.Replace("%OFFSCREENCANVAS%", bMultithreading_UseOffscreenCanvas ? "true" : "false");
                }

                if (LineStr.Contains("%EMSDK_VERSION%"))
                {
                    string escpath = HTML5SDKInfo.EMSCRIPTEN_ROOT.Replace("\\", "/");
                    LineStr = LineStr.Replace("%EMSDK_VERSION%", (ProjectConfiguration == "Shipping") ? HTML5SDKInfo.EmscriptenVersion() : escpath);
                }

                if (LineStr.Contains("%EMSDK_CONFIG%"))
                {
                    string escpath = HTML5SDKInfo.DOT_EMSCRIPTEN.Replace("\\", "/");
                    LineStr = LineStr.Replace("%EMSDK_CONFIG%", (ProjectConfiguration == "Shipping") ? "" : escpath);
                }

                outputContents.AppendLine(LineStr);
            }
        }

        if (outputContents.Length > 0)
        {
            // Save the file
            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(InOutputFile));
                File.WriteAllText(InOutputFile, outputContents.ToString(), Encoding.UTF8);
            }
            catch (Exception)
            {
                // Unable to write to the project file.
            }
        }
    }