Compare commits
3
Commits
c8361d7ebf
...
8398bf5f12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8398bf5f12 | ||
|
|
3ceaff0d4e | ||
|
|
9117362f03 |
@@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using HarmonyLib;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
namespace IngameReveries
|
namespace IngameReveries
|
||||||
@@ -11,21 +10,110 @@ namespace IngameReveries
|
|||||||
// Multiple ModBehaviours in your mod will share the same container.
|
// Multiple ModBehaviours in your mod will share the same container.
|
||||||
public class IngameReveries : ModBehaviour
|
public class IngameReveries : ModBehaviour
|
||||||
{
|
{
|
||||||
|
private GameObject _ingameReveriesUI;
|
||||||
|
|
||||||
|
private AssetBundle _reveriesBundle;
|
||||||
|
private GameObject _reveriesPrefab;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
// Metadata of your mod is stored in this.about
|
// Metadata of your mod is stored in this.about
|
||||||
Debug.Log("Hello! I'm loaded! " + mod.metadata.id);
|
Debug.Log("Hola! I'm loaded! " + mod.metadata.id);
|
||||||
|
|
||||||
// If you need to patch with Harmony, you can use this.harmony to access the Harmony instance for your mod.
|
// If you need to patch with Harmony, you can use this.harmony to access the Harmony instance for your mod.
|
||||||
// It will be created with your mod's id automatically, the first time you access the property.
|
// It will be created with your mod's id automatically, the first time you access the property.
|
||||||
harmony.PatchAll();
|
harmony.PatchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
InitializeAssets();
|
||||||
|
|
||||||
|
SceneManager.sceneLoaded += (scene, mode) =>
|
||||||
|
{
|
||||||
|
// Check if UI already instantiated
|
||||||
|
if (_ingameReveriesUI != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string gameSceneDir = "Assets/Dew/Zones/";
|
||||||
|
string relativeToScene = Path.GetRelativePath(gameSceneDir, scene.path);
|
||||||
|
|
||||||
|
if (!relativeToScene.StartsWith(".."))
|
||||||
|
{
|
||||||
|
Debug.Log($"[IngameReveries] Switched to scene inside {gameSceneDir}");
|
||||||
|
|
||||||
|
GameObject menuViewGO = GameObject.Find("GameLogicPackage/UI/InGame/UI_Common_MenuView");
|
||||||
|
if (menuViewGO == null)
|
||||||
|
{
|
||||||
|
Debug.Log("Couldn't find menu view");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ingameReveriesUI = new GameObject("IngameReveriesUI");
|
||||||
|
_ingameReveriesUI.transform.parent = menuViewGO.transform;
|
||||||
|
Instantiate(DewGUI.widgetWindow, _ingameReveriesUI.transform);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
// Make sure you clean up properly to support Live Reload.
|
// Make sure you clean up properly to support Live Reload.
|
||||||
Debug.Log("Good bye! " + mod.metadata.id);
|
Debug.Log("Good bye! " + mod.metadata.id);
|
||||||
harmony.UnpatchAll();
|
harmony.UnpatchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitializeAssets()
|
||||||
|
{
|
||||||
|
string bundlePath = Path.Combine(mod.path, "assets", "bundle");
|
||||||
|
|
||||||
|
if (!File.Exists(bundlePath))
|
||||||
|
{
|
||||||
|
Debug.LogError($"[IngameReveries] Bundle not found at: {bundlePath}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_reveriesBundle = AssetBundle.GetAllLoadedAssetBundles()
|
||||||
|
.FirstOrDefault(b => b.name == "logosteal" || b.mainAsset != null);
|
||||||
|
|
||||||
|
if (_reveriesBundle == null)
|
||||||
|
{
|
||||||
|
// If it isn't loaded yet, load it from disk
|
||||||
|
Debug.Log("[IngameReveries] Loading Bundle");
|
||||||
|
_reveriesBundle = AssetBundle.LoadFromFile(bundlePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("[IngameReveries] Bundle already loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_reveriesBundle == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("[IngameReveries] Failed to load AssetBundle!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the prefab from the bundle
|
||||||
|
string assetName = _reveriesBundle.GetAllAssetNames().First();
|
||||||
|
_reveriesPrefab = _reveriesBundle.LoadAsset<GameObject>(assetName);
|
||||||
|
|
||||||
|
if (_reveriesPrefab == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("[IngameReveries] Failed to load prefab!");
|
||||||
|
|
||||||
|
// List what's in the bundle for debugging
|
||||||
|
string[] assetNames = _reveriesBundle.GetAllAssetNames();
|
||||||
|
Debug.Log("[IngameReveries] Assets in bundle:");
|
||||||
|
foreach (string name in assetNames)
|
||||||
|
{
|
||||||
|
Debug.Log($" - {name}");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log("[IngameReveries] Successfully loaded prefab!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,6 +219,10 @@
|
|||||||
<HintPath>$(GameManagedDir)\Unity.VisualEffectGraph.Runtime.dll</HintPath>
|
<HintPath>$(GameManagedDir)\Unity.VisualEffectGraph.Runtime.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AssetBundleModule">
|
||||||
|
<HintPath>$(GameManagedDir)\UnityEngine.AssetBundleModule.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="UnityEngine.CoreModule">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<HintPath>$(GameManagedDir)\UnityEngine.CoreModule.dll</HintPath>
|
<HintPath>$(GameManagedDir)\UnityEngine.CoreModule.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
@@ -277,7 +281,11 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="src\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
<Exec Command="echo "Copy build to game folder"
mkdir -p "$(GameModsDir)"
cp -r "$(ProjectDir)about" "$(GameModsDir)"
cp -r "$(ProjectDir)bin" "$(GameModsDir)"" />
|
<Exec Command="echo "Copy build to game folder"
mkdir -p "$(GameModsDir)"
cp -r "$(ProjectDir)about" "$(GameModsDir)"
cp -r "$(ProjectDir)bin" "$(GameModsDir)"
cp -r "$(ProjectDir)assets" "$(GameModsDir)"" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user