Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(ui): fix main menu ui
  • Loading branch information
Xenira committed Dec 3, 2023
1 parent 13f3231 commit fe877f5
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 38 deletions.
3 changes: 3 additions & 0 deletions plugin/TechtonicaVr.csproj
Expand Up @@ -71,6 +71,9 @@
<Reference Include="Unity.Postprocessing.Runtime">
<HintPath>..\strip-dll\Unity.Postprocessing.Runtime.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>..\strip-dll\UnityEngine.UIModule.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
Expand Down
15 changes: 15 additions & 0 deletions plugin/src/Plugin.cs
Expand Up @@ -14,6 +14,7 @@
using TechtonicaVR.Util;
using Plugin.Input;
using TechtonicaVR.Assets;
using UnityEngine.SceneManagement;

namespace TechtonicaVR;

Expand Down Expand Up @@ -67,6 +68,20 @@ private void Awake()
new AssetLoader();

Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");

// Add listener for scene change
SceneManager.sceneLoaded += OnSceneLoaded;
}

private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
// Handle scene change logic here
Logger.LogInfo($"Scene {scene.name} loaded!");
if (scene.name == "Main Menu")
{
Logger.LogInfo("Scene is MainMenu, creating MainMenuPatch...");
MainMenuPatch.Create();
}
}

public static System.Collections.IEnumerator InitVRLoader()
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/camera/camera_manager.cs
Expand Up @@ -121,7 +121,7 @@ IEnumerator PatchCoroutine()
{
yield return new WaitForSeconds(1);

PatchBehaviour.Create();
MainGamePatch.Create();
yield break;
}

Expand Down
13 changes: 5 additions & 8 deletions plugin/src/Patch.cs → plugin/src/main_game_patch.cs
@@ -1,11 +1,9 @@
using System;
using System.Linq;
using TechtonicaVR.Patches;
using TechtonicaVR.Patches.Player;
using TechtonicaVR.Patches.UI;
using TechtonicaVR.Patches.MainGame.Player;
using TechtonicaVR.Patches.MainGame.UI;
using TechtonicaVR.Patches.Universal;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace TechtonicaVR;

Expand All @@ -15,7 +13,7 @@ public interface IPatch
bool IsApplied();
}

public class PatchBehaviour : MonoBehaviour
public class MainGamePatch : MonoBehaviour
{

private IPatch[] playerSpringPatches = [
Expand All @@ -25,16 +23,15 @@ public class PatchBehaviour : MonoBehaviour
new SetDefaultLayerPatch("Scanner", true),
new SetDefaultLayerPatch("Spectral Cube (Sparks)", true),
new SetDefaultLayerPatch("Spectral Cube (Paladin)", true),
// new AimTransformPatch(),
];

IPatch[] patches = [];

private float startTime = Time.time;

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

return instance;
}
Expand Down
40 changes: 40 additions & 0 deletions plugin/src/main_menu_patch.cs
@@ -0,0 +1,40 @@
using System;
using System.Linq;
using TechtonicaVR.Patches.MainMenu;
using UnityEngine;

namespace TechtonicaVR;

public class MainMenuPatch : MonoBehaviour
{

IPatch[] patches = [
new CameraOriginPatch(),
new SpaceBGCameraPatch(),
new MenuCanvasPatch(),
];

private float startTime = Time.time;

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

return instance;
}

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

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

if (!patches.Any())
{
gameObject.SetActive(false);
}
}
}
@@ -1,7 +1,7 @@
using Plugin.Input;
using UnityEngine;

namespace TechtonicaVR.Patches.Player;
namespace TechtonicaVR.Patches.MainGame.Player;

public class RightHandAttachPatch : GameObjectPatch
{
Expand Down
@@ -1,6 +1,6 @@
using UnityEngine;

namespace TechtonicaVR.Patches.UI;
namespace TechtonicaVR.Patches.MainGame.UI;

class DialoguePopupPatch : GameComponentPatch<DialogueEntryPopupUI>

Expand Down
@@ -1,6 +1,6 @@
using UnityEngine;

namespace TechtonicaVR.Patches.UI;
namespace TechtonicaVR.Patches.MainGame.UI;

public class InventoryAndCraftingPatch : GameObjectPatch
{
Expand Down
@@ -1,6 +1,6 @@
using UnityEngine;

namespace TechtonicaVR.Patches.UI;
namespace TechtonicaVR.Patches.MainGame.UI;

class NotificationCanvasPatche : GameComponentPatch<NotificationUI>

Expand Down
@@ -1,6 +1,6 @@
using UnityEngine;

namespace TechtonicaVR.Patches.UI;
namespace TechtonicaVR.Patches.MainGame.UI;

class QuestTaskListPatch : GameComponentPatch<QuestUI>

Expand Down
@@ -1,7 +1,7 @@
using TechtonicaVR.Patches.Universal;
using UnityEngine;

namespace TechtonicaVR.Patches.UI;
namespace TechtonicaVR.Patches.MainGame.UI;

class ToolbarUiPatch : GameComponentPatch<ToolbarUI>

Expand Down
16 changes: 16 additions & 0 deletions plugin/src/patch/main_menu/camera_origin_patch.cs
@@ -0,0 +1,16 @@
using UnityEngine;

namespace TechtonicaVR.Patches.MainMenu;

public class CameraOriginPatch : GameObjectPatch
{
public CameraOriginPatch() : base("Main Camera (origin)")
{
}

protected override bool Apply(GameObject gameObject)
{
gameObject.transform.position = new Vector3(-1614, 23, -2312);
return true;
}
}
29 changes: 29 additions & 0 deletions plugin/src/patch/main_menu/menu_canvas_patch.cs
@@ -0,0 +1,29 @@
using UnityEngine;

namespace TechtonicaVR.Patches.MainMenu;

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

protected override bool Apply(GameObject gameObject)
{
var origin = GameObject.Find("Main Camera (origin)");
if (origin == null)
{
return false;
}

gameObject.transform.parent = origin.transform;
gameObject.transform.localPosition = new Vector3(5.5982f, 0.7818f, 5.9599f);
gameObject.transform.rotation = Quaternion.Euler(0, 40.4374f, 0);
gameObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);

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

return true;
}
}
29 changes: 29 additions & 0 deletions plugin/src/patch/main_menu/space_bg_camera_patch.cs
@@ -0,0 +1,29 @@
using FluffyUnderware.DevTools.Extensions;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using Valve.VR;

namespace TechtonicaVR.Patches.MainMenu;

public class SpaceBGCameraPatch : GameObjectPatch
{
public SpaceBGCameraPatch() : base("Space BG Camera")
{
}

protected override bool Apply(GameObject gameObject)
{
var origin = GameObject.Find("Main Camera (origin)");
if (origin == null)
{
return false;
}

gameObject.AddComponent<SteamVR_TrackedObject>();
gameObject.GetComponent<PostProcessLayer>().enabled = false;
Object.Destroy(gameObject.GetComponent("SpaceGraphicsToolkit.SgtCamera"));

gameObject.transform.parent = origin.transform;
return true;
}
}
23 changes: 0 additions & 23 deletions plugin/src/patch/player/aim_transform_patch.cs

This file was deleted.

0 comments on commit fe877f5

Please sign in to comment.