Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(ui): fix loading screen
  • Loading branch information
Xenira committed Dec 3, 2023
1 parent fe877f5 commit 08f0536
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 5 deletions.
5 changes: 5 additions & 0 deletions plugin/src/Plugin.cs
Expand Up @@ -82,6 +82,11 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
Logger.LogInfo("Scene is MainMenu, creating MainMenuPatch...");
MainMenuPatch.Create();
}
else if (scene.name == "Loading")
{
Logger.LogInfo("Scene is LoadingScreen, creating LoadingScreenPatch...");
LoadingScreenPatch.Create();
}
}

public static System.Collections.IEnumerator InitVRLoader()
Expand Down
15 changes: 15 additions & 0 deletions plugin/src/debug/disable_loading_screen_complete.cs
@@ -0,0 +1,15 @@
using HarmonyLib;

namespace TechtonicaVR.Debug;

[HarmonyPatch]
public class DisableLoadingScreenComplete
{
[HarmonyPatch(typeof(LoadingUI), "Update")]
[HarmonyPrefix]
public static bool Update()
{
// Set to false to disable loading screen skipping
return true;
}
}
38 changes: 38 additions & 0 deletions plugin/src/loading_screen_patch.cs
@@ -0,0 +1,38 @@
using System;
using System.Linq;
using TechtonicaVR.Patches.LoadingScreen;
using UnityEngine;

namespace TechtonicaVR;

public class LoadingScreenPatch : MonoBehaviour
{

IPatch[] patches = [
new LoadingScreenCanvasPatch(),
];

private float startTime = Time.time;

public static LoadingScreenPatch Create()
{
var instance = new GameObject(nameof(LoadingScreenPatch)).AddComponent<LoadingScreenPatch>();

return instance;
}

void Start()
{
Plugin.Logger.LogDebug("Hello Loading Screen!");
}

void Update()
{
patches = patches.Where(p => !p.Apply()).ToArray();

if (!patches.Any())
{
gameObject.SetActive(false);
}
}
}
2 changes: 1 addition & 1 deletion plugin/src/main_game_patch.cs
Expand Up @@ -48,7 +48,7 @@ void Start()
new DisableComponentPatch<OutlinePostProcess>(),
]).ToArray();

Debug.Log("Hello World!");
Plugin.Logger.LogDebug("Hello World!");
}

void Update()
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main_menu_patch.cs
Expand Up @@ -25,7 +25,7 @@ public static MainMenuPatch Create()

void Start()
{
Debug.Log("Hello Main Menu!");
Plugin.Logger.LogDebug("Hello Main Menu!");
}

void Update()
Expand Down
24 changes: 24 additions & 0 deletions plugin/src/patch/loading_screen/loading_screen_canvas_patch.cs
@@ -0,0 +1,24 @@
using TechtonicaVR.VRCamera;
using UnityEngine;

namespace TechtonicaVR.Patches.LoadingScreen;

public class LoadingScreenCanvasPatch : GameObjectPatch
{
public LoadingScreenCanvasPatch() : base("Canvas")
{
}

protected override bool Apply(GameObject gameObject)
{
gameObject.transform.position = new Vector3(0, 0, 0);
gameObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);

var canvas = gameObject.GetComponent<Canvas>();
canvas.renderMode = RenderMode.WorldSpace;

VRCameraManager.mainCamera.farClipPlane = 20f;

return true;
}
}
6 changes: 3 additions & 3 deletions plugin/src/util/ApplicationManifestHelper.cs
Expand Up @@ -37,20 +37,20 @@ public static void UpdateManifest(string manifestPath, string appKey, string ima
var error = OpenVR.Applications.AddApplicationManifest(manifestPath, false);
if (error != EVRApplicationError.None)
{
Debug.LogError("Failed to set AppManifest " + error);
Plugin.Logger.LogError("Failed to set AppManifest " + error);
}

var processId = System.Diagnostics.Process.GetCurrentProcess().Id;
Plugin.Logger.LogDebug("Identifying application");
var applicationIdentifyErr = OpenVR.Applications.IdentifyApplication((uint)processId, appKey);
if (applicationIdentifyErr != EVRApplicationError.None)
{
Debug.LogError("Error identifying application: " + applicationIdentifyErr);
Plugin.Logger.LogError("Error identifying application: " + applicationIdentifyErr);
}
}
catch (Exception exception)
{
Debug.LogError("Error updating AppManifest: " + exception);
Plugin.Logger.LogError("Error updating AppManifest: " + exception);
}
}

Expand Down

0 comments on commit 08f0536

Please sign in to comment.