mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2026-02-04 22:22:22 +08:00
Compare commits
5 Commits
d8ab2163de
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 98abc31c6f | |||
| d698e0afc1 | |||
| 8077f7fa30 | |||
| fbad19f68f | |||
| 471cf7d013 |
BIN
AssemblyFromGame/Assembly-CSharp.dll
Normal file
BIN
AssemblyFromGame/Assembly-CSharp.dll
Normal file
Binary file not shown.
BIN
AssemblyFromGame/UnityEngine.UI.dll
Normal file
BIN
AssemblyFromGame/UnityEngine.UI.dll
Normal file
Binary file not shown.
@@ -1,177 +1,137 @@
|
||||
## Changelog
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
### 1.3.7
|
||||
* Remove use of MonoMod.Util on loading dll import functions to make mod compatible with HarmonyX 2.13.0 (Although it is not merged yet. Check the PR [here](https://github.com/BepInEx/BepInEx/pull/902)).
|
||||
## Changelog
|
||||
|
||||
### 1.3.6
|
||||
* Support for using subfolder in save filepath (only MODs are doing this currently).
|
||||
* 1.3.8
|
||||
* Support for game version 0.10.34.
|
||||
|
||||
### 1.3.5
|
||||
* Fix a crash issue on choosing language other than English and Chinese.
|
||||
* 1.3.7
|
||||
* Remove use of MonoMod.Util on loading dll import functions to make mod compatible with HarmonyX 2.13.0 (Although it is not merged yet. Check the PR [here](https://github.com/BepInEx/BepInEx/pull/902)).
|
||||
|
||||
### 1.3.4
|
||||
* Support for game version 0.10.28.20759.
|
||||
* 1.3.6
|
||||
* Support for using subfolder in save filepath (only MODs are doing this currently).
|
||||
|
||||
### 1.3.3
|
||||
* Fix a display issue on combobox of compression type.
|
||||
* 1.3.5
|
||||
* Fix a crash issue on choosing language other than English and Chinese.
|
||||
|
||||
### 1.3.2
|
||||
* Add config UI on Save Game dialog, to set compression types.
|
||||
* Change button text to `Save (Compress)` for better understanding.
|
||||
* 1.3.4
|
||||
* Support for game version 0.10.28.20759.
|
||||
|
||||
### 1.3.1
|
||||
* Add config to disable feature for auto saves.
|
||||
* Fix bug that first save after game start is always compressed in Zstd.
|
||||
* 1.3.3
|
||||
* Fix a display issue on combobox of compression type.
|
||||
|
||||
### 1.3.0
|
||||
* Separate config entries for manual save and auto save.
|
||||
* Now you can still get speed benefit while setting compression type to `None` for auto saves, and for manual saves if using the new `Save` button.
|
||||
+ Adds a `nonewrap.dll` for this function.
|
||||
* Update `LZ4` and `Zstd` library to latest version.
|
||||
* `lz4wrap.dll` and `zstdwrap.dll` are compiled using `-O3` instead of `-Os`, expect to be slightly faster but larger.
|
||||
* 1.3.2
|
||||
* Add config UI on Save Game dialog, to set compression types. * Change button text to `Save (Compress)` for better understanding.
|
||||
|
||||
* 1.3.1
|
||||
* Add config to disable feature for auto saves. * Fix bug that first save after game start is always compressed in Zstd.
|
||||
|
||||
* 1.3.0
|
||||
* Separate config entries for manual save and auto save. * Now you can still get speed benefit while setting compression type to `None` for auto saves, and for manual saves if using the new `Save` button. * Adds a `nonewrap.dll` for this function. * Update `LZ4` and `Zstd` library to latest version. * `lz4wrap.dll` and `zstdwrap.dll` are compiled using `-O3` instead of `-Os`, expect to be slightly faster but larger.
|
||||
|
||||
<details>
|
||||
<summary>Older versions</summary>
|
||||
|
||||
### 1.2.2
|
||||
* Fix #4, a bug caused by non-ASCII UTF-8 characters.
|
||||
* Remove use of Harmony.UnpatchAll() to avoid warnings in BepInEx log.
|
||||
* 1.2.2
|
||||
* Fix #4, a bug caused by non-ASCII UTF-8 characters. * Remove use of Harmony.UnpatchAll() to avoid warnings in BepInEx log.
|
||||
|
||||
### 1.2.1
|
||||
* Simplified codes to display compression type and `Decompress` button on save/load UI, making CompressSave compatible with other MODs(like GalacticScale) which override `UILoadGameWindow::OnSelectedChange()`.
|
||||
* Add compression level -5 to -1 for zstd, which makes it working better than lz4(which is actually lz4hc used by lz4frame) now:
|
||||
* -5 gets faster compression speed than lz4 with still a little better compression ratio.
|
||||
* -1 has almost the same speed against lz4 with greater compression ratio.
|
||||
* Due to bug of r2modman UI which does not support negative integer, the config value of compression level is not limited any more.
|
||||
* move native wrapper DLLs into `x64` folder to avoid warning logs on loading BepInEx plugins.
|
||||
* 1.2.1
|
||||
* Simplified codes to display compression type and `Decompress` button on save/load UI, making CompressSave compatible with other MODs(like GalacticScale) which override `UILoadGameWindow::OnSelectedChange()`. * Add compression level -5 to -1 for zstd, which makes it working better than lz4(which is actually lz4hc used by lz4frame) now: * -5 gets faster compression speed than lz4 with still a little better compression ratio. * -1 has almost the same speed against lz4 with greater compression ratio. * Due to bug of r2modman UI which does not support negative integer, the config value of compression level is not limited any more. * move native wrapper DLLs into `x64` folder to avoid warning logs on loading BepInEx plugins.
|
||||
|
||||
### 1.2.0
|
||||
* Match game version 0.9.27.15033.
|
||||
* Add new compression type: zstd (a bit slower but get better compression ratio than lz4).
|
||||
* Add config to set compression type and level(Don't use high compression levels for zstd as they are very slow).
|
||||
* Hide decompress button for normal save files.
|
||||
* Optimize native dlls for other compression library support:
|
||||
* Unified naming rules for filenames and export functions.
|
||||
* Add compression level support.
|
||||
* 1.2.0
|
||||
* Match game version 0.9.27.15033. * Add new compression type: zstd (a bit slower but get better compression ratio than lz4). * Add config to set compression type and level(Don't use high compression levels for zstd as they are very slow). * Hide decompress button for normal save files. * Optimize native dlls for other compression library support: * Unified naming rules for filenames and export functions. * Add compression level support.
|
||||
|
||||
### 1.1.14
|
||||
* Fix Sandbox info on Save/Load Panel.
|
||||
* Fix DLL version info.
|
||||
* 1.1.14
|
||||
* Fix Sandbox info on Save/Load Panel. * Fix DLL version info.
|
||||
|
||||
### 1.1.13
|
||||
* 1.1.13
|
||||
* Match game version 0.9.26.13026. * Move "Sandbox Mode" checkbox on Save Panel to avoid overlap. * Avoid warning message on "Continue" button of main menu.
|
||||
|
||||
* Match game version 0.9.26.13026.
|
||||
* Move "Sandbox Mode" checkbox on Save Panel to avoid overlap.
|
||||
* Avoid warning message on "Continue" button of main menu.
|
||||
* 1.1.12
|
||||
* Match game version 0.9.25.12007.
|
||||
|
||||
### 1.1.12
|
||||
* 1.1.11
|
||||
* Fix 1.1.10 package issue.
|
||||
|
||||
* Match game version 0.9.25.12007.
|
||||
* 1.1.10
|
||||
* Fix 1.1.8 Archive corruption with DIY System, corrupted archives can be fixed by using \[Fix118\] mod
|
||||
|
||||
### 1.1.11
|
||||
Fix118: <https://github.com/bluedoom/DSP_Mod/blob/master/Fix118>
|
||||
|
||||
* Fix 1.1.10 package issue.
|
||||
* 1.1.9
|
||||
* CompressSave is temporarily disabled due to some error with the DIY system.
|
||||
|
||||
### 1.1.10
|
||||
* 1.1.8
|
||||
* Match game version 0.9.24.11029
|
||||
|
||||
* Fix 1.1.8 Archive corruption with DIY System, corrupted archives can be fixed by using \[Fix118\] mod
|
||||
* 1.1.7
|
||||
* Fix incorrect data on statistic panel. * Improve performance.
|
||||
|
||||
Fix118: https://github.com/bluedoom/DSP_Mod/blob/master/Fix118
|
||||
* 1.1.6
|
||||
* fix memory leak
|
||||
|
||||
### 1.1.9
|
||||
* 1.1.5 (Game Version 0.8.22)
|
||||
* Match game version 0.8.22. * Thanks [@starfi5h] for * PatchSave now use transpiler for better robustness. * Change version check to soft warning. * Add PeekableReader so other mods can use BinaryReader.PeekChar(). * Change LZ4DecompressionStream.Position behavior. Position setter i - available now.
|
||||
|
||||
* CompressSave is temporarily disabled due to some error with the DIY system.
|
||||
* 1.1.4 (Game Version 0.8.19)
|
||||
* Match game version 0.8.19.
|
||||
|
||||
### 1.1.8
|
||||
* 1.1.3 (2021/05/29) (Game Version 0.7.18)
|
||||
* Match game version 0.7.18. * Fix memory leak.
|
||||
|
||||
* Match game version 0.9.24.11029
|
||||
* 1.1.2 (2021/03/24) (Game Version 0.6.17)
|
||||
* Handle lz4 library missing Error
|
||||
|
||||
### 1.1.7
|
||||
* 1.1.1 (2021/03/17) (Game Version 0.6.17)
|
||||
* Fix Load Error
|
||||
|
||||
* Fix incorrect data on statistic panel.
|
||||
* Improve performance.
|
||||
|
||||
### 1.1.6
|
||||
|
||||
* fix memory leak
|
||||
|
||||
### 1.1.5 (Game Version 0.8.22)
|
||||
|
||||
* Match game version 0.8.22.
|
||||
* Thanks [@starfi5h] for
|
||||
- PatchSave now use transpiler for better robustness.
|
||||
- Change version check to soft warning.
|
||||
- Add PeekableReader so other mods can use BinaryReader.PeekChar().
|
||||
- Change LZ4DecompressionStream.Position behavior. Position setter i - available now.
|
||||
|
||||
### 1.1.4 (Game Version 0.8.19)
|
||||
|
||||
* Match game version 0.8.19.
|
||||
|
||||
### 1.1.3 (2021/05/29) (Game Version 0.7.18)
|
||||
|
||||
* Match game version 0.7.18.
|
||||
* Fix memory leak.
|
||||
|
||||
### 1.1.2 (2021/03/24) (Game Version 0.6.17)
|
||||
|
||||
* Handle lz4 library missing Error
|
||||
|
||||
### 1.1.1 (2021/03/17) (Game Version 0.6.17)
|
||||
|
||||
* Fix Load Error
|
||||
|
||||
### 1.1.0 (2021/03/17) (Game Version 0.6.17)
|
||||
|
||||
* Add UI button
|
||||
* 1.1.0 (2021/03/17) (Game Version 0.6.17)
|
||||
* Add UI button
|
||||
|
||||
</details>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
## 更新日志
|
||||
|
||||
### 1.3.7
|
||||
* 移除使用MonoMod.Util加载dll导入函数,以使MOD与HarmonyX 2.13.0兼容(尽管此改动尚未合并。[在此](https://github.com/BepInEx/BepInEx/pull/902)查看合并请求)。
|
||||
* 1.3.8
|
||||
* 支持游戏版本 0.10.34。
|
||||
|
||||
### 1.3.6
|
||||
* 支持在存档路径中使用子文件夹(目前只有MOD会这么干)。
|
||||
* 1.3.7
|
||||
* 移除使用MonoMod.Util加载dll导入函数,以使MOD与HarmonyX 2.13.0兼容(尽管此改动尚未合并。[在此](https://github.com/BepInEx/BepInEx/pull/902)查看合并请求)。
|
||||
|
||||
### 1.3.5
|
||||
* 修复了选择英文和中文以外的语言时的崩溃问题。
|
||||
* 1.3.6
|
||||
* 支持在存档路径中使用子文件夹(目前只有MOD会这么干)。
|
||||
|
||||
### 1.3.4
|
||||
* 支持游戏版本 0.10.28.20759。
|
||||
* 1.3.5
|
||||
* 修复了选择英文和中文以外的语言时的崩溃问题。
|
||||
|
||||
### 1.3.3
|
||||
* 修复压缩类型下拉框显示问题。
|
||||
* 1.3.4
|
||||
* 支持游戏版本 0.10.28.20759。
|
||||
|
||||
### 1.3.2
|
||||
* 在保存面板上增加设置压缩方式的UI。
|
||||
* 将按钮文本改为`压缩保存`以区分功能。
|
||||
* 1.3.3
|
||||
* 修复压缩类型下拉框显示问题。
|
||||
|
||||
### 1.3.1
|
||||
* 增加在自动存档中禁用压缩的设置项。
|
||||
* 修复一个导致游戏开始后第一次保存总是使用Zstd压缩的bug。
|
||||
* 1.3.2
|
||||
* 在保存面板上增加设置压缩方式的UI。 * 将按钮文本改为`压缩保存`以区分功能。
|
||||
|
||||
### 1.3.0
|
||||
* 分离手动存档和自动存档的设置项。
|
||||
* 现在在自动存档设置压缩类型为`存储`也可以获得速度提升,手动存档也可以在使用新的`保存`按钮后获得速度提升。
|
||||
+ 为此增加了`nonewrap.dll`。
|
||||
* 更新`LZ4`和`Zstd`库到最新版本。
|
||||
* `lz4wrap.dll`和`zstdwrap.dll`使用`-O3`编译而不是`-Os`,速度略有提升但体积变大。
|
||||
* 1.3.1
|
||||
* 增加在自动存档中禁用压缩的设置项。 * 修复一个导致游戏开始后第一次保存总是使用Zstd压缩的bug。
|
||||
|
||||
* 1.3.0
|
||||
* 分离手动存档和自动存档的设置项。 * 现在在自动存档设置压缩类型为`存储`也可以获得速度提升,手动存档也可以在使用新的`保存`按钮后获得速度提升。 * 为此增加了`nonewrap.dll`。 * 更新`LZ4`和`Zstd`库到最新版本。 * `lz4wrap.dll`和`zstdwrap.dll`使用`-O3`编译而不是`-Os`,速度略有提升但体积变大。
|
||||
|
||||
<details>
|
||||
<summary>Older versions</summary>
|
||||
|
||||
### 1.2.2
|
||||
* 修复 #4,一个导致非ASCII UTF-8字符导致的bug。
|
||||
* 移除使用Harmony.UnpatchAll()以避免在BepInEx日志中出现警告。
|
||||
* 1.2.2
|
||||
* 修复 #4,一个导致非ASCII UTF-8字符导致的bug。 * 移除使用Harmony.UnpatchAll()以避免在BepInEx日志中出现警告。
|
||||
|
||||
### 1.2.1
|
||||
* 简化代码以在存档读取面板上显示压缩类型和`解压`按钮,使得CompressSave与其他MOD(如GalacticScale)兼容,因为它们都覆盖了`UILoadGameWindow::OnSelectedChange()`。
|
||||
* 为zstd添加了压缩等级-5到-1,现在它比lz4(实际上是lz4frame)表现更好了:
|
||||
* -5比lz4更快,但压缩比略有提升。
|
||||
* -1和lz4几乎一样快,但压缩比更高。
|
||||
* 由于r2modman UI的bug,压缩等级的设置项不再限制范围。
|
||||
* 将本地的wrapper DLL移动到`x64`目录。
|
||||
* 1.2.1
|
||||
* 简化代码以在存档读取面板上显示压缩类型和`解压`按钮,使得CompressSave与其他MOD(如GalacticScale)兼容,因为它们都覆盖了`UILoadGameWindow::OnSelectedChange()`。 * 为zstd添加了压缩等级-5到-1,现在它比lz4(实际上是lz4frame)表现更好了: * -5比lz4更快,但压缩比略有提升。 * -1和lz4几乎一样快,但压缩比更高。 * 由于r2modman UI的bug,压缩等级的设置项不再限制范围。 * 将本地的wrapper DLL移动到`x64`目录。
|
||||
|
||||
</details>
|
||||
</details>
|
||||
|
||||
@@ -156,9 +156,16 @@ public class PatchSave
|
||||
}
|
||||
}
|
||||
|
||||
public static void UseCommonSaveCompressionType()
|
||||
{
|
||||
_compressionTypeForSaving = CompressionTypeForSaves;
|
||||
_compressionLevelForSaving = CompressionLevelForSaves;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameSave), "AutoSave")]
|
||||
[HarmonyPatch(typeof(GameSave), "SaveAsLastExit")]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.AutoSave))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.AutoSaveAfterErrored))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.SaveAsLastExit))]
|
||||
private static void BeforeAutoSave()
|
||||
{
|
||||
UseCompressSave = EnableForAutoSaves.Value && EnableCompress;
|
||||
@@ -168,7 +175,7 @@ public class PatchSave
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameSave), "SaveCurrentGame")]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.SaveCurrentGame))]
|
||||
private static IEnumerable<CodeInstruction> SaveCurrentGame_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
/* BinaryWriter binaryWriter = new BinaryWriter(fileStream); => Create compressionStream and replace binaryWriter.
|
||||
@@ -182,23 +189,23 @@ public class PatchSave
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryWriter), [typeof(FileStream)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "CreateBinaryWriter")
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(CreateBinaryWriter))
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(PerformanceMonitor), "BeginStream"))
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(PerformanceMonitor), nameof(PerformanceMonitor.BeginStream)))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "MonitorStream")
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(MonitorStream))
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Stream), "Seek"))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Stream), nameof(Stream.Seek)))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "FileLengthWrite0")
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(FileLengthWrite0))
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryWriter), "Write", [typeof(long)]))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryWriter), nameof(BinaryWriter.Write), [typeof(long)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "FileLengthWrite1")
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(FileLengthWrite1))
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(IDisposable), "Dispose"))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(IDisposable), nameof(IDisposable.Dispose)))
|
||||
).Advance(1).Insert(
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PatchSave), "DisposeCompressionStream"))
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(DisposeCompressionStream)))
|
||||
);
|
||||
EnableCompress = true;
|
||||
return matcher.InstructionEnumeration();
|
||||
@@ -221,7 +228,6 @@ public class PatchSave
|
||||
{
|
||||
if (UseCompressSave)
|
||||
{
|
||||
SaveUtil.Logger.LogDebug("Begin compress save");
|
||||
WriteHeader(fileStream);
|
||||
_compressionStream = _compressionTypeForSaving switch
|
||||
{
|
||||
@@ -283,11 +289,11 @@ public class PatchSave
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameSave), "LoadCurrentGame")]
|
||||
[HarmonyPatch(typeof(GameSave), "LoadGameDesc")]
|
||||
[HarmonyPatch(typeof(GameSave), "ReadHeader")]
|
||||
[HarmonyPatch(typeof(GameSave), "ReadHeaderAndDescAndProperty")]
|
||||
[HarmonyPatch(typeof(GameSave), "ReadModes")]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadCurrentGame))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadGameDesc))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeader))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeaderAndDescAndProperty))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadModes))]
|
||||
private static IEnumerable<CodeInstruction> LoadCurrentGame_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
/* using (BinaryReader binaryReader = new BinaryReader(fileStream)) => Create decompressionStream and replace binaryReader.
|
||||
@@ -302,27 +308,27 @@ public class PatchSave
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryReader), [typeof(FileStream)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "CreateBinaryReader")
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(CreateBinaryReader))
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(PerformanceMonitor), "BeginStream"))
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(PerformanceMonitor), nameof(PerformanceMonitor.BeginStream)))
|
||||
);
|
||||
|
||||
if (matcher.IsValid)
|
||||
matcher.Set(OpCodes.Call, AccessTools.Method(typeof(PatchSave), "MonitorStream"));
|
||||
matcher.Set(OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(MonitorStream)));
|
||||
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryReader), "ReadInt64"))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryReader), nameof(BinaryReader.ReadInt64)))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "FileLengthRead")
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(FileLengthRead))
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(IDisposable), "Dispose"))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(IDisposable), nameof(IDisposable.Dispose)))
|
||||
).Advance(1).Insert(
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PatchSave), "DisposeCompressionStream"))
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(DisposeCompressionStream)))
|
||||
).MatchBack(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Stream), "Seek"))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Stream), nameof(Stream.Seek)))
|
||||
);
|
||||
if (matcher.IsValid)
|
||||
matcher.Set(OpCodes.Call, AccessTools.Method(typeof(PatchSave), "ReadSeek"));
|
||||
matcher.Set(OpCodes.Call, AccessTools.Method(typeof(PatchSave), nameof(ReadSeek)));
|
||||
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<AssemblyName>CompressSave</AssemblyName>
|
||||
<BepInExPluginGuid>org.soardev.compresssave</BepInExPluginGuid>
|
||||
<Description>DSP MOD - CompressSave</Description>
|
||||
<Version>1.3.7</Version>
|
||||
<Version>1.3.8</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
@@ -14,9 +14,9 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<!--<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />-->
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" /> -->
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
@@ -27,6 +27,15 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -9,7 +9,7 @@ class PatchUILoadGame
|
||||
{
|
||||
static UIButton _decompressButton;
|
||||
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), "OnSelectedChange"), HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.OnSelectedChange)), HarmonyPostfix]
|
||||
private static void OnSelectedChange(UILoadGameWindow __instance)
|
||||
{
|
||||
var selected = __instance.selected;
|
||||
@@ -26,7 +26,7 @@ class PatchUILoadGame
|
||||
_decompressButton.gameObject.SetActive(compressedType != CompressionType.None);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), "_OnOpen"), HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow._OnOpen)), HarmonyPostfix]
|
||||
static void _OnOpen(UILoadGameWindow __instance)
|
||||
{
|
||||
if (_decompressButton) return;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using CompressSave.UI;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -18,7 +19,7 @@ static class PatchUISaveGame
|
||||
_OnDestroy();
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "OnSelectedChange"), HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.OnSelectedChange)), HarmonyPostfix]
|
||||
private static void OnSelectedChange(UISaveGameWindow __instance)
|
||||
{
|
||||
var selected = __instance.selected;
|
||||
@@ -32,17 +33,17 @@ static class PatchUISaveGame
|
||||
};
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "_OnDestroy"), HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow._OnDestroy)), HarmonyPostfix]
|
||||
private static void _OnDestroy()
|
||||
{
|
||||
//Console.WriteLine("OnCreate");
|
||||
_context = new UIContext();
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "OnSaveClick"), HarmonyReversePatch]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.OnSaveClick)), HarmonyReversePatch]
|
||||
private static void OSaveGameAs(this UISaveGameWindow ui, int data) { }
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "CheckAndSetSaveButtonEnable"), HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.CheckAndSetSaveButtonEnable)), HarmonyPostfix]
|
||||
private static void CheckAndSetSaveButtonEnable(UISaveGameWindow __instance)
|
||||
{
|
||||
_OnOpen(__instance);
|
||||
@@ -61,37 +62,43 @@ static class PatchUISaveGame
|
||||
public UISaveGameWindow Window;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "OnSaveClick"), HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.OnSaveClick)), HarmonyPrefix]
|
||||
private static void OnSaveClick()
|
||||
{
|
||||
PatchSave.UseCompressSave = true;
|
||||
PatchSave.UseCommonSaveCompressionType();
|
||||
}
|
||||
|
||||
private static UIContext _context = new();
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "_OnOpen"), HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow._OnOpen)), HarmonyPostfix]
|
||||
private static void _OnOpen(UISaveGameWindow __instance)
|
||||
{
|
||||
if (_context.ButtonCompress) return;
|
||||
if (_context.ButtonCompress)
|
||||
{
|
||||
var dist = __instance.cancelButton.transform.localPosition.x - __instance.saveButton.transform.localPosition.x - ((RectTransform)__instance.cancelButton.transform).sizeDelta.x;
|
||||
var cRectTrans = (RectTransform)_context.ButtonCompress.transform;
|
||||
var localPos = __instance.saveButton.transform.localPosition;
|
||||
cRectTrans.localPosition = new Vector3(localPos.x - dist - ((RectTransform)__instance.saveButton.transform).sizeDelta.x, localPos.y, localPos.z);
|
||||
return;
|
||||
}
|
||||
RectTransform rtrans;
|
||||
Vector3 pos;
|
||||
_context.SaveButton = __instance.saveButton;
|
||||
_context.SaveButtonText = __instance.saveButtonText;
|
||||
_context.Window = __instance;
|
||||
var gameObj = __instance.transform.Find("button-compress")?.gameObject;
|
||||
var created = false;
|
||||
var isCreating = false;
|
||||
var theParent = __instance.saveButton.transform.parent;
|
||||
if (gameObj == null)
|
||||
{
|
||||
gameObj = Object.Instantiate(__instance.saveButton.gameObject, __instance.saveButton.transform.parent);
|
||||
created = true;
|
||||
gameObj = Object.Instantiate(__instance.saveButton.gameObject, theParent);
|
||||
isCreating = true;
|
||||
}
|
||||
_context.ButtonCompress = gameObj.GetComponent<UIButton>();
|
||||
if (created)
|
||||
if (isCreating)
|
||||
{
|
||||
_context.ButtonCompress.gameObject.name = "button-compress";
|
||||
rtrans = (RectTransform)_context.ButtonCompress.transform;
|
||||
pos = rtrans.anchoredPosition3D;
|
||||
rtrans.anchoredPosition3D = new Vector3(pos.x - 180, pos.y, pos.z);
|
||||
_context.ButtonCompress.button.image.color = new Color32(0xfc, 0x6f, 00, 0x77);
|
||||
var textTrans = _context.ButtonCompress.transform.Find("button-text");
|
||||
_context.ButtonCompressText = textTrans.GetComponent<Text>();
|
||||
@@ -106,126 +113,89 @@ static class PatchUISaveGame
|
||||
localizer.translation = "Save with Compression".Translate();
|
||||
}
|
||||
}
|
||||
var distance = __instance.cancelButton.transform.localPosition.x - __instance.saveButton.transform.localPosition.x - ((RectTransform)__instance.cancelButton.transform).sizeDelta.x;
|
||||
rtrans = (RectTransform)_context.ButtonCompress.transform;
|
||||
pos = __instance.saveButton.transform.localPosition;
|
||||
rtrans.localPosition = new Vector3(pos.x - distance - ((RectTransform)__instance.saveButton.transform).sizeDelta.x, pos.y, pos.z);
|
||||
|
||||
created = false;
|
||||
isCreating = false;
|
||||
gameObj = __instance.transform.Find("manual-save-type-combobox")?.gameObject;
|
||||
if (gameObj == null)
|
||||
{
|
||||
gameObj = Object.Instantiate(UIRoot.instance.optionWindow.resolutionComp.transform.parent.gameObject, __instance.saveButton.transform.parent);
|
||||
created = true;
|
||||
gameObj = UI.MyComboBox.CreateComboBox("manual-save-type-combobox");
|
||||
isCreating = true;
|
||||
}
|
||||
_context.ManualSaveTypeComboBox = gameObj;
|
||||
if (created)
|
||||
|
||||
if (isCreating)
|
||||
{
|
||||
gameObj.name = "manual-save-type-combobox";
|
||||
var btnCompressTrans = (RectTransform)_context.ButtonCompress.transform;
|
||||
var text = AddText("Compression for manual saves", 14, "manual-save-type-combobox-text");
|
||||
rtrans = text.rectTransform;
|
||||
rtrans.SetParent(theParent, false);
|
||||
pos = btnCompressTrans.localPosition;
|
||||
rtrans.anchorMin = btnCompressTrans.anchorMin;
|
||||
rtrans.anchorMax = btnCompressTrans.anchorMax;
|
||||
rtrans.pivot = btnCompressTrans.pivot;
|
||||
rtrans.localPosition = new Vector3(pos.x - 250f, pos.y + 45f, pos.z);
|
||||
|
||||
rtrans = (RectTransform)gameObj.transform;
|
||||
var rtrans2 = (RectTransform)_context.ButtonCompress.transform;
|
||||
pos = rtrans2.anchoredPosition3D;
|
||||
rtrans.anchorMin = rtrans2.anchorMin;
|
||||
rtrans.anchorMax = rtrans2.anchorMax;
|
||||
rtrans.pivot = rtrans2.pivot;
|
||||
rtrans.anchoredPosition3D = new Vector3(pos.x + 100, pos.y + 45, pos.z);
|
||||
var cbctrl = rtrans.transform.Find("ComboBox");
|
||||
var content = cbctrl.Find("Dropdown List ScrollBox")?.Find("Mask")?.Find("Content Panel");
|
||||
if (content != null)
|
||||
rtrans.SetParent(theParent, false);
|
||||
rtrans.anchorMin = btnCompressTrans.anchorMin;
|
||||
rtrans.anchorMax = btnCompressTrans.anchorMax;
|
||||
rtrans.pivot = btnCompressTrans.pivot;
|
||||
text.UpdateGeometry();
|
||||
rtrans.localPosition = new Vector3(pos.x - 50f, pos.y + 45f, pos.z);
|
||||
var cb = rtrans.GetComponent<MyComboBox>();
|
||||
cb.WithItems("Store".Translate(), "LZ4", "Zstd").WithIndex((int)PatchSave.CompressionTypeForSaves).WithOnSelChanged((idx) =>
|
||||
{
|
||||
for (var i = content.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
var theTrans = content.GetChild(i);
|
||||
if (theTrans.name == "Item Button(Clone)")
|
||||
{
|
||||
Object.Destroy(theTrans.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
var cb = cbctrl.GetComponent<UIComboBox>();
|
||||
cb.onSubmit.RemoveAllListeners();
|
||||
cb.onItemIndexChange.RemoveAllListeners();
|
||||
cb.Items = ["Store".Translate(), "LZ4", "Zstd"];
|
||||
cb.itemIndex = (int)PatchSave.CompressionTypeForSaves;
|
||||
cb.onItemIndexChange.AddListener(()=>
|
||||
{
|
||||
PatchSave.CompressionTypeForSaves = (CompressionType)cb.itemIndex;
|
||||
PatchSave.CompressionTypeForSaves = (CompressionType)idx;
|
||||
PatchSave.CompressionTypeForSavesConfig.Value = CompressSave.StringFromCompresstionType(PatchSave.CompressionTypeForSaves);
|
||||
});
|
||||
rtrans = (RectTransform)cb.transform;
|
||||
pos = rtrans.anchoredPosition3D;
|
||||
rtrans.anchoredPosition3D = new Vector3(pos.x - 50, pos.y, pos.z);
|
||||
var size = rtrans.sizeDelta;
|
||||
rtrans.sizeDelta = new Vector2(150f, size.y);
|
||||
var txt = gameObj.GetComponent<Text>();
|
||||
txt.text = "Compression for manual saves".Translate();
|
||||
var localizer = gameObj.GetComponent<Localizer>();
|
||||
if (localizer != null)
|
||||
{
|
||||
localizer.stringKey = "Compression for manual saves";
|
||||
localizer.translation = "Compression for manual saves".Translate();
|
||||
}
|
||||
}
|
||||
|
||||
created = false;
|
||||
isCreating = false;
|
||||
gameObj = __instance.transform.Find("auto-save-type-combobox")?.gameObject;
|
||||
if (gameObj == null)
|
||||
{
|
||||
gameObj = Object.Instantiate(UIRoot.instance.optionWindow.resolutionComp.transform.parent.gameObject, __instance.saveButton.transform.parent);
|
||||
created = true;
|
||||
gameObj = UI.MyComboBox.CreateComboBox("auto-save-type-combobox");
|
||||
isCreating = true;
|
||||
}
|
||||
_context.AutoSaveTypeComboBox = gameObj;
|
||||
if (created)
|
||||
if (isCreating)
|
||||
{
|
||||
gameObj.name = "auto-save-type-combobox";
|
||||
var btnCompressTrans = (RectTransform)_context.ButtonCompress.transform;
|
||||
|
||||
var text = AddText("Compression for auto saves", 14, "auto-save-type-combobox-text");
|
||||
rtrans = text.rectTransform;
|
||||
rtrans.SetParent(theParent, false);
|
||||
pos = btnCompressTrans.localPosition;
|
||||
rtrans.anchorMin = btnCompressTrans.anchorMin;
|
||||
rtrans.anchorMax = btnCompressTrans.anchorMax;
|
||||
rtrans.pivot = btnCompressTrans.pivot;
|
||||
rtrans.localPosition = new Vector3(pos.x + 160f, pos.y + 45f, pos.z);
|
||||
|
||||
rtrans = (RectTransform)gameObj.transform;
|
||||
var rtrans2 = (RectTransform)_context.ButtonCompress.transform;
|
||||
pos = rtrans2.anchoredPosition3D;
|
||||
rtrans.anchorMin = rtrans2.anchorMin;
|
||||
rtrans.anchorMax = rtrans2.anchorMax;
|
||||
rtrans.pivot = rtrans2.pivot;
|
||||
rtrans.anchoredPosition3D = new Vector3(pos.x + 510, pos.y + 45, pos.z);
|
||||
var cbctrl = rtrans.transform.Find("ComboBox");
|
||||
var content = cbctrl.Find("Dropdown List ScrollBox")?.Find("Mask")?.Find("Content Panel");
|
||||
if (content != null)
|
||||
{
|
||||
for (var i = content.childCount - 1; i >= 0; i--)
|
||||
rtrans.SetParent(theParent, false);
|
||||
rtrans.anchorMin = btnCompressTrans.anchorMin;
|
||||
rtrans.anchorMax = btnCompressTrans.anchorMax;
|
||||
rtrans.pivot = btnCompressTrans.pivot;
|
||||
rtrans.localPosition = new Vector3(pos.x + 360f, pos.y + 45f, pos.z);
|
||||
var cb = rtrans.GetComponent<MyComboBox>();
|
||||
cb.WithItems(["已停用".Translate(), "Store".Translate(), "LZ4", "Zstd"]).WithIndex(PatchSave.EnableForAutoSaves.Value ? (int)PatchSave.CompressionTypeForAutoSaves + 1 : 0)
|
||||
.WithOnSelChanged((idx) =>
|
||||
{
|
||||
var theTrans = content.GetChild(i);
|
||||
if (theTrans.name == "Item Button(Clone)")
|
||||
if (idx == 0)
|
||||
{
|
||||
Object.Destroy(theTrans.gameObject);
|
||||
PatchSave.EnableForAutoSaves.Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
var cb = cbctrl.GetComponent<UIComboBox>();
|
||||
cb.onSubmit.RemoveAllListeners();
|
||||
cb.onItemIndexChange.RemoveAllListeners();
|
||||
cb.Items = ["已停用".Translate(), "Store".Translate(), "LZ4", "Zstd"];
|
||||
cb.itemIndex = PatchSave.EnableForAutoSaves.Value ? (int)PatchSave.CompressionTypeForAutoSaves + 1 : 0;
|
||||
cb.onItemIndexChange.AddListener(() =>
|
||||
{
|
||||
var idx = cb.itemIndex;
|
||||
if (idx == 0)
|
||||
{
|
||||
PatchSave.EnableForAutoSaves.Value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PatchSave.EnableForAutoSaves.Value = true;
|
||||
PatchSave.CompressionTypeForAutoSaves = (CompressionType)idx - 1;
|
||||
PatchSave.CompressionTypeForAutoSavesConfig.Value = CompressSave.StringFromCompresstionType(PatchSave.CompressionTypeForAutoSaves);
|
||||
}
|
||||
});
|
||||
rtrans = (RectTransform)cb.transform;
|
||||
pos = rtrans.anchoredPosition3D;
|
||||
rtrans.anchoredPosition3D = new Vector3(pos.x - 50, pos.y, pos.z);
|
||||
var size = rtrans.sizeDelta;
|
||||
rtrans.sizeDelta = new Vector2(150f, size.y);
|
||||
var txt = gameObj.GetComponent<Text>();
|
||||
txt.text = "Compression for auto saves".Translate();
|
||||
var localizer = gameObj.GetComponent<Localizer>();
|
||||
if (localizer != null)
|
||||
{
|
||||
localizer.stringKey = "Compression for auto saves";
|
||||
localizer.translation = "Compression for auto saves".Translate();
|
||||
}
|
||||
else
|
||||
{
|
||||
PatchSave.EnableForAutoSaves.Value = true;
|
||||
PatchSave.CompressionTypeForAutoSaves = (CompressionType)idx - 1;
|
||||
PatchSave.CompressionTypeForAutoSavesConfig.Value = CompressSave.StringFromCompresstionType(PatchSave.CompressionTypeForAutoSaves);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,4 +204,16 @@ static class PatchUISaveGame
|
||||
PatchSave.UseCompressSave = false;
|
||||
_context.Window.OSaveGameAs(data);
|
||||
}
|
||||
|
||||
public static Text AddText(string label, int fontSize = 14, string objName = "label")
|
||||
{
|
||||
var txt = Object.Instantiate(UIRoot.instance.uiGame.assemblerWindow.stateText);
|
||||
txt.gameObject.name = objName;
|
||||
txt.text = label.Translate();
|
||||
txt.color = new Color(1f, 1f, 1f, 0.4f);
|
||||
txt.alignment = TextAnchor.MiddleLeft;
|
||||
txt.fontSize = fontSize;
|
||||
txt.rectTransform.sizeDelta = new Vector2(txt.preferredWidth + 8f, txt.preferredHeight + 8f);
|
||||
return txt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public static class SaveUtil
|
||||
{
|
||||
Major = 0,
|
||||
Minor = 10,
|
||||
Release = 28,
|
||||
Release = 34,
|
||||
};
|
||||
|
||||
private static string UnzipToFile(DecompressionStream lzStream, string fullPath)
|
||||
@@ -24,7 +24,7 @@ public static class SaveUtil
|
||||
fullPath = filename + GameSave.saveExt;
|
||||
if (dir != null) fullPath = Path.Combine(dir, fullPath);
|
||||
var i = 0;
|
||||
while(File.Exists(fullPath))
|
||||
while (File.Exists(fullPath))
|
||||
{
|
||||
fullPath = $"{filename}[{i++}]{GameSave.saveExt}";
|
||||
if (dir != null) fullPath = Path.Combine(dir, fullPath);
|
||||
|
||||
156
CompressSave/UI/MyComboBox.cs
Normal file
156
CompressSave/UI/MyComboBox.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace CompressSave.UI;
|
||||
|
||||
public class MyComboBox : MonoBehaviour
|
||||
{
|
||||
private RectTransform _rectTrans;
|
||||
private UIComboBox _comboBox;
|
||||
public Action<int> OnSelChanged;
|
||||
|
||||
private static GameObject _baseObject;
|
||||
|
||||
public static void InitBaseObject()
|
||||
{
|
||||
if (_baseObject) return;
|
||||
var fontSource = UIRoot.instance.uiGame.buildMenu.uxFacilityCheck.transform.Find("text")?.GetComponent<Text>();
|
||||
var go = Instantiate(UIRoot.instance.optionWindow.resolutionComp.gameObject);
|
||||
go.name = "my-combobox";
|
||||
go.SetActive(false);
|
||||
|
||||
var rect = (RectTransform)go.transform;
|
||||
var cbctrl = rect.GetComponent<UIComboBox>();
|
||||
foreach (var button in cbctrl.ItemButtons)
|
||||
{
|
||||
Destroy(button.gameObject);
|
||||
}
|
||||
cbctrl.Items.Clear();
|
||||
cbctrl.ItemButtons.Clear();
|
||||
if (fontSource)
|
||||
{
|
||||
var txtComp = cbctrl.m_ListItemRes.GetComponentInChildren<Text>();
|
||||
if (txtComp)
|
||||
{
|
||||
txtComp.font = fontSource.font;
|
||||
txtComp.fontSize = fontSource.fontSize;
|
||||
txtComp.fontStyle = fontSource.fontStyle;
|
||||
}
|
||||
txtComp = rect.Find("Main Button/Text")?.GetComponent<Text>();
|
||||
if (txtComp)
|
||||
{
|
||||
txtComp.font = fontSource.font;
|
||||
txtComp.fontSize = fontSource.fontSize;
|
||||
txtComp.fontStyle = fontSource.fontStyle;
|
||||
}
|
||||
}
|
||||
cbctrl.onSubmit.RemoveAllListeners();
|
||||
cbctrl.onItemIndexChange.RemoveAllListeners();
|
||||
_baseObject = go;
|
||||
}
|
||||
|
||||
public static GameObject CreateComboBox(string name)
|
||||
{
|
||||
if (_baseObject == null) InitBaseObject();
|
||||
var gameObject = Instantiate(_baseObject);
|
||||
gameObject.name = name;
|
||||
gameObject.SetActive(true);
|
||||
var cb = gameObject.AddComponent<MyComboBox>();
|
||||
cb._rectTrans = (RectTransform)gameObject.transform;
|
||||
var box = cb._rectTrans.GetComponent<UIComboBox>();
|
||||
cb._comboBox = box;
|
||||
box.onItemIndexChange.AddListener(() => { cb.OnSelChanged?.Invoke(box.itemIndex); });
|
||||
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
protected void OnDestroy()
|
||||
{
|
||||
_config.SettingChanged -= _configChanged;
|
||||
}
|
||||
|
||||
public void SetFontSize(int size)
|
||||
{
|
||||
_comboBox.ItemButtons.ForEach(b => b.GetComponentInChildren<Text>().fontSize = size);
|
||||
_comboBox.m_ListItemRes.GetComponentInChildren<Text>().fontSize = size;
|
||||
var txtComp = _comboBox.transform.Find("Main Button")?.GetComponentInChildren<Text>();
|
||||
if (txtComp) txtComp.fontSize = size;
|
||||
}
|
||||
|
||||
public void SetItems(params string[] items)
|
||||
{
|
||||
_comboBox.Items = [.. items.Select(s => s.Translate())];
|
||||
_comboBox.StartItemIndex = 0;
|
||||
_comboBox.DropDownCount = Math.Min(items.Length, 8);
|
||||
}
|
||||
|
||||
public void SetIndex(int index) => _comboBox.itemIndex = index;
|
||||
|
||||
public void SetSize(float width, float height)
|
||||
{
|
||||
var rtrans = (RectTransform)_comboBox.transform;
|
||||
rtrans.sizeDelta = new Vector2(width > 0f ? width : rtrans.sizeDelta.x, height > 0f ? height : rtrans.sizeDelta.y);
|
||||
_rectTrans.sizeDelta = new Vector2(rtrans.localPosition.x + rtrans.sizeDelta.x, _rectTrans.sizeDelta.y);
|
||||
}
|
||||
|
||||
public void AddOnSelChanged(Action<int> action) => OnSelChanged += action;
|
||||
|
||||
private EventHandler _configChanged;
|
||||
private Action<int> _selChanged;
|
||||
private ConfigEntry<int> _config;
|
||||
public void SetConfigEntry(ConfigEntry<int> config)
|
||||
{
|
||||
if (_selChanged != null) OnSelChanged -= _selChanged;
|
||||
if (_configChanged != null) config.SettingChanged -= _configChanged;
|
||||
|
||||
_comboBox.itemIndex = config.Value;
|
||||
_config = config;
|
||||
_selChanged = value => config.Value = value;
|
||||
OnSelChanged += _selChanged;
|
||||
_configChanged = (_, _) => SetIndex(config.Value);
|
||||
config.SettingChanged += _configChanged;
|
||||
}
|
||||
|
||||
public MyComboBox WithFontSize(int size)
|
||||
{
|
||||
SetFontSize(size);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MyComboBox WithItems(params string[] items)
|
||||
{
|
||||
SetItems(items);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MyComboBox WithIndex(int index)
|
||||
{
|
||||
SetIndex(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MyComboBox WithSize(float width, float height)
|
||||
{
|
||||
SetSize(width, height);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MyComboBox WithOnSelChanged(params Action<int>[] action)
|
||||
{
|
||||
foreach (var act in action)
|
||||
AddOnSelChanged(act);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MyComboBox WithConfigEntry(ConfigEntry<int> config)
|
||||
{
|
||||
SetConfigEntry(config);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float Width => _rectTrans.sizeDelta.x;
|
||||
public float Height => _rectTrans.sizeDelta.y;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
|
||||
}
|
||||
|
||||
private BufferWriter(DoubleBuffer buffer , UTF8Encoding encoding, CompressionStream outStream) : base(Stream.Null, encoding)
|
||||
private BufferWriter(DoubleBuffer buffer, UTF8Encoding encoding, CompressionStream outStream) : base(Stream.Null, encoding)
|
||||
{
|
||||
_baseStream = outStream;
|
||||
_swapedBytes = 0;
|
||||
|
||||
@@ -98,13 +98,13 @@ public class CompressionStream : Stream
|
||||
{
|
||||
_doubleBuffer = new DoubleBuffer(readBuffer ?? new byte[4 * Mb], writeBuffer ?? new byte[4 * Mb], Compress);
|
||||
_outBuffer = outputBuffer ?? new byte[_wrapper.CompressBufferBound(writeBuffer?.Length ?? 4 * Mb)];
|
||||
BufferWriter = new BufferWriter(_doubleBuffer,this);
|
||||
BufferWriter = new BufferWriter(_doubleBuffer, this);
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
_doubleBuffer.SwapBuffer();
|
||||
if(_useMultiThread)
|
||||
if (_useMultiThread)
|
||||
{
|
||||
_doubleBuffer.WaitReadEnd();
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class CompressionStream : Stream
|
||||
|
||||
private void CompressAsync()
|
||||
{
|
||||
while(!_stopWorker)
|
||||
while (!_stopWorker)
|
||||
{
|
||||
Compress_Internal();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace CompressSave.Wrapper;
|
||||
|
||||
public class LZ4API: WrapperDefines
|
||||
public class LZ4API : WrapperDefines
|
||||
{
|
||||
public static readonly bool Avaliable;
|
||||
public static readonly LZ4API Instance = new();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace CompressSave.Wrapper;
|
||||
|
||||
public class NoneAPI: WrapperDefines
|
||||
public class NoneAPI : WrapperDefines
|
||||
{
|
||||
public static readonly bool Avaliable;
|
||||
public static readonly NoneAPI Instance = new();
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace CompressSave.Wrapper;
|
||||
|
||||
public class ZstdAPI: WrapperDefines
|
||||
public class ZstdAPI : WrapperDefines
|
||||
{
|
||||
public static readonly bool Avaliable;
|
||||
public static readonly ZstdAPI Instance = new();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "CompressSave",
|
||||
"version_number": "1.3.7",
|
||||
"version_number": "1.3.8",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods_TO/tree/master/CompressSave",
|
||||
"description": "Compress game saves to reduce space use and boost save speed / 压缩游戏存档以降低空间使用并提升保存速度",
|
||||
"dependencies": ["xiaoye97-BepInEx-5.4.17"]
|
||||
|
||||
@@ -5,46 +5,46 @@ using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace AssetsLoader
|
||||
{
|
||||
internal class ABEmbeddedAssetsLoad : ABLoad
|
||||
{
|
||||
public ABEmbeddedAssetsLoad(string filename, string assetsNamespace = null)
|
||||
{
|
||||
var stackTrace = new StackTrace();
|
||||
var frame = stackTrace.GetFrame(1);
|
||||
var assembly = frame.GetMethod().DeclaringType.Assembly;
|
||||
var flag = assetsNamespace == null;
|
||||
if (flag)
|
||||
{
|
||||
assetsNamespace = assembly.FullName.Split([','])[0];
|
||||
}
|
||||
LoadAssetsFromEmbedded(filename, assetsNamespace, assembly);
|
||||
}
|
||||
internal class ABEmbeddedAssetsLoad : ABLoad
|
||||
{
|
||||
public ABEmbeddedAssetsLoad(string filename, string assetsNamespace = null)
|
||||
{
|
||||
var stackTrace = new StackTrace();
|
||||
var frame = stackTrace.GetFrame(1);
|
||||
var assembly = frame.GetMethod().DeclaringType.Assembly;
|
||||
var flag = assetsNamespace == null;
|
||||
if (flag)
|
||||
{
|
||||
assetsNamespace = assembly.FullName.Split([','])[0];
|
||||
}
|
||||
LoadAssetsFromEmbedded(filename, assetsNamespace, assembly);
|
||||
}
|
||||
|
||||
private void LoadAssetsFromEmbedded(string filename, string assetsNamespace, Assembly assembly)
|
||||
{
|
||||
var text = assetsNamespace + "." + filename;
|
||||
var manifestResourceStream = assembly.GetManifestResourceStream(text);
|
||||
var flag = manifestResourceStream == null;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log(string.Concat(["在", assembly.FullName, "找不到内嵌的资源", text, ",请检查内嵌资源中是否有它:"]));
|
||||
foreach (var text2 in assembly.GetManifestResourceNames())
|
||||
{
|
||||
Debug.Log(text2);
|
||||
}
|
||||
Debug.Log("------------------------");
|
||||
}
|
||||
else
|
||||
{
|
||||
Ab = AssetBundle.LoadFromStream(manifestResourceStream);
|
||||
Init();
|
||||
}
|
||||
}
|
||||
private void LoadAssetsFromEmbedded(string filename, string assetsNamespace, Assembly assembly)
|
||||
{
|
||||
var text = assetsNamespace + "." + filename;
|
||||
var manifestResourceStream = assembly.GetManifestResourceStream(text);
|
||||
var flag = manifestResourceStream == null;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log(string.Concat(["在", assembly.FullName, "找不到内嵌的资源", text, ",请检查内嵌资源中是否有它:"]));
|
||||
foreach (var text2 in assembly.GetManifestResourceNames())
|
||||
{
|
||||
Debug.Log(text2);
|
||||
}
|
||||
Debug.Log("------------------------");
|
||||
}
|
||||
else
|
||||
{
|
||||
Ab = AssetBundle.LoadFromStream(manifestResourceStream);
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public ABEmbeddedAssetsLoad(string filename, string dllFilepath, string dllNamespace)
|
||||
{
|
||||
var assembly = Assembly.LoadFrom(dllFilepath);
|
||||
LoadAssetsFromEmbedded(filename, dllNamespace, assembly);
|
||||
}
|
||||
}
|
||||
public ABEmbeddedAssetsLoad(string filename, string dllFilepath, string dllNamespace)
|
||||
{
|
||||
var assembly = Assembly.LoadFrom(dllFilepath);
|
||||
LoadAssetsFromEmbedded(filename, dllNamespace, assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace AssetsLoader
|
||||
{
|
||||
internal class ABFileLoad : ABLoad
|
||||
{
|
||||
public ABFileLoad(string filepath)
|
||||
{
|
||||
Ab = AssetBundle.LoadFromFile(filepath);
|
||||
Init();
|
||||
}
|
||||
}
|
||||
internal class ABFileLoad : ABLoad
|
||||
{
|
||||
public ABFileLoad(string filepath)
|
||||
{
|
||||
Ab = AssetBundle.LoadFromFile(filepath);
|
||||
Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,77 +4,77 @@ using UnityEngine;
|
||||
|
||||
namespace AssetsLoader
|
||||
{
|
||||
public abstract class ABLoad : ILoad
|
||||
{
|
||||
protected void Init()
|
||||
{
|
||||
foreach (var text in Ab.GetAllAssetNames())
|
||||
{
|
||||
var flag = text.Contains("prefabs");
|
||||
if (flag)
|
||||
{
|
||||
PrefabPath = text.Substring(0, text.IndexOf("prefabs", StringComparison.OrdinalIgnoreCase));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract class ABLoad : ILoad
|
||||
{
|
||||
protected void Init()
|
||||
{
|
||||
foreach (var text in Ab.GetAllAssetNames())
|
||||
{
|
||||
var flag = text.Contains("prefabs");
|
||||
if (flag)
|
||||
{
|
||||
PrefabPath = text.Substring(0, text.IndexOf("prefabs", StringComparison.OrdinalIgnoreCase));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
var flag = Ab == null;
|
||||
GameObject gameObject;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log("内嵌的AB包没有找到");
|
||||
gameObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = path.Contains("/");
|
||||
if (flag2)
|
||||
{
|
||||
path = Path.Combine(PrefabPath, path);
|
||||
var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase);
|
||||
if (flag3)
|
||||
{
|
||||
path += ".prefab";
|
||||
}
|
||||
}
|
||||
gameObject = Ab.LoadAsset<GameObject>(path);
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
var flag = Ab == null;
|
||||
GameObject gameObject;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log("内嵌的AB包没有找到");
|
||||
gameObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = path.Contains("/");
|
||||
if (flag2)
|
||||
{
|
||||
path = Path.Combine(PrefabPath, path);
|
||||
var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase);
|
||||
if (flag3)
|
||||
{
|
||||
path += ".prefab";
|
||||
}
|
||||
}
|
||||
gameObject = Ab.LoadAsset<GameObject>(path);
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
public string LoadText(string path)
|
||||
{
|
||||
var flag = Ab == null;
|
||||
string text;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log("内嵌的AB包没有找到");
|
||||
text = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = path.Contains("/");
|
||||
if (flag2)
|
||||
{
|
||||
path = Path.Combine(_txtPath, path);
|
||||
var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase);
|
||||
if (flag3)
|
||||
{
|
||||
path += ".prefab";
|
||||
}
|
||||
}
|
||||
text = Ab.LoadAsset<TextAsset>(path).text;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
public string LoadText(string path)
|
||||
{
|
||||
var flag = Ab == null;
|
||||
string text;
|
||||
if (flag)
|
||||
{
|
||||
Debug.Log("内嵌的AB包没有找到");
|
||||
text = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = path.Contains("/");
|
||||
if (flag2)
|
||||
{
|
||||
path = Path.Combine(_txtPath, path);
|
||||
var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase);
|
||||
if (flag3)
|
||||
{
|
||||
path += ".prefab";
|
||||
}
|
||||
}
|
||||
text = Ab.LoadAsset<TextAsset>(path).text;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
protected string PrefabPath;
|
||||
protected string PrefabPath;
|
||||
|
||||
protected AssetBundle Ab;
|
||||
protected AssetBundle Ab;
|
||||
|
||||
private string _txtPath;
|
||||
}
|
||||
private string _txtPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
|
||||
namespace AssetsLoader
|
||||
{
|
||||
public static class ABLoader
|
||||
{
|
||||
public static ABLoad LoadFromFile(string abFilename, string dir)
|
||||
{
|
||||
var text = Path.Combine(dir, abFilename);
|
||||
return new ABFileLoad(text);
|
||||
}
|
||||
public static class ABLoader
|
||||
{
|
||||
public static ABLoad LoadFromFile(string abFilename, string dir)
|
||||
{
|
||||
var text = Path.Combine(dir, abFilename);
|
||||
return new ABFileLoad(text);
|
||||
}
|
||||
|
||||
public static ABLoad LoadFromFile(string filepath)
|
||||
{
|
||||
return new ABFileLoad(filepath);
|
||||
}
|
||||
public static ABLoad LoadFromFile(string filepath)
|
||||
{
|
||||
return new ABFileLoad(filepath);
|
||||
}
|
||||
|
||||
public static ABLoad LoadFromEmbeddedAssets(string abFilename, string defaultNamespace = null)
|
||||
{
|
||||
return new ABEmbeddedAssetsLoad(abFilename, defaultNamespace);
|
||||
}
|
||||
public static ABLoad LoadFromEmbeddedAssets(string abFilename, string defaultNamespace = null)
|
||||
{
|
||||
return new ABEmbeddedAssetsLoad(abFilename, defaultNamespace);
|
||||
}
|
||||
|
||||
public static ABLoad LoadFromDll(string abFilename, string dllFilepath, string dllDefaultNameSpace)
|
||||
{
|
||||
return new ABEmbeddedAssetsLoad(abFilename, dllFilepath, dllDefaultNameSpace);
|
||||
}
|
||||
}
|
||||
public static ABLoad LoadFromDll(string abFilename, string dllFilepath, string dllDefaultNameSpace)
|
||||
{
|
||||
return new ABEmbeddedAssetsLoad(abFilename, dllFilepath, dllDefaultNameSpace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace AssetsLoader
|
||||
{
|
||||
public interface ILoad
|
||||
{
|
||||
GameObject LoadPrefab(string path);
|
||||
public interface ILoad
|
||||
{
|
||||
GameObject LoadPrefab(string path);
|
||||
|
||||
string LoadText(string path);
|
||||
}
|
||||
string LoadText(string path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
namespace AssetsLoader
|
||||
{
|
||||
public class ResourceLoad : ILoad
|
||||
{
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
return Resources.Load<GameObject>(path);
|
||||
}
|
||||
public class ResourceLoad : ILoad
|
||||
{
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
return Resources.Load<GameObject>(path);
|
||||
}
|
||||
|
||||
public string LoadText(string path)
|
||||
{
|
||||
return Resources.Load<TextAsset>(path).text;
|
||||
}
|
||||
}
|
||||
public string LoadText(string path)
|
||||
{
|
||||
return Resources.Load<TextAsset>(path).text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,153 +4,153 @@ using UnityEngine;
|
||||
|
||||
namespace XianTu
|
||||
{
|
||||
public class BlueTuUIData
|
||||
{
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
public event Action OnValueChange;
|
||||
public class BlueTuUIData
|
||||
{
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
public event Action OnValueChange;
|
||||
|
||||
public static BlueTuUIData Instance { get; } = new();
|
||||
public static BlueTuUIData Instance { get; } = new();
|
||||
|
||||
public Vector3 Bias
|
||||
{
|
||||
get => _bias;
|
||||
public Vector3 Bias
|
||||
{
|
||||
get => _bias;
|
||||
set
|
||||
{
|
||||
_bias = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_bias = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Scale
|
||||
{
|
||||
get => _scale;
|
||||
public Vector3 Scale
|
||||
{
|
||||
get => _scale;
|
||||
set
|
||||
{
|
||||
_scale = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_scale = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Pivot
|
||||
{
|
||||
get => _pivot;
|
||||
public Vector3 Pivot
|
||||
{
|
||||
get => _pivot;
|
||||
set
|
||||
{
|
||||
_pivot = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_pivot = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float LayerHeight
|
||||
{
|
||||
get => _layerHeight;
|
||||
public float LayerHeight
|
||||
{
|
||||
get => _layerHeight;
|
||||
set
|
||||
{
|
||||
_layerHeight = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_layerHeight = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float Rotate
|
||||
{
|
||||
get => _rotate;
|
||||
public float Rotate
|
||||
{
|
||||
get => _rotate;
|
||||
set
|
||||
{
|
||||
_rotate = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_rotate = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int LayerNumber
|
||||
{
|
||||
get => _layerNumber;
|
||||
public int LayerNumber
|
||||
{
|
||||
get => _layerNumber;
|
||||
set
|
||||
{
|
||||
var flag = LayerNumber < 1;
|
||||
if (!flag)
|
||||
{
|
||||
_layerNumber = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
var flag = LayerNumber < 1;
|
||||
if (!flag)
|
||||
{
|
||||
_layerNumber = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enable
|
||||
{
|
||||
get => _enable;
|
||||
public bool Enable
|
||||
{
|
||||
get => _enable;
|
||||
set
|
||||
{
|
||||
_enable = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_enable = value;
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlueTuUIData Clone()
|
||||
{
|
||||
var blueTuUIData = (BlueTuUIData)MemberwiseClone();
|
||||
blueTuUIData.OnValueChange = null;
|
||||
return blueTuUIData;
|
||||
}
|
||||
public BlueTuUIData Clone()
|
||||
{
|
||||
var blueTuUIData = (BlueTuUIData)MemberwiseClone();
|
||||
blueTuUIData.OnValueChange = null;
|
||||
return blueTuUIData;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
var blueTuUIData = new BlueTuUIData();
|
||||
_bias = blueTuUIData._bias;
|
||||
_scale = blueTuUIData._scale;
|
||||
_pivot = blueTuUIData._pivot;
|
||||
_layerHeight = blueTuUIData._layerHeight;
|
||||
_layerNumber = blueTuUIData._layerNumber;
|
||||
_rotate = blueTuUIData._rotate;
|
||||
_enable = true;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
var blueTuUIData = new BlueTuUIData();
|
||||
_bias = blueTuUIData._bias;
|
||||
_scale = blueTuUIData._scale;
|
||||
_pivot = blueTuUIData._pivot;
|
||||
_layerHeight = blueTuUIData._layerHeight;
|
||||
_layerNumber = blueTuUIData._layerNumber;
|
||||
_rotate = blueTuUIData._rotate;
|
||||
_enable = true;
|
||||
}
|
||||
|
||||
|
||||
private Vector3 _bias = new(0f, 0f, 0f);
|
||||
private Vector3 _bias = new(0f, 0f, 0f);
|
||||
|
||||
private Vector3 _scale = new(1f, 1f, 1f);
|
||||
private Vector3 _scale = new(1f, 1f, 1f);
|
||||
|
||||
private Vector3 _pivot = new(0f, 0f, 0f);
|
||||
private Vector3 _pivot = new(0f, 0f, 0f);
|
||||
|
||||
private float _layerHeight = 5f;
|
||||
private float _layerHeight = 5f;
|
||||
|
||||
private int _layerNumber = 1;
|
||||
private int _layerNumber = 1;
|
||||
|
||||
private float _rotate;
|
||||
private float _rotate;
|
||||
|
||||
private bool _enable = true;
|
||||
private bool _enable = true;
|
||||
|
||||
public Action OnBuildBtn;
|
||||
public Action OnBuildBtn;
|
||||
|
||||
public Action OnResetBtn;
|
||||
public Action OnResetBtn;
|
||||
|
||||
public Action OnCopyBtn;
|
||||
}
|
||||
public Action OnCopyBtn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,36 +6,36 @@ using UnityEngine;
|
||||
|
||||
namespace XianTu
|
||||
{
|
||||
internal class EmbeddedFileLoad : ILoad
|
||||
{
|
||||
public EmbeddedFileLoad(string assetsNamespace = null)
|
||||
{
|
||||
var stackTrace = new StackTrace();
|
||||
var frame = stackTrace.GetFrame(1);
|
||||
var assembly = frame.GetMethod().DeclaringType.Assembly;
|
||||
var flag = assetsNamespace == null;
|
||||
if (flag)
|
||||
{
|
||||
assetsNamespace = assembly.FullName.Split([','])[0];
|
||||
}
|
||||
this._assetsNamespace = assetsNamespace;
|
||||
this._assembly = assembly;
|
||||
}
|
||||
internal class EmbeddedFileLoad : ILoad
|
||||
{
|
||||
public EmbeddedFileLoad(string assetsNamespace = null)
|
||||
{
|
||||
var stackTrace = new StackTrace();
|
||||
var frame = stackTrace.GetFrame(1);
|
||||
var assembly = frame.GetMethod().DeclaringType.Assembly;
|
||||
var flag = assetsNamespace == null;
|
||||
if (flag)
|
||||
{
|
||||
assetsNamespace = assembly.FullName.Split([','])[0];
|
||||
}
|
||||
this._assetsNamespace = assetsNamespace;
|
||||
this._assembly = assembly;
|
||||
}
|
||||
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string LoadText(string path)
|
||||
{
|
||||
public string LoadText(string path)
|
||||
{
|
||||
using var manifestResourceStream = _assembly.GetManifestResourceStream(_assetsNamespace + "." + path.Replace('/', '.'));
|
||||
using var streamReader = new StreamReader(manifestResourceStream);
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string _assetsNamespace;
|
||||
private readonly string _assetsNamespace;
|
||||
|
||||
private readonly Assembly _assembly;
|
||||
}
|
||||
private readonly Assembly _assembly;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,19 @@ using UnityEngine;
|
||||
|
||||
namespace XianTu
|
||||
{
|
||||
internal class FileLoad(string dirPath) : ILoad
|
||||
internal class FileLoad(string dirPath) : ILoad
|
||||
{
|
||||
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public GameObject LoadPrefab(string path)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string LoadText(string path)
|
||||
{
|
||||
return File.ReadAllText(Path.Combine(_dirPath, path));
|
||||
}
|
||||
public string LoadText(string path)
|
||||
{
|
||||
return File.ReadAllText(Path.Combine(_dirPath, path));
|
||||
}
|
||||
|
||||
private readonly string _dirPath = dirPath ?? "";
|
||||
}
|
||||
private readonly string _dirPath = dirPath ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,376 +5,376 @@ using XianTu.UI;
|
||||
|
||||
namespace XianTu.Scripts.DataController
|
||||
{
|
||||
internal class BlueTuController
|
||||
{
|
||||
public BlueTuController()
|
||||
{
|
||||
_oldData = BlueTuUIData.Instance.Clone();
|
||||
_data = BlueTuUIData.Instance;
|
||||
Init_OnUIOpen();
|
||||
_data.OnValueChange += OnUserChangeData;
|
||||
var blueTuUIData = _data;
|
||||
blueTuUIData.OnBuildBtn = (Action)Delegate.Combine(blueTuUIData.OnBuildBtn, new Action(OnUserBuildDetermine));
|
||||
var blueTuUIData2 = _data;
|
||||
blueTuUIData2.OnCopyBtn = (Action)Delegate.Combine(blueTuUIData2.OnCopyBtn, new Action(OnUserCopy));
|
||||
var blueTuUIData3 = _data;
|
||||
blueTuUIData3.OnResetBtn = (Action)Delegate.Combine(blueTuUIData3.OnResetBtn, new Action(OnReset));
|
||||
var blueprintData = BlueTuDatabase.Load("FoundationBlueTu");
|
||||
_foundation = blueprintData.buildings[0];
|
||||
}
|
||||
internal class BlueTuController
|
||||
{
|
||||
public BlueTuController()
|
||||
{
|
||||
_oldData = BlueTuUIData.Instance.Clone();
|
||||
_data = BlueTuUIData.Instance;
|
||||
Init_OnUIOpen();
|
||||
_data.OnValueChange += OnUserChangeData;
|
||||
var blueTuUIData = _data;
|
||||
blueTuUIData.OnBuildBtn = (Action)Delegate.Combine(blueTuUIData.OnBuildBtn, new Action(OnUserBuildDetermine));
|
||||
var blueTuUIData2 = _data;
|
||||
blueTuUIData2.OnCopyBtn = (Action)Delegate.Combine(blueTuUIData2.OnCopyBtn, new Action(OnUserCopy));
|
||||
var blueTuUIData3 = _data;
|
||||
blueTuUIData3.OnResetBtn = (Action)Delegate.Combine(blueTuUIData3.OnResetBtn, new Action(OnReset));
|
||||
var blueprintData = BlueTuDatabase.Load("FoundationBlueTu");
|
||||
_foundation = blueprintData.buildings[0];
|
||||
}
|
||||
|
||||
private void OnUserCopy()
|
||||
{
|
||||
_actionBuild.blueprintClipboard = _bPaste.blueprint;
|
||||
ResetBuildDuiDie();
|
||||
_bPaste.RefreshBlueprintUI();
|
||||
}
|
||||
private void OnUserCopy()
|
||||
{
|
||||
_actionBuild.blueprintClipboard = _bPaste.blueprint;
|
||||
ResetBuildDuiDie();
|
||||
_bPaste.RefreshBlueprintUI();
|
||||
}
|
||||
|
||||
private void Init_OnUIOpen()
|
||||
{
|
||||
UIManager.Instance.CanvasMonoEvent.onEnableEvent.AddListener(OnReset);
|
||||
}
|
||||
private void Init_OnUIOpen()
|
||||
{
|
||||
UIManager.Instance.CanvasMonoEvent.onEnableEvent.AddListener(OnReset);
|
||||
}
|
||||
|
||||
private void OnReset()
|
||||
{
|
||||
Player = GameMain.mainPlayer;
|
||||
var flag = Player == null;
|
||||
if (flag)
|
||||
{
|
||||
_data.Enable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerController = Player.controller;
|
||||
_actionBuild = PlayerController.actionBuild;
|
||||
var flag2 = _actionBuild != null;
|
||||
if (flag2)
|
||||
{
|
||||
_activeTool = _actionBuild.activeTool;
|
||||
var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste;
|
||||
var flag3 = buildToolBlueprintPaste != null;
|
||||
if (flag3)
|
||||
{
|
||||
_bPaste = buildToolBlueprintPaste;
|
||||
var mouseRay = _actionBuild.activeTool.mouseRay;
|
||||
_defaultMouseRay = new Ray(mouseRay.origin, mouseRay.direction);
|
||||
var flag4 = buildToolBlueprintPaste.blueprint != _blueprint;
|
||||
if (flag4)
|
||||
{
|
||||
_templateBlueTu = buildToolBlueprintPaste.blueprint.Clone();
|
||||
_blueprint = buildToolBlueprintPaste.blueprint;
|
||||
}
|
||||
_oldData = new BlueTuUIData();
|
||||
_data.Reset();
|
||||
_data.Enable = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_data.Enable = false;
|
||||
}
|
||||
}
|
||||
private void OnReset()
|
||||
{
|
||||
Player = GameMain.mainPlayer;
|
||||
var flag = Player == null;
|
||||
if (flag)
|
||||
{
|
||||
_data.Enable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerController = Player.controller;
|
||||
_actionBuild = PlayerController.actionBuild;
|
||||
var flag2 = _actionBuild != null;
|
||||
if (flag2)
|
||||
{
|
||||
_activeTool = _actionBuild.activeTool;
|
||||
var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste;
|
||||
var flag3 = buildToolBlueprintPaste != null;
|
||||
if (flag3)
|
||||
{
|
||||
_bPaste = buildToolBlueprintPaste;
|
||||
var mouseRay = _actionBuild.activeTool.mouseRay;
|
||||
_defaultMouseRay = new Ray(mouseRay.origin, mouseRay.direction);
|
||||
var flag4 = buildToolBlueprintPaste.blueprint != _blueprint;
|
||||
if (flag4)
|
||||
{
|
||||
_templateBlueTu = buildToolBlueprintPaste.blueprint.Clone();
|
||||
_blueprint = buildToolBlueprintPaste.blueprint;
|
||||
}
|
||||
_oldData = new BlueTuUIData();
|
||||
_data.Reset();
|
||||
_data.Enable = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_data.Enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
private Player Player { get; set; }
|
||||
|
||||
private void OnUserBuildDetermine()
|
||||
{
|
||||
var flag = _actionBuild.activeTool != null;
|
||||
if (flag)
|
||||
{
|
||||
var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste;
|
||||
var flag2 = buildToolBlueprintPaste != null;
|
||||
if (flag2)
|
||||
{
|
||||
var flag3 = buildToolBlueprintPaste.CheckBuildConditionsPrestage();
|
||||
if (flag3)
|
||||
{
|
||||
ResetBuildDuiDie();
|
||||
Build(buildToolBlueprintPaste);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnUserBuildDetermine()
|
||||
{
|
||||
var flag = _actionBuild.activeTool != null;
|
||||
if (flag)
|
||||
{
|
||||
var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste;
|
||||
var flag2 = buildToolBlueprintPaste != null;
|
||||
if (flag2)
|
||||
{
|
||||
var flag3 = buildToolBlueprintPaste.CheckBuildConditionsPrestage();
|
||||
if (flag3)
|
||||
{
|
||||
ResetBuildDuiDie();
|
||||
Build(buildToolBlueprintPaste);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetBuildDuiDie()
|
||||
{
|
||||
var buildToolBlueprintPaste = _bPaste;
|
||||
BlueprintBuilding blueprintBuilding = null;
|
||||
foreach (var blueprintBuilding2 in buildToolBlueprintPaste.blueprint.buildings)
|
||||
{
|
||||
var flag = Math.Abs(blueprintBuilding2.localOffset_z) < 1.5f;
|
||||
if (flag)
|
||||
{
|
||||
var itemProto = LDB.items.Select(blueprintBuilding2.itemId);
|
||||
Debug.Log($"基底查验:{itemProto.name}.{itemProto.ID}:{blueprintBuilding2.localOffset_x:2f}, {blueprintBuilding2.localOffset_y:2f}, {blueprintBuilding2.localOffset_z:2f}");
|
||||
blueprintBuilding = blueprintBuilding2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var flag2 = blueprintBuilding == null;
|
||||
if (flag2)
|
||||
{
|
||||
Debug.Log("没有基底");
|
||||
}
|
||||
var flag3 = blueprintBuilding == null;
|
||||
if (flag3)
|
||||
{
|
||||
var buildings2 = _bPaste.blueprint.buildings;
|
||||
var array = new BlueprintBuilding[_bPaste.blueprint.buildings.Length + 1];
|
||||
_bPaste.blueprint.buildings = array;
|
||||
buildings2.CopyTo(array, 0);
|
||||
blueprintBuilding = _foundation;
|
||||
blueprintBuilding.index = buildings2.Length;
|
||||
blueprintBuilding.localOffset_z = -0.5f;
|
||||
array[buildings2.Length] = blueprintBuilding;
|
||||
}
|
||||
foreach (var blueprintBuilding3 in _bPaste.blueprint.buildings)
|
||||
{
|
||||
var flag4 = blueprintBuilding3.IsBelt();
|
||||
if (!flag4)
|
||||
{
|
||||
var flag5 = blueprintBuilding3.IsSlot();
|
||||
if (!flag5)
|
||||
{
|
||||
var flag6 = blueprintBuilding3 == blueprintBuilding;
|
||||
if (!flag6)
|
||||
{
|
||||
blueprintBuilding3.inputToSlot = 14;
|
||||
blueprintBuilding3.outputFromSlot = 15;
|
||||
blueprintBuilding3.inputFromSlot = 15;
|
||||
blueprintBuilding3.outputToSlot = 14;
|
||||
blueprintBuilding3.inputObj = blueprintBuilding;
|
||||
blueprintBuilding3.inputFromSlot = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_bPaste.bpCursor = _bPaste.blueprint.buildings.Length;
|
||||
_bPaste.buildPreviews.Clear();
|
||||
_bPaste.ResetStates();
|
||||
_BuildTool_BluePrint_OnTick();
|
||||
}
|
||||
private void ResetBuildDuiDie()
|
||||
{
|
||||
var buildToolBlueprintPaste = _bPaste;
|
||||
BlueprintBuilding blueprintBuilding = null;
|
||||
foreach (var blueprintBuilding2 in buildToolBlueprintPaste.blueprint.buildings)
|
||||
{
|
||||
var flag = Math.Abs(blueprintBuilding2.localOffset_z) < 1.5f;
|
||||
if (flag)
|
||||
{
|
||||
var itemProto = LDB.items.Select(blueprintBuilding2.itemId);
|
||||
Debug.Log($"基底查验:{itemProto.name}.{itemProto.ID}:{blueprintBuilding2.localOffset_x:2f}, {blueprintBuilding2.localOffset_y:2f}, {blueprintBuilding2.localOffset_z:2f}");
|
||||
blueprintBuilding = blueprintBuilding2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var flag2 = blueprintBuilding == null;
|
||||
if (flag2)
|
||||
{
|
||||
Debug.Log("没有基底");
|
||||
}
|
||||
var flag3 = blueprintBuilding == null;
|
||||
if (flag3)
|
||||
{
|
||||
var buildings2 = _bPaste.blueprint.buildings;
|
||||
var array = new BlueprintBuilding[_bPaste.blueprint.buildings.Length + 1];
|
||||
_bPaste.blueprint.buildings = array;
|
||||
buildings2.CopyTo(array, 0);
|
||||
blueprintBuilding = _foundation;
|
||||
blueprintBuilding.index = buildings2.Length;
|
||||
blueprintBuilding.localOffset_z = -0.5f;
|
||||
array[buildings2.Length] = blueprintBuilding;
|
||||
}
|
||||
foreach (var blueprintBuilding3 in _bPaste.blueprint.buildings)
|
||||
{
|
||||
var flag4 = blueprintBuilding3.IsBelt();
|
||||
if (!flag4)
|
||||
{
|
||||
var flag5 = blueprintBuilding3.IsSlot();
|
||||
if (!flag5)
|
||||
{
|
||||
var flag6 = blueprintBuilding3 == blueprintBuilding;
|
||||
if (!flag6)
|
||||
{
|
||||
blueprintBuilding3.inputToSlot = 14;
|
||||
blueprintBuilding3.outputFromSlot = 15;
|
||||
blueprintBuilding3.inputFromSlot = 15;
|
||||
blueprintBuilding3.outputToSlot = 14;
|
||||
blueprintBuilding3.inputObj = blueprintBuilding;
|
||||
blueprintBuilding3.inputFromSlot = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_bPaste.bpCursor = _bPaste.blueprint.buildings.Length;
|
||||
_bPaste.buildPreviews.Clear();
|
||||
_bPaste.ResetStates();
|
||||
_BuildTool_BluePrint_OnTick();
|
||||
}
|
||||
|
||||
private void Build(BuildTool_BlueprintPaste bp)
|
||||
{
|
||||
if (bp.CheckBuildConditionsPrestage())
|
||||
{
|
||||
PlayerController.cmd.stage = 1;
|
||||
bp.GenerateBlueprintGratBoxes();
|
||||
bp.DeterminePreviewsPrestage(true, false);
|
||||
bp.ActiveColliders(_actionBuild.model);
|
||||
var buildCondition = bp.CheckBuildConditions();
|
||||
bp.DeterminePreviews();
|
||||
bp.result = (buildCondition ? (bp.result & ~EBlueprintPasteResult.HasError) : (bp.result | EBlueprintPasteResult.HasError));
|
||||
bp.DeactiveColliders(_actionBuild.model);
|
||||
bp.CalculateReformData();
|
||||
if (buildCondition && bp.quickPaste && (bp.result & EBlueprintPasteResult.HasReform) == EBlueprintPasteResult.None)
|
||||
{
|
||||
bp.CreatePrebuilds();
|
||||
bp.ResetStates();
|
||||
}
|
||||
}
|
||||
bp.isDragging = false;
|
||||
bp.startGroundPosSnapped = bp.castGroundPosSnapped;
|
||||
bp.ErrorGridClustering();
|
||||
_BuildTool_BluePrint_OnTick();
|
||||
}
|
||||
private void Build(BuildTool_BlueprintPaste bp)
|
||||
{
|
||||
if (bp.CheckBuildConditionsPrestage())
|
||||
{
|
||||
PlayerController.cmd.stage = 1;
|
||||
bp.GenerateBlueprintGratBoxes();
|
||||
bp.DeterminePreviewsPrestage(true, false);
|
||||
bp.ActiveColliders(_actionBuild.model);
|
||||
var buildCondition = bp.CheckBuildConditions();
|
||||
bp.DeterminePreviews();
|
||||
bp.result = (buildCondition ? (bp.result & ~EBlueprintPasteResult.HasError) : (bp.result | EBlueprintPasteResult.HasError));
|
||||
bp.DeactiveColliders(_actionBuild.model);
|
||||
bp.CalculateReformData();
|
||||
if (buildCondition && bp.quickPaste && (bp.result & EBlueprintPasteResult.HasReform) == EBlueprintPasteResult.None)
|
||||
{
|
||||
bp.CreatePrebuilds();
|
||||
bp.ResetStates();
|
||||
}
|
||||
}
|
||||
bp.isDragging = false;
|
||||
bp.startGroundPosSnapped = bp.castGroundPosSnapped;
|
||||
bp.ErrorGridClustering();
|
||||
_BuildTool_BluePrint_OnTick();
|
||||
}
|
||||
|
||||
private void OnUserChangeData()
|
||||
{
|
||||
var flag = !_data.Enable;
|
||||
if (!flag)
|
||||
{
|
||||
var flag2 = PlayerController == null;
|
||||
if (!flag2)
|
||||
{
|
||||
var flag3 = _actionBuild == null;
|
||||
if (!flag3)
|
||||
{
|
||||
var flag4 = _bPaste == null;
|
||||
if (!flag4)
|
||||
{
|
||||
var vector = _data.Bias - _oldData.Bias;
|
||||
private void OnUserChangeData()
|
||||
{
|
||||
var flag = !_data.Enable;
|
||||
if (!flag)
|
||||
{
|
||||
var flag2 = PlayerController == null;
|
||||
if (!flag2)
|
||||
{
|
||||
var flag3 = _actionBuild == null;
|
||||
if (!flag3)
|
||||
{
|
||||
var flag4 = _bPaste == null;
|
||||
if (!flag4)
|
||||
{
|
||||
var vector = _data.Bias - _oldData.Bias;
|
||||
var num = _data.LayerHeight - _oldData.LayerHeight;
|
||||
var num2 = _data.LayerNumber - _oldData.LayerNumber;
|
||||
var num3 = _data.Rotate - _oldData.Rotate;
|
||||
var flag5 = _actionBuild != null;
|
||||
if (flag5)
|
||||
{
|
||||
CtrlLayerNumber(num2);
|
||||
CtrlLayerHeight(num);
|
||||
CtrlRotate(num3);
|
||||
CtrlBiasData(vector);
|
||||
CtrlScale();
|
||||
_BuildTool_BluePrint_OnTick();
|
||||
}
|
||||
_oldData.Scale = _data.Scale;
|
||||
_oldData.Pivot = _data.Pivot;
|
||||
_oldData.LayerHeight = _data.LayerHeight;
|
||||
_oldData.LayerNumber = _data.LayerNumber;
|
||||
_oldData.Rotate = _data.Rotate;
|
||||
_oldData.Bias = _data.Bias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var num2 = _data.LayerNumber - _oldData.LayerNumber;
|
||||
var num3 = _data.Rotate - _oldData.Rotate;
|
||||
var flag5 = _actionBuild != null;
|
||||
if (flag5)
|
||||
{
|
||||
CtrlLayerNumber(num2);
|
||||
CtrlLayerHeight(num);
|
||||
CtrlRotate(num3);
|
||||
CtrlBiasData(vector);
|
||||
CtrlScale();
|
||||
_BuildTool_BluePrint_OnTick();
|
||||
}
|
||||
_oldData.Scale = _data.Scale;
|
||||
_oldData.Pivot = _data.Pivot;
|
||||
_oldData.LayerHeight = _data.LayerHeight;
|
||||
_oldData.LayerNumber = _data.LayerNumber;
|
||||
_oldData.Rotate = _data.Rotate;
|
||||
_oldData.Bias = _data.Bias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CtrlLayerNumber(int bLayerNumber)
|
||||
{
|
||||
var flag = bLayerNumber == 0;
|
||||
if (!flag)
|
||||
{
|
||||
var num = _data.LayerNumber * _templateBlueTu.buildings.Length;
|
||||
var buildings = _bPaste.blueprint.buildings;
|
||||
var array = new BlueprintBuilding[num];
|
||||
var flag2 = buildings.Length > num;
|
||||
if (flag2)
|
||||
{
|
||||
Array.Copy(buildings, array, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
buildings.CopyTo(array, 0);
|
||||
var num2 = _templateBlueTu.buildings.Length;
|
||||
for (var i = _bPaste.bpCursor; i < array.Length; i += num2)
|
||||
{
|
||||
_templateBlueTu.Clone().buildings.CopyTo(array, i);
|
||||
}
|
||||
for (var j = _bPaste.bpCursor; j < array.Length; j++)
|
||||
{
|
||||
array[j].localOffset_z = array[j - num2].localOffset_z + _data.LayerHeight;
|
||||
array[j].localOffset_z2 = array[j - num2].localOffset_z2 + _data.LayerHeight;
|
||||
}
|
||||
for (var k = _bPaste.bpCursor; k < array.Length; k++)
|
||||
{
|
||||
array[k].index = k;
|
||||
}
|
||||
}
|
||||
_bPaste.blueprint.buildings = array;
|
||||
_bPaste.bpCursor = _bPaste.blueprint.buildings.Length;
|
||||
_bPaste.buildPreviews.Clear();
|
||||
_bPaste.ResetStates();
|
||||
}
|
||||
}
|
||||
private void CtrlLayerNumber(int bLayerNumber)
|
||||
{
|
||||
var flag = bLayerNumber == 0;
|
||||
if (!flag)
|
||||
{
|
||||
var num = _data.LayerNumber * _templateBlueTu.buildings.Length;
|
||||
var buildings = _bPaste.blueprint.buildings;
|
||||
var array = new BlueprintBuilding[num];
|
||||
var flag2 = buildings.Length > num;
|
||||
if (flag2)
|
||||
{
|
||||
Array.Copy(buildings, array, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
buildings.CopyTo(array, 0);
|
||||
var num2 = _templateBlueTu.buildings.Length;
|
||||
for (var i = _bPaste.bpCursor; i < array.Length; i += num2)
|
||||
{
|
||||
_templateBlueTu.Clone().buildings.CopyTo(array, i);
|
||||
}
|
||||
for (var j = _bPaste.bpCursor; j < array.Length; j++)
|
||||
{
|
||||
array[j].localOffset_z = array[j - num2].localOffset_z + _data.LayerHeight;
|
||||
array[j].localOffset_z2 = array[j - num2].localOffset_z2 + _data.LayerHeight;
|
||||
}
|
||||
for (var k = _bPaste.bpCursor; k < array.Length; k++)
|
||||
{
|
||||
array[k].index = k;
|
||||
}
|
||||
}
|
||||
_bPaste.blueprint.buildings = array;
|
||||
_bPaste.bpCursor = _bPaste.blueprint.buildings.Length;
|
||||
_bPaste.buildPreviews.Clear();
|
||||
_bPaste.ResetStates();
|
||||
}
|
||||
}
|
||||
|
||||
private void CtrlLayerHeight(float bLayerHeight)
|
||||
{
|
||||
var flag = bLayerHeight == 0f;
|
||||
if (!flag)
|
||||
{
|
||||
var num = _templateBlueTu.buildings.Length;
|
||||
var num2 = 0;
|
||||
var buildings = _bPaste.blueprint.buildings;
|
||||
for (var i = 0; i < _bPaste.bpCursor; i++)
|
||||
{
|
||||
var flag2 = i == num * (num2 + 1);
|
||||
if (flag2)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
buildings[i].localOffset_z += bLayerHeight * num2;
|
||||
buildings[i].localOffset_z2 += bLayerHeight * num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CtrlLayerHeight(float bLayerHeight)
|
||||
{
|
||||
var flag = bLayerHeight == 0f;
|
||||
if (!flag)
|
||||
{
|
||||
var num = _templateBlueTu.buildings.Length;
|
||||
var num2 = 0;
|
||||
var buildings = _bPaste.blueprint.buildings;
|
||||
for (var i = 0; i < _bPaste.bpCursor; i++)
|
||||
{
|
||||
var flag2 = i == num * (num2 + 1);
|
||||
if (flag2)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
buildings[i].localOffset_z += bLayerHeight * num2;
|
||||
buildings[i].localOffset_z2 += bLayerHeight * num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CtrlScale()
|
||||
{
|
||||
var flag = _oldData.Scale == _data.Scale;
|
||||
if (!flag)
|
||||
{
|
||||
var buildings = _templateBlueTu.buildings;
|
||||
var vector = _data.Scale - _oldData.Scale;
|
||||
var pivot = _data.Pivot;
|
||||
var num = 0;
|
||||
for (var i = 0; i < _bPaste.bpCursor; i++)
|
||||
{
|
||||
var flag2 = num == buildings.Length;
|
||||
if (flag2)
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
var blueprintBuilding = buildings[num];
|
||||
var blueprintBuilding2 = _bPaste.blueprint.buildings[i];
|
||||
blueprintBuilding2.localOffset_x += (blueprintBuilding.localOffset_x - pivot.x) * vector.x + pivot.x;
|
||||
blueprintBuilding2.localOffset_y += (blueprintBuilding.localOffset_y - pivot.y) * vector.y + pivot.y;
|
||||
blueprintBuilding2.localOffset_z += blueprintBuilding.localOffset_z * vector.z;
|
||||
blueprintBuilding2.localOffset_x2 += (blueprintBuilding.localOffset_x2 - pivot.x) * vector.x + pivot.x;
|
||||
blueprintBuilding2.localOffset_y2 += (blueprintBuilding.localOffset_y2 - pivot.y) * vector.y + pivot.y;
|
||||
blueprintBuilding2.localOffset_z2 += blueprintBuilding.localOffset_z2 * vector.z;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CtrlScale()
|
||||
{
|
||||
var flag = _oldData.Scale == _data.Scale;
|
||||
if (!flag)
|
||||
{
|
||||
var buildings = _templateBlueTu.buildings;
|
||||
var vector = _data.Scale - _oldData.Scale;
|
||||
var pivot = _data.Pivot;
|
||||
var num = 0;
|
||||
for (var i = 0; i < _bPaste.bpCursor; i++)
|
||||
{
|
||||
var flag2 = num == buildings.Length;
|
||||
if (flag2)
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
var blueprintBuilding = buildings[num];
|
||||
var blueprintBuilding2 = _bPaste.blueprint.buildings[i];
|
||||
blueprintBuilding2.localOffset_x += (blueprintBuilding.localOffset_x - pivot.x) * vector.x + pivot.x;
|
||||
blueprintBuilding2.localOffset_y += (blueprintBuilding.localOffset_y - pivot.y) * vector.y + pivot.y;
|
||||
blueprintBuilding2.localOffset_z += blueprintBuilding.localOffset_z * vector.z;
|
||||
blueprintBuilding2.localOffset_x2 += (blueprintBuilding.localOffset_x2 - pivot.x) * vector.x + pivot.x;
|
||||
blueprintBuilding2.localOffset_y2 += (blueprintBuilding.localOffset_y2 - pivot.y) * vector.y + pivot.y;
|
||||
blueprintBuilding2.localOffset_z2 += blueprintBuilding.localOffset_z2 * vector.z;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CtrlRotate(float bRotate)
|
||||
{
|
||||
var flag = Math.Abs(bRotate) < 0.001f;
|
||||
if (!flag)
|
||||
{
|
||||
var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste;
|
||||
var flag2 = buildToolBlueprintPaste != null;
|
||||
if (flag2)
|
||||
{
|
||||
var pivot = _data.Pivot;
|
||||
var buildings = buildToolBlueprintPaste.blueprint.buildings;
|
||||
var quaternion = Quaternion.AngleAxis(bRotate, Vector3.forward);
|
||||
for (var i = 0; i < _bPaste.bpCursor; i++)
|
||||
{
|
||||
var blueprintBuilding = buildings[i];
|
||||
var vector = new Vector3(blueprintBuilding.localOffset_x - pivot.x, blueprintBuilding.localOffset_y - pivot.y, 0f);
|
||||
vector = quaternion * vector;
|
||||
blueprintBuilding.localOffset_x = vector.x + pivot.x;
|
||||
blueprintBuilding.localOffset_y = vector.y + pivot.y;
|
||||
blueprintBuilding.yaw -= bRotate;
|
||||
private void CtrlRotate(float bRotate)
|
||||
{
|
||||
var flag = Math.Abs(bRotate) < 0.001f;
|
||||
if (!flag)
|
||||
{
|
||||
var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste;
|
||||
var flag2 = buildToolBlueprintPaste != null;
|
||||
if (flag2)
|
||||
{
|
||||
var pivot = _data.Pivot;
|
||||
var buildings = buildToolBlueprintPaste.blueprint.buildings;
|
||||
var quaternion = Quaternion.AngleAxis(bRotate, Vector3.forward);
|
||||
for (var i = 0; i < _bPaste.bpCursor; i++)
|
||||
{
|
||||
var blueprintBuilding = buildings[i];
|
||||
var vector = new Vector3(blueprintBuilding.localOffset_x - pivot.x, blueprintBuilding.localOffset_y - pivot.y, 0f);
|
||||
vector = quaternion * vector;
|
||||
blueprintBuilding.localOffset_x = vector.x + pivot.x;
|
||||
blueprintBuilding.localOffset_y = vector.y + pivot.y;
|
||||
blueprintBuilding.yaw -= bRotate;
|
||||
vector = new Vector3(blueprintBuilding.localOffset_x2 - pivot.x, blueprintBuilding.localOffset_y2 - pivot.y, 0f);
|
||||
vector = quaternion * vector;
|
||||
blueprintBuilding.localOffset_x2 = vector.x + pivot.x;
|
||||
blueprintBuilding.localOffset_y2 = vector.y + pivot.y;
|
||||
blueprintBuilding.yaw2 -= bRotate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vector = quaternion * vector;
|
||||
blueprintBuilding.localOffset_x2 = vector.x + pivot.x;
|
||||
blueprintBuilding.localOffset_y2 = vector.y + pivot.y;
|
||||
blueprintBuilding.yaw2 -= bRotate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerController PlayerController => _playerController;
|
||||
|
||||
private void CtrlBiasData(Vector3 bBias)
|
||||
{
|
||||
var flag = bBias == Vector3.zero;
|
||||
if (!flag)
|
||||
{
|
||||
var playerActionBuild = _actionBuild;
|
||||
var buildTool = playerActionBuild.activeTool;
|
||||
var buildToolBlueprintPaste = buildTool as BuildTool_BlueprintPaste;
|
||||
var flag2 = buildToolBlueprintPaste != null;
|
||||
if (flag2)
|
||||
{
|
||||
for (var i = 0; i < buildToolBlueprintPaste.bpCursor; i++)
|
||||
{
|
||||
var blueprintBuilding = buildToolBlueprintPaste.blueprint.buildings[i];
|
||||
blueprintBuilding.localOffset_x += bBias.x;
|
||||
blueprintBuilding.localOffset_x2 += bBias.x;
|
||||
blueprintBuilding.localOffset_y += bBias.y;
|
||||
blueprintBuilding.localOffset_y2 += bBias.y;
|
||||
blueprintBuilding.localOffset_z += bBias.z;
|
||||
blueprintBuilding.localOffset_z2 += bBias.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CtrlBiasData(Vector3 bBias)
|
||||
{
|
||||
var flag = bBias == Vector3.zero;
|
||||
if (!flag)
|
||||
{
|
||||
var playerActionBuild = _actionBuild;
|
||||
var buildTool = playerActionBuild.activeTool;
|
||||
var buildToolBlueprintPaste = buildTool as BuildTool_BlueprintPaste;
|
||||
var flag2 = buildToolBlueprintPaste != null;
|
||||
if (flag2)
|
||||
{
|
||||
for (var i = 0; i < buildToolBlueprintPaste.bpCursor; i++)
|
||||
{
|
||||
var blueprintBuilding = buildToolBlueprintPaste.blueprint.buildings[i];
|
||||
blueprintBuilding.localOffset_x += bBias.x;
|
||||
blueprintBuilding.localOffset_x2 += bBias.x;
|
||||
blueprintBuilding.localOffset_y += bBias.y;
|
||||
blueprintBuilding.localOffset_y2 += bBias.y;
|
||||
blueprintBuilding.localOffset_z += bBias.z;
|
||||
blueprintBuilding.localOffset_z2 += bBias.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _BuildTool_BluePrint_OnTick()
|
||||
{
|
||||
VFInput.onGUI = false;
|
||||
_bPaste.mouseRay = _defaultMouseRay;
|
||||
var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste;
|
||||
var flag = buildToolBlueprintPaste != null;
|
||||
if (flag)
|
||||
{
|
||||
buildToolBlueprintPaste.ClearErrorMessage();
|
||||
buildToolBlueprintPaste.UpdateRaycast();
|
||||
buildToolBlueprintPaste.CheckBuildConditionsPrestage();
|
||||
private void _BuildTool_BluePrint_OnTick()
|
||||
{
|
||||
VFInput.onGUI = false;
|
||||
_bPaste.mouseRay = _defaultMouseRay;
|
||||
var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste;
|
||||
var flag = buildToolBlueprintPaste != null;
|
||||
if (flag)
|
||||
{
|
||||
buildToolBlueprintPaste.ClearErrorMessage();
|
||||
buildToolBlueprintPaste.UpdateRaycast();
|
||||
buildToolBlueprintPaste.CheckBuildConditionsPrestage();
|
||||
switch (PlayerController.cmd.stage)
|
||||
{
|
||||
case 0:
|
||||
@@ -385,28 +385,28 @@ namespace XianTu.Scripts.DataController
|
||||
break;
|
||||
}
|
||||
buildToolBlueprintPaste.UpdatePreviewModels(_actionBuild.model);
|
||||
buildToolBlueprintPaste.ErrorGridClustering();
|
||||
}
|
||||
}
|
||||
buildToolBlueprintPaste.TranslateErrorType(false);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly BlueTuUIData _data;
|
||||
private readonly BlueTuUIData _data;
|
||||
|
||||
private BlueTuUIData _oldData;
|
||||
private BlueTuUIData _oldData;
|
||||
|
||||
private PlayerController _playerController;
|
||||
private PlayerController _playerController;
|
||||
|
||||
private Ray _defaultMouseRay;
|
||||
private Ray _defaultMouseRay;
|
||||
|
||||
private BlueprintData _templateBlueTu;
|
||||
private BlueprintData _templateBlueTu;
|
||||
|
||||
private PlayerAction_Build _actionBuild;
|
||||
private PlayerAction_Build _actionBuild;
|
||||
|
||||
private BuildTool _activeTool;
|
||||
private BuildTool _activeTool;
|
||||
|
||||
private BuildTool_BlueprintPaste _bPaste;
|
||||
private BuildTool_BlueprintPaste _bPaste;
|
||||
|
||||
private readonly BlueprintBuilding _foundation;
|
||||
private readonly BlueprintBuilding _foundation;
|
||||
|
||||
private BlueprintData _blueprint;
|
||||
}
|
||||
private BlueprintData _blueprint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,34 +2,34 @@
|
||||
|
||||
namespace XianTu.Scripts.DataController
|
||||
{
|
||||
internal static class BlueTuDatabase
|
||||
{
|
||||
public static BlueprintData Load(string path)
|
||||
{
|
||||
var flag = !path.EndsWith(".txt");
|
||||
if (flag)
|
||||
{
|
||||
path += ".txt";
|
||||
}
|
||||
var text = Singleton<LoadManager>.Instance.LoadText(path);
|
||||
var flag2 = text == "";
|
||||
BlueprintData blueprintData;
|
||||
if (flag2)
|
||||
{
|
||||
Debug.Log("没有找到蓝图文件");
|
||||
blueprintData = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var blueprintData2 = BlueprintData.CreateNew(text);
|
||||
var flag3 = blueprintData2 == null;
|
||||
if (flag3)
|
||||
{
|
||||
Debug.Log("蓝图文件加载失败");
|
||||
}
|
||||
blueprintData = blueprintData2;
|
||||
}
|
||||
return blueprintData;
|
||||
}
|
||||
}
|
||||
internal static class BlueTuDatabase
|
||||
{
|
||||
public static BlueprintData Load(string path)
|
||||
{
|
||||
var flag = !path.EndsWith(".txt");
|
||||
if (flag)
|
||||
{
|
||||
path += ".txt";
|
||||
}
|
||||
var text = Singleton<LoadManager>.Instance.LoadText(path);
|
||||
var flag2 = text == "";
|
||||
BlueprintData blueprintData;
|
||||
if (flag2)
|
||||
{
|
||||
Debug.Log("没有找到蓝图文件");
|
||||
blueprintData = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var blueprintData2 = BlueprintData.CreateNew(text);
|
||||
var flag3 = blueprintData2 == null;
|
||||
if (flag3)
|
||||
{
|
||||
Debug.Log("蓝图文件加载失败");
|
||||
}
|
||||
blueprintData = blueprintData2;
|
||||
}
|
||||
return blueprintData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,19 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace ToolScripts
|
||||
{
|
||||
internal static class EventTriggerExpand
|
||||
{
|
||||
public static void Add(this EventTrigger trigger, EventTriggerType eventID, UnityAction<BaseEventData> callback)
|
||||
{
|
||||
var flag = trigger.triggers == null;
|
||||
if (flag)
|
||||
{
|
||||
trigger.triggers = [];
|
||||
}
|
||||
var entry = new EventTrigger.Entry();
|
||||
entry.eventID = eventID;
|
||||
entry.callback.AddListener(callback);
|
||||
trigger.triggers.Add(entry);
|
||||
}
|
||||
}
|
||||
internal static class EventTriggerExpand
|
||||
{
|
||||
public static void Add(this EventTrigger trigger, EventTriggerType eventID, UnityAction<BaseEventData> callback)
|
||||
{
|
||||
var flag = trigger.triggers == null;
|
||||
if (flag)
|
||||
{
|
||||
trigger.triggers = [];
|
||||
}
|
||||
var entry = new EventTrigger.Entry();
|
||||
entry.eventID = eventID;
|
||||
entry.callback.AddListener(callback);
|
||||
trigger.triggers.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,74 +2,74 @@
|
||||
|
||||
namespace ToolScripts
|
||||
{
|
||||
public static class GameObjectExpand
|
||||
{
|
||||
public static T Find<T>(this GameObject obj, string name) where T : class
|
||||
{
|
||||
var gameObject = GameObject.Find(name);
|
||||
bool flag = gameObject;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = gameObject.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
public static class GameObjectExpand
|
||||
{
|
||||
public static T Find<T>(this GameObject obj, string name) where T : class
|
||||
{
|
||||
var gameObject = GameObject.Find(name);
|
||||
bool flag = gameObject;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = gameObject.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static T Find<T>(this Transform obj, string name) where T : class
|
||||
{
|
||||
var transform = obj.Find(name);
|
||||
bool flag = transform;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = transform.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
public static T Find<T>(this Transform obj, string name) where T : class
|
||||
{
|
||||
var transform = obj.Find(name);
|
||||
bool flag = transform;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = transform.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static bool TryFind<T>(this GameObject obj, string name, out T result) where T : class
|
||||
{
|
||||
var gameObject = GameObject.Find(name);
|
||||
bool flag = gameObject;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
result = gameObject.GetComponent<T>();
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default(T);
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
public static bool TryFind<T>(this GameObject obj, string name, out T result) where T : class
|
||||
{
|
||||
var gameObject = GameObject.Find(name);
|
||||
bool flag = gameObject;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
result = gameObject.GetComponent<T>();
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default(T);
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
public static bool TryFind<T>(this Transform obj, string name, out T result) where T : class
|
||||
{
|
||||
var transform = obj.Find(name);
|
||||
bool flag = transform;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
result = transform.GetComponent<T>();
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default(T);
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
}
|
||||
public static bool TryFind<T>(this Transform obj, string name, out T result) where T : class
|
||||
{
|
||||
var transform = obj.Find(name);
|
||||
bool flag = transform;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
result = transform.GetComponent<T>();
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default(T);
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,31 +2,31 @@
|
||||
|
||||
namespace ToolScripts
|
||||
{
|
||||
public static class _BlueprintBuildingExpands
|
||||
{
|
||||
static _BlueprintBuildingExpands()
|
||||
{
|
||||
BeltProtoDict.Add(2001, null);
|
||||
BeltProtoDict.Add(2002, null);
|
||||
BeltProtoDict.Add(2003, null);
|
||||
SoltProtoDict.Add(2011, null);
|
||||
SoltProtoDict.Add(2012, null);
|
||||
SoltProtoDict.Add(2013, null);
|
||||
public static class _BlueprintBuildingExpands
|
||||
{
|
||||
static _BlueprintBuildingExpands()
|
||||
{
|
||||
BeltProtoDict.Add(2001, null);
|
||||
BeltProtoDict.Add(2002, null);
|
||||
BeltProtoDict.Add(2003, null);
|
||||
SoltProtoDict.Add(2011, null);
|
||||
SoltProtoDict.Add(2012, null);
|
||||
SoltProtoDict.Add(2013, null);
|
||||
SoltProtoDict.Add(2014, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBelt(this BlueprintBuilding bb)
|
||||
{
|
||||
return BeltProtoDict.ContainsKey(bb.itemId);
|
||||
}
|
||||
public static bool IsBelt(this BlueprintBuilding bb)
|
||||
{
|
||||
return BeltProtoDict.ContainsKey(bb.itemId);
|
||||
}
|
||||
|
||||
public static bool IsSlot(this BlueprintBuilding bb)
|
||||
{
|
||||
return SoltProtoDict.ContainsKey(bb.itemId);
|
||||
}
|
||||
public static bool IsSlot(this BlueprintBuilding bb)
|
||||
{
|
||||
return SoltProtoDict.ContainsKey(bb.itemId);
|
||||
}
|
||||
|
||||
private static readonly Dictionary<int, ItemProto> BeltProtoDict = new();
|
||||
|
||||
private static readonly Dictionary<int, ItemProto> SoltProtoDict = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,39 +2,39 @@
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
internal class BasePanel : MonoBehaviour
|
||||
{
|
||||
public virtual void OnEnter()
|
||||
{
|
||||
}
|
||||
internal class BasePanel : MonoBehaviour
|
||||
{
|
||||
public virtual void OnEnter()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnPause()
|
||||
{
|
||||
UITool.GameObject.SetActive(false);
|
||||
}
|
||||
public virtual void OnPause()
|
||||
{
|
||||
UITool.GameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public virtual void OnResume()
|
||||
{
|
||||
UITool.GameObject.SetActive(true);
|
||||
}
|
||||
public virtual void OnResume()
|
||||
{
|
||||
UITool.GameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public virtual void OnExit()
|
||||
{
|
||||
Destroy(UITool.GameObject);
|
||||
}
|
||||
public virtual void OnExit()
|
||||
{
|
||||
Destroy(UITool.GameObject);
|
||||
}
|
||||
|
||||
public void Init(PanelManager panelManager)
|
||||
{
|
||||
PanelManager = panelManager;
|
||||
}
|
||||
public void Init(PanelManager panelManager)
|
||||
{
|
||||
PanelManager = panelManager;
|
||||
}
|
||||
|
||||
public PanelManager PanelManager { get; private set; }
|
||||
public PanelManager PanelManager { get; private set; }
|
||||
|
||||
public void Init(UITool uiTool)
|
||||
{
|
||||
UITool = uiTool;
|
||||
}
|
||||
public void Init(UITool uiTool)
|
||||
{
|
||||
UITool = uiTool;
|
||||
}
|
||||
|
||||
public UITool UITool { get; private set; }
|
||||
}
|
||||
public UITool UITool { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,339 +6,339 @@ using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
internal class BlueTuPatchUI : XianTuBasePanel
|
||||
{
|
||||
public BlueTuUIData Data { get; private set; }
|
||||
internal class BlueTuPatchUI : XianTuBasePanel
|
||||
{
|
||||
public BlueTuUIData Data { get; private set; }
|
||||
|
||||
public static BlueTuPatchUI Instance { get; private set; }
|
||||
public static BlueTuPatchUI Instance { get; private set; }
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
Data = BlueTuUIData.Instance;
|
||||
enableToggle = UITool.GetComponentInChild<Toggle>("XianTuEnableTg");
|
||||
enableToggle.isOn = Data.Enable;
|
||||
enableToggle.onValueChanged.AddListener(delegate(bool value)
|
||||
{
|
||||
Data.Enable = value;
|
||||
});
|
||||
_tipText = UITool.GetComponentInChild<Button>("Tx_Tip");
|
||||
_buildButton = UITool.GetComponentInChild<Button>("Btn_Build");
|
||||
_buildButton.onClick.AddListener(delegate
|
||||
{
|
||||
var onBuildBtn = Data.OnBuildBtn;
|
||||
if (onBuildBtn != null)
|
||||
{
|
||||
onBuildBtn();
|
||||
}
|
||||
});
|
||||
_resetButton = UITool.GetComponentInChild<Button>("Btn_Reset");
|
||||
_resetButton.onClick.AddListener(delegate
|
||||
{
|
||||
var onResetBtn = Data.OnResetBtn;
|
||||
if (onResetBtn != null)
|
||||
{
|
||||
onResetBtn();
|
||||
}
|
||||
ResetValue();
|
||||
});
|
||||
_copyButton = UITool.GetComponentInChild<Button>("Btn_Copy");
|
||||
_copyButton.onClick.AddListener(delegate
|
||||
{
|
||||
var onCopyBtn = Data.OnCopyBtn;
|
||||
if (onCopyBtn != null)
|
||||
{
|
||||
onCopyBtn();
|
||||
}
|
||||
});
|
||||
LayerNumber = CreateUIValue(Data.LayerNumber, "LayerNumber");
|
||||
LayerHeight = CreateUIValue(Data.LayerHeight, "LayerHeight", 20f);
|
||||
var text = "ScaleGroup/Group/ScaleX";
|
||||
var text2 = "ScaleGroup/Group/ScaleY";
|
||||
ScaleX = CreateUIValue(Data.Scale.x, text);
|
||||
ScaleY = CreateUIValue(Data.Scale.y, text2);
|
||||
var text3 = "ScaleGroup/Group/ScaleZ";
|
||||
ScaleZ = CreateUIValue(Data.Scale.z, text3);
|
||||
var text4 = "BiasGroup/Group/BiasX";
|
||||
var text5 = "BiasGroup/Group/BiasY";
|
||||
var text6 = "BiasGroup/Group/BiasZ";
|
||||
_biasX = CreateUIValue(Data.Bias.x, text4, 20f);
|
||||
_biasY = CreateUIValue(Data.Bias.y, text5, 20f);
|
||||
BiasZ = CreateUIValue(Data.Bias.z, text6, 20f);
|
||||
Rotate = CreateUIValue(Data.Rotate, "Rotate", 180f);
|
||||
_pivotX = CreateUIValue(Data.Pivot.x, "PivotX");
|
||||
_pivotY = CreateUIValue(Data.Pivot.y, "PivotY");
|
||||
AddDragControl(Rotate, "Name");
|
||||
AddDragControl(LayerNumber, "Name");
|
||||
AddDragControl(LayerHeight, "Name");
|
||||
AddDragControl(ScaleX, "Name");
|
||||
AddDragControl(ScaleY, "Name");
|
||||
AddDragControl(ScaleZ, "Name");
|
||||
AddDragControl(_pivotX, _pivotY, "Name");
|
||||
AddDragControl(_biasX, "Name");
|
||||
AddDragControl(_biasY, "Name");
|
||||
AddDragControl(BiasZ, "Name");
|
||||
BindScaleData();
|
||||
BindBiasData();
|
||||
BindPivot();
|
||||
BindLayerNumber();
|
||||
BindLayerHeight();
|
||||
BindRotate();
|
||||
Instance = this;
|
||||
var initFinish = InitFinish;
|
||||
if (initFinish != null)
|
||||
{
|
||||
initFinish(this);
|
||||
}
|
||||
BindOnEnable_MoveCenter();
|
||||
}
|
||||
|
||||
private void ResetValue()
|
||||
{
|
||||
_biasX.Value = Data.Bias.x;
|
||||
_biasY.Value = Data.Bias.y;
|
||||
BiasZ.Value = Data.Bias.z;
|
||||
ScaleX.Value = Data.Scale.x;
|
||||
ScaleY.Value = Data.Scale.y;
|
||||
ScaleZ.Value = Data.Scale.z;
|
||||
_pivotX.Value = Data.Pivot.x;
|
||||
_pivotY.Value = Data.Pivot.y;
|
||||
Rotate.Value = Data.Rotate;
|
||||
enableToggle.isOn = Data.Enable;
|
||||
LayerHeight.Value = Data.LayerHeight;
|
||||
LayerNumber.Value = Data.LayerNumber;
|
||||
}
|
||||
|
||||
private void BindOnEnable_MoveCenter()
|
||||
{
|
||||
var canvasMonoEvent = UIManager.CanvasMonoEvent;
|
||||
var rectTransform = (RectTransform)transform;
|
||||
var centerBias = new Vector3(-rectTransform.rect.width / 2f, rectTransform.rect.height / 2f);
|
||||
canvasMonoEvent.onEnableEvent.AddListener(delegate
|
||||
{
|
||||
var isOn = enableToggle.isOn;
|
||||
if (isOn)
|
||||
{
|
||||
UITool.GameObject.transform.position = Input.mousePosition + centerBias;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void BindRotate()
|
||||
{
|
||||
Rotate.OnValueChange += delegate(float f)
|
||||
{
|
||||
Data.Rotate = f;
|
||||
};
|
||||
}
|
||||
|
||||
private void BindLayerHeight()
|
||||
{
|
||||
LayerHeight.OnValueChange += delegate(float f)
|
||||
{
|
||||
Data.LayerHeight = f;
|
||||
};
|
||||
}
|
||||
|
||||
private void BindLayerNumber()
|
||||
{
|
||||
LayerNumber.OnValueChange += delegate(int i)
|
||||
{
|
||||
Data.LayerNumber = i;
|
||||
};
|
||||
}
|
||||
|
||||
private void BindPivot()
|
||||
{
|
||||
var tempPivot = Data.Pivot;
|
||||
var cd = Time.time;
|
||||
_pivotX.OnValueChange += delegate(float f)
|
||||
{
|
||||
var flag = Time.time - cd < Time.fixedDeltaTime;
|
||||
if (!flag)
|
||||
{
|
||||
cd = Time.time;
|
||||
tempPivot.x = f;
|
||||
Data.Pivot = tempPivot;
|
||||
}
|
||||
};
|
||||
_pivotY.OnValueChange += delegate(float f)
|
||||
{
|
||||
var flag2 = Time.time - cd < Time.fixedDeltaTime;
|
||||
if (!flag2)
|
||||
{
|
||||
cd = Time.time;
|
||||
tempPivot.y = f;
|
||||
Data.Pivot = tempPivot;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void BindBiasData()
|
||||
{
|
||||
var tempBias = Data.Bias;
|
||||
_biasX.OnValueChange += delegate(float f)
|
||||
{
|
||||
tempBias.x = f;
|
||||
Data.Bias = tempBias;
|
||||
};
|
||||
_biasY.OnValueChange += delegate(float f)
|
||||
{
|
||||
tempBias.y = f;
|
||||
Data.Bias = tempBias;
|
||||
};
|
||||
BiasZ.OnValueChange += delegate(float f)
|
||||
{
|
||||
tempBias.z = f;
|
||||
Data.Bias = tempBias;
|
||||
};
|
||||
}
|
||||
|
||||
private void BindScaleData()
|
||||
{
|
||||
var tempScale = Data.Scale;
|
||||
ScaleX.OnValueChange += delegate(float f)
|
||||
{
|
||||
tempScale.x = f;
|
||||
Data.Scale = tempScale;
|
||||
};
|
||||
ScaleY.OnValueChange += delegate(float f)
|
||||
{
|
||||
tempScale.y = f;
|
||||
Data.Scale = tempScale;
|
||||
};
|
||||
ScaleZ.OnValueChange += delegate(float f)
|
||||
{
|
||||
tempScale.z = f;
|
||||
Data.Scale = tempScale;
|
||||
};
|
||||
}
|
||||
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private static event Action<BlueTuPatchUI> InitFinish;
|
||||
|
||||
public static event Action<BlueTuPatchUI> OnInitFinish
|
||||
{
|
||||
add
|
||||
{
|
||||
InitFinish += value;
|
||||
var flag = Instance != null;
|
||||
if (flag)
|
||||
{
|
||||
value(Instance);
|
||||
}
|
||||
}
|
||||
remove => InitFinish -= value;
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
Data = BlueTuUIData.Instance;
|
||||
enableToggle = UITool.GetComponentInChild<Toggle>("XianTuEnableTg");
|
||||
enableToggle.isOn = Data.Enable;
|
||||
enableToggle.onValueChanged.AddListener(delegate (bool value)
|
||||
{
|
||||
Data.Enable = value;
|
||||
});
|
||||
_tipText = UITool.GetComponentInChild<Button>("Tx_Tip");
|
||||
_buildButton = UITool.GetComponentInChild<Button>("Btn_Build");
|
||||
_buildButton.onClick.AddListener(delegate
|
||||
{
|
||||
var onBuildBtn = Data.OnBuildBtn;
|
||||
if (onBuildBtn != null)
|
||||
{
|
||||
onBuildBtn();
|
||||
}
|
||||
});
|
||||
_resetButton = UITool.GetComponentInChild<Button>("Btn_Reset");
|
||||
_resetButton.onClick.AddListener(delegate
|
||||
{
|
||||
var onResetBtn = Data.OnResetBtn;
|
||||
if (onResetBtn != null)
|
||||
{
|
||||
onResetBtn();
|
||||
}
|
||||
ResetValue();
|
||||
});
|
||||
_copyButton = UITool.GetComponentInChild<Button>("Btn_Copy");
|
||||
_copyButton.onClick.AddListener(delegate
|
||||
{
|
||||
var onCopyBtn = Data.OnCopyBtn;
|
||||
if (onCopyBtn != null)
|
||||
{
|
||||
onCopyBtn();
|
||||
}
|
||||
});
|
||||
LayerNumber = CreateUIValue(Data.LayerNumber, "LayerNumber");
|
||||
LayerHeight = CreateUIValue(Data.LayerHeight, "LayerHeight", 20f);
|
||||
var text = "ScaleGroup/Group/ScaleX";
|
||||
var text2 = "ScaleGroup/Group/ScaleY";
|
||||
ScaleX = CreateUIValue(Data.Scale.x, text);
|
||||
ScaleY = CreateUIValue(Data.Scale.y, text2);
|
||||
var text3 = "ScaleGroup/Group/ScaleZ";
|
||||
ScaleZ = CreateUIValue(Data.Scale.z, text3);
|
||||
var text4 = "BiasGroup/Group/BiasX";
|
||||
var text5 = "BiasGroup/Group/BiasY";
|
||||
var text6 = "BiasGroup/Group/BiasZ";
|
||||
_biasX = CreateUIValue(Data.Bias.x, text4, 20f);
|
||||
_biasY = CreateUIValue(Data.Bias.y, text5, 20f);
|
||||
BiasZ = CreateUIValue(Data.Bias.z, text6, 20f);
|
||||
Rotate = CreateUIValue(Data.Rotate, "Rotate", 180f);
|
||||
_pivotX = CreateUIValue(Data.Pivot.x, "PivotX");
|
||||
_pivotY = CreateUIValue(Data.Pivot.y, "PivotY");
|
||||
AddDragControl(Rotate, "Name");
|
||||
AddDragControl(LayerNumber, "Name");
|
||||
AddDragControl(LayerHeight, "Name");
|
||||
AddDragControl(ScaleX, "Name");
|
||||
AddDragControl(ScaleY, "Name");
|
||||
AddDragControl(ScaleZ, "Name");
|
||||
AddDragControl(_pivotX, _pivotY, "Name");
|
||||
AddDragControl(_biasX, "Name");
|
||||
AddDragControl(_biasY, "Name");
|
||||
AddDragControl(BiasZ, "Name");
|
||||
BindScaleData();
|
||||
BindBiasData();
|
||||
BindPivot();
|
||||
BindLayerNumber();
|
||||
BindLayerHeight();
|
||||
BindRotate();
|
||||
Instance = this;
|
||||
var initFinish = InitFinish;
|
||||
if (initFinish != null)
|
||||
{
|
||||
initFinish(this);
|
||||
}
|
||||
BindOnEnable_MoveCenter();
|
||||
}
|
||||
|
||||
private void AddDragControl<T>(UIValue<T> uiValue, string childrenName) where T : IComparable
|
||||
{
|
||||
var flag = uiValue.Components.Length != 0;
|
||||
if (flag)
|
||||
{
|
||||
var parent = uiValue.Components[0].gameObject.transform.parent;
|
||||
var transform = parent.Find(childrenName);
|
||||
bool flag2 = transform;
|
||||
if (flag2)
|
||||
{
|
||||
uiValue.BindDragControl(transform.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ResetValue()
|
||||
{
|
||||
_biasX.Value = Data.Bias.x;
|
||||
_biasY.Value = Data.Bias.y;
|
||||
BiasZ.Value = Data.Bias.z;
|
||||
ScaleX.Value = Data.Scale.x;
|
||||
ScaleY.Value = Data.Scale.y;
|
||||
ScaleZ.Value = Data.Scale.z;
|
||||
_pivotX.Value = Data.Pivot.x;
|
||||
_pivotY.Value = Data.Pivot.y;
|
||||
Rotate.Value = Data.Rotate;
|
||||
enableToggle.isOn = Data.Enable;
|
||||
LayerHeight.Value = Data.LayerHeight;
|
||||
LayerNumber.Value = Data.LayerNumber;
|
||||
}
|
||||
|
||||
private void AddDragControl<T>(UIValue<T> uiValueX, UIValue<T> uiValueY, string childrenName) where T : IComparable
|
||||
{
|
||||
var flag = uiValueX.Components.Length != 0;
|
||||
if (flag)
|
||||
{
|
||||
var parent = uiValueX.Components[0].gameObject.transform.parent;
|
||||
var transform = parent.Find(childrenName);
|
||||
bool flag2 = transform;
|
||||
if (flag2)
|
||||
{
|
||||
uiValueX.BindDragControl(transform.gameObject);
|
||||
uiValueY.BindDragControl(transform.gameObject);
|
||||
UIValue<T>.BindDragControl(transform.gameObject, uiValueX, uiValueY);
|
||||
}
|
||||
}
|
||||
var flag3 = uiValueY.Components.Length != 0;
|
||||
if (flag3)
|
||||
{
|
||||
var parent2 = uiValueY.Components[0].gameObject.transform.parent;
|
||||
var transform2 = parent2.Find(childrenName);
|
||||
bool flag4 = transform2;
|
||||
if (flag4)
|
||||
{
|
||||
uiValueX.BindDragControl(transform2.gameObject);
|
||||
uiValueY.BindDragControl(transform2.gameObject);
|
||||
UIValue<T>.BindDragControl(transform2.gameObject, uiValueX, uiValueY);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void BindOnEnable_MoveCenter()
|
||||
{
|
||||
var canvasMonoEvent = UIManager.CanvasMonoEvent;
|
||||
var rectTransform = (RectTransform)transform;
|
||||
var centerBias = new Vector3(-rectTransform.rect.width / 2f, rectTransform.rect.height / 2f);
|
||||
canvasMonoEvent.onEnableEvent.AddListener(delegate
|
||||
{
|
||||
var isOn = enableToggle.isOn;
|
||||
if (isOn)
|
||||
{
|
||||
UITool.GameObject.transform.position = Input.mousePosition + centerBias;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private UIValue<T> CreateUIValue<T>(T defaultValue, string groupPath, float maxValue = 10f) where T : IComparable
|
||||
{
|
||||
var uivalue = new UIValue<T>(defaultValue, Array.Empty<Component>());
|
||||
var gameObject = UITool.FindChildGameObject(groupPath);
|
||||
var flag = gameObject == null;
|
||||
UIValue<T> uivalue2;
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogError("没有找到" + groupPath);
|
||||
uivalue2 = uivalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<Toggle>());
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<Slider>());
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<Scrollbar>());
|
||||
var componentsInChildren = gameObject.GetComponentsInChildren<Text>();
|
||||
for (var i = 0; i < componentsInChildren.Length; i++)
|
||||
{
|
||||
var flag2 = componentsInChildren[i].name == "ValueText";
|
||||
if (flag2)
|
||||
{
|
||||
uivalue.Bind(componentsInChildren[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<InputField>());
|
||||
uivalue.MaxValue = maxValue;
|
||||
uivalue2 = uivalue;
|
||||
}
|
||||
return uivalue2;
|
||||
}
|
||||
private void BindRotate()
|
||||
{
|
||||
Rotate.OnValueChange += delegate (float f)
|
||||
{
|
||||
Data.Rotate = f;
|
||||
};
|
||||
}
|
||||
|
||||
public Toggle enableToggle;
|
||||
private void BindLayerHeight()
|
||||
{
|
||||
LayerHeight.OnValueChange += delegate (float f)
|
||||
{
|
||||
Data.LayerHeight = f;
|
||||
};
|
||||
}
|
||||
|
||||
private Button _tipText;
|
||||
private void BindLayerNumber()
|
||||
{
|
||||
LayerNumber.OnValueChange += delegate (int i)
|
||||
{
|
||||
Data.LayerNumber = i;
|
||||
};
|
||||
}
|
||||
|
||||
private Button _buildButton;
|
||||
private void BindPivot()
|
||||
{
|
||||
var tempPivot = Data.Pivot;
|
||||
var cd = Time.time;
|
||||
_pivotX.OnValueChange += delegate (float f)
|
||||
{
|
||||
var flag = Time.time - cd < Time.fixedDeltaTime;
|
||||
if (!flag)
|
||||
{
|
||||
cd = Time.time;
|
||||
tempPivot.x = f;
|
||||
Data.Pivot = tempPivot;
|
||||
}
|
||||
};
|
||||
_pivotY.OnValueChange += delegate (float f)
|
||||
{
|
||||
var flag2 = Time.time - cd < Time.fixedDeltaTime;
|
||||
if (!flag2)
|
||||
{
|
||||
cd = Time.time;
|
||||
tempPivot.y = f;
|
||||
Data.Pivot = tempPivot;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Button _resetButton;
|
||||
private void BindBiasData()
|
||||
{
|
||||
var tempBias = Data.Bias;
|
||||
_biasX.OnValueChange += delegate (float f)
|
||||
{
|
||||
tempBias.x = f;
|
||||
Data.Bias = tempBias;
|
||||
};
|
||||
_biasY.OnValueChange += delegate (float f)
|
||||
{
|
||||
tempBias.y = f;
|
||||
Data.Bias = tempBias;
|
||||
};
|
||||
BiasZ.OnValueChange += delegate (float f)
|
||||
{
|
||||
tempBias.z = f;
|
||||
Data.Bias = tempBias;
|
||||
};
|
||||
}
|
||||
|
||||
public UIValue<int> LayerNumber;
|
||||
private void BindScaleData()
|
||||
{
|
||||
var tempScale = Data.Scale;
|
||||
ScaleX.OnValueChange += delegate (float f)
|
||||
{
|
||||
tempScale.x = f;
|
||||
Data.Scale = tempScale;
|
||||
};
|
||||
ScaleY.OnValueChange += delegate (float f)
|
||||
{
|
||||
tempScale.y = f;
|
||||
Data.Scale = tempScale;
|
||||
};
|
||||
ScaleZ.OnValueChange += delegate (float f)
|
||||
{
|
||||
tempScale.z = f;
|
||||
Data.Scale = tempScale;
|
||||
};
|
||||
}
|
||||
|
||||
public UIValue<float> LayerHeight;
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private static event Action<BlueTuPatchUI> InitFinish;
|
||||
|
||||
public UIValue<float> ScaleX;
|
||||
public static event Action<BlueTuPatchUI> OnInitFinish
|
||||
{
|
||||
add
|
||||
{
|
||||
InitFinish += value;
|
||||
var flag = Instance != null;
|
||||
if (flag)
|
||||
{
|
||||
value(Instance);
|
||||
}
|
||||
}
|
||||
remove => InitFinish -= value;
|
||||
}
|
||||
|
||||
public UIValue<float> ScaleY;
|
||||
private void AddDragControl<T>(UIValue<T> uiValue, string childrenName) where T : IComparable
|
||||
{
|
||||
var flag = uiValue.Components.Length != 0;
|
||||
if (flag)
|
||||
{
|
||||
var parent = uiValue.Components[0].gameObject.transform.parent;
|
||||
var transform = parent.Find(childrenName);
|
||||
bool flag2 = transform;
|
||||
if (flag2)
|
||||
{
|
||||
uiValue.BindDragControl(transform.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UIValue<float> ScaleZ;
|
||||
private void AddDragControl<T>(UIValue<T> uiValueX, UIValue<T> uiValueY, string childrenName) where T : IComparable
|
||||
{
|
||||
var flag = uiValueX.Components.Length != 0;
|
||||
if (flag)
|
||||
{
|
||||
var parent = uiValueX.Components[0].gameObject.transform.parent;
|
||||
var transform = parent.Find(childrenName);
|
||||
bool flag2 = transform;
|
||||
if (flag2)
|
||||
{
|
||||
uiValueX.BindDragControl(transform.gameObject);
|
||||
uiValueY.BindDragControl(transform.gameObject);
|
||||
UIValue<T>.BindDragControl(transform.gameObject, uiValueX, uiValueY);
|
||||
}
|
||||
}
|
||||
var flag3 = uiValueY.Components.Length != 0;
|
||||
if (flag3)
|
||||
{
|
||||
var parent2 = uiValueY.Components[0].gameObject.transform.parent;
|
||||
var transform2 = parent2.Find(childrenName);
|
||||
bool flag4 = transform2;
|
||||
if (flag4)
|
||||
{
|
||||
uiValueX.BindDragControl(transform2.gameObject);
|
||||
uiValueY.BindDragControl(transform2.gameObject);
|
||||
UIValue<T>.BindDragControl(transform2.gameObject, uiValueX, uiValueY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UIValue<float> BiasZ;
|
||||
private UIValue<T> CreateUIValue<T>(T defaultValue, string groupPath, float maxValue = 10f) where T : IComparable
|
||||
{
|
||||
var uivalue = new UIValue<T>(defaultValue, Array.Empty<Component>());
|
||||
var gameObject = UITool.FindChildGameObject(groupPath);
|
||||
var flag = gameObject == null;
|
||||
UIValue<T> uivalue2;
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogError("没有找到" + groupPath);
|
||||
uivalue2 = uivalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<Toggle>());
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<Slider>());
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<Scrollbar>());
|
||||
var componentsInChildren = gameObject.GetComponentsInChildren<Text>();
|
||||
for (var i = 0; i < componentsInChildren.Length; i++)
|
||||
{
|
||||
var flag2 = componentsInChildren[i].name == "ValueText";
|
||||
if (flag2)
|
||||
{
|
||||
uivalue.Bind(componentsInChildren[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
uivalue.Bind(gameObject.GetComponentInChildren<InputField>());
|
||||
uivalue.MaxValue = maxValue;
|
||||
uivalue2 = uivalue;
|
||||
}
|
||||
return uivalue2;
|
||||
}
|
||||
|
||||
public UIValue<float> Rotate;
|
||||
public Toggle enableToggle;
|
||||
|
||||
private UIValue<float> _pivotX;
|
||||
private Button _tipText;
|
||||
|
||||
private UIValue<float> _pivotY;
|
||||
private Button _buildButton;
|
||||
|
||||
private UIValue<float> _biasX;
|
||||
private Button _resetButton;
|
||||
|
||||
private UIValue<float> _biasY;
|
||||
public UIValue<int> LayerNumber;
|
||||
|
||||
private Button _copyButton;
|
||||
}
|
||||
public UIValue<float> LayerHeight;
|
||||
|
||||
public UIValue<float> ScaleX;
|
||||
|
||||
public UIValue<float> ScaleY;
|
||||
|
||||
public UIValue<float> ScaleZ;
|
||||
|
||||
public UIValue<float> BiasZ;
|
||||
|
||||
public UIValue<float> Rotate;
|
||||
|
||||
private UIValue<float> _pivotX;
|
||||
|
||||
private UIValue<float> _pivotY;
|
||||
|
||||
private UIValue<float> _biasX;
|
||||
|
||||
private UIValue<float> _biasY;
|
||||
|
||||
private Button _copyButton;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,22 +4,22 @@ using UnityEngine.Serialization;
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
public class CanvasMonoEvent : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
onEnableEvent = new UnityEvent();
|
||||
}
|
||||
public class CanvasMonoEvent : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
onEnableEvent = new UnityEvent();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
var onEnableEvent = this.onEnableEvent;
|
||||
if (onEnableEvent != null)
|
||||
{
|
||||
onEnableEvent.Invoke();
|
||||
}
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
var onEnableEvent = this.onEnableEvent;
|
||||
if (onEnableEvent != null)
|
||||
{
|
||||
onEnableEvent.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
[FormerlySerializedAs("OnEnableEvent")] public UnityEvent onEnableEvent;
|
||||
}
|
||||
[FormerlySerializedAs("OnEnableEvent")] public UnityEvent onEnableEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,93 +7,93 @@ using Object = UnityEngine.Object;
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
public class PanelManager
|
||||
{
|
||||
public LoadManager Loader { get; private set; }
|
||||
public class PanelManager
|
||||
{
|
||||
public LoadManager Loader { get; private set; }
|
||||
|
||||
public PanelManager(GameObject rootCanvas)
|
||||
{
|
||||
_panelStack = new Stack<BasePanel>();
|
||||
_panelDict = new Dictionary<string, BasePanel>();
|
||||
this._rootCanvas = rootCanvas;
|
||||
Loader = Singleton<LoadManager>.Instance;
|
||||
_uiAssembly = GetType().Assembly;
|
||||
}
|
||||
public PanelManager(GameObject rootCanvas)
|
||||
{
|
||||
_panelStack = new Stack<BasePanel>();
|
||||
_panelDict = new Dictionary<string, BasePanel>();
|
||||
this._rootCanvas = rootCanvas;
|
||||
Loader = Singleton<LoadManager>.Instance;
|
||||
_uiAssembly = GetType().Assembly;
|
||||
}
|
||||
|
||||
public void Push(string nextPanelName)
|
||||
{
|
||||
var flag = _panelStack.Count > 0;
|
||||
if (flag)
|
||||
{
|
||||
_panelStack.Peek().OnPause();
|
||||
}
|
||||
var flag2 = _panelDict.ContainsKey(nextPanelName);
|
||||
BasePanel basePanel;
|
||||
if (flag2)
|
||||
{
|
||||
basePanel = _panelDict[nextPanelName];
|
||||
basePanel.OnResume();
|
||||
}
|
||||
else
|
||||
{
|
||||
var text = Path.Combine(UIPrefabDir, nextPanelName);
|
||||
var gameObject = Loader.LoadPrefab(text);
|
||||
var flag3 = gameObject == null;
|
||||
if (flag3)
|
||||
{
|
||||
Debug.LogError("没有找到" + text);
|
||||
var flag4 = _panelStack.Count > 0;
|
||||
if (flag4)
|
||||
{
|
||||
_panelStack.Peek().OnResume();
|
||||
}
|
||||
return;
|
||||
}
|
||||
gameObject = Object.Instantiate(gameObject, _rootCanvas.transform);
|
||||
var type = _uiAssembly.GetType(_panelNameSapce + "." + nextPanelName);
|
||||
basePanel = (BasePanel)gameObject.AddComponent(type);
|
||||
var uitool = new UITool(gameObject);
|
||||
basePanel.Init(this);
|
||||
basePanel.Init(uitool);
|
||||
_panelDict.Add(nextPanelName, basePanel);
|
||||
basePanel.OnEnter();
|
||||
}
|
||||
_panelStack.Push(basePanel);
|
||||
}
|
||||
public void Push(string nextPanelName)
|
||||
{
|
||||
var flag = _panelStack.Count > 0;
|
||||
if (flag)
|
||||
{
|
||||
_panelStack.Peek().OnPause();
|
||||
}
|
||||
var flag2 = _panelDict.ContainsKey(nextPanelName);
|
||||
BasePanel basePanel;
|
||||
if (flag2)
|
||||
{
|
||||
basePanel = _panelDict[nextPanelName];
|
||||
basePanel.OnResume();
|
||||
}
|
||||
else
|
||||
{
|
||||
var text = Path.Combine(UIPrefabDir, nextPanelName);
|
||||
var gameObject = Loader.LoadPrefab(text);
|
||||
var flag3 = gameObject == null;
|
||||
if (flag3)
|
||||
{
|
||||
Debug.LogError("没有找到" + text);
|
||||
var flag4 = _panelStack.Count > 0;
|
||||
if (flag4)
|
||||
{
|
||||
_panelStack.Peek().OnResume();
|
||||
}
|
||||
return;
|
||||
}
|
||||
gameObject = Object.Instantiate(gameObject, _rootCanvas.transform);
|
||||
var type = _uiAssembly.GetType(_panelNameSapce + "." + nextPanelName);
|
||||
basePanel = (BasePanel)gameObject.AddComponent(type);
|
||||
var uitool = new UITool(gameObject);
|
||||
basePanel.Init(this);
|
||||
basePanel.Init(uitool);
|
||||
_panelDict.Add(nextPanelName, basePanel);
|
||||
basePanel.OnEnter();
|
||||
}
|
||||
_panelStack.Push(basePanel);
|
||||
}
|
||||
|
||||
public void Pop()
|
||||
{
|
||||
var flag = _panelStack.Count > 0;
|
||||
if (flag)
|
||||
{
|
||||
var basePanel = _panelStack.Pop();
|
||||
basePanel.OnPause();
|
||||
}
|
||||
var flag2 = _panelStack.Count > 0;
|
||||
if (flag2)
|
||||
{
|
||||
_panelStack.Peek().OnResume();
|
||||
}
|
||||
}
|
||||
public void Pop()
|
||||
{
|
||||
var flag = _panelStack.Count > 0;
|
||||
if (flag)
|
||||
{
|
||||
var basePanel = _panelStack.Pop();
|
||||
basePanel.OnPause();
|
||||
}
|
||||
var flag2 = _panelStack.Count > 0;
|
||||
if (flag2)
|
||||
{
|
||||
_panelStack.Peek().OnResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
for (var i = 0; i < _panelDict.Count; i++)
|
||||
{
|
||||
_panelDict.ElementAt(i).Value.OnExit();
|
||||
}
|
||||
}
|
||||
public void Exit()
|
||||
{
|
||||
for (var i = 0; i < _panelDict.Count; i++)
|
||||
{
|
||||
_panelDict.ElementAt(i).Value.OnExit();
|
||||
}
|
||||
}
|
||||
|
||||
private Stack<BasePanel> _panelStack;
|
||||
private Stack<BasePanel> _panelStack;
|
||||
|
||||
private Dictionary<string, BasePanel> _panelDict;
|
||||
private Dictionary<string, BasePanel> _panelDict;
|
||||
|
||||
private GameObject _rootCanvas;
|
||||
private GameObject _rootCanvas;
|
||||
|
||||
private Assembly _uiAssembly;
|
||||
private Assembly _uiAssembly;
|
||||
|
||||
private string _panelNameSapce = "XianTu.UI";
|
||||
private string _panelNameSapce = "XianTu.UI";
|
||||
|
||||
public readonly string UIPrefabDir = "Prefabs/UI";
|
||||
}
|
||||
public readonly string UIPrefabDir = "Prefabs/UI";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,69 +4,69 @@ using Object = UnityEngine.Object;
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
public class UIManager
|
||||
{
|
||||
public GameObject CanvasObj { get; private set; }
|
||||
public class UIManager
|
||||
{
|
||||
public GameObject CanvasObj { get; private set; }
|
||||
|
||||
public bool ActiveSelf => CanvasObj.activeSelf;
|
||||
public bool ActiveSelf => CanvasObj.activeSelf;
|
||||
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
CanvasObj.SetActive(value);
|
||||
}
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
CanvasObj.SetActive(value);
|
||||
}
|
||||
|
||||
public void SwitchDisplay()
|
||||
{
|
||||
CanvasObj.SetActive(CanvasObj.activeSelf);
|
||||
}
|
||||
public void SwitchDisplay()
|
||||
{
|
||||
CanvasObj.SetActive(CanvasObj.activeSelf);
|
||||
}
|
||||
|
||||
public UIManager(Action<object> debugLog = null)
|
||||
{
|
||||
Instance = this;
|
||||
var flag = debugLog == null;
|
||||
if (flag)
|
||||
{
|
||||
DebugLog = new Action<object>(Debug.Log);
|
||||
}
|
||||
var flag2 = !LoadCanvas();
|
||||
if (flag2)
|
||||
{
|
||||
DebugLog("UI管理器加载失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
PanelManager = new PanelManager(CanvasObj);
|
||||
}
|
||||
}
|
||||
public UIManager(Action<object> debugLog = null)
|
||||
{
|
||||
Instance = this;
|
||||
var flag = debugLog == null;
|
||||
if (flag)
|
||||
{
|
||||
DebugLog = new Action<object>(Debug.Log);
|
||||
}
|
||||
var flag2 = !LoadCanvas();
|
||||
if (flag2)
|
||||
{
|
||||
DebugLog("UI管理器加载失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
PanelManager = new PanelManager(CanvasObj);
|
||||
}
|
||||
}
|
||||
|
||||
public PanelManager PanelManager { get; private set; }
|
||||
public PanelManager PanelManager { get; private set; }
|
||||
|
||||
public static UIManager Instance { get; private set; }
|
||||
public static UIManager Instance { get; private set; }
|
||||
|
||||
public CanvasMonoEvent CanvasMonoEvent { get; private set; }
|
||||
public CanvasMonoEvent CanvasMonoEvent { get; private set; }
|
||||
|
||||
private bool LoadCanvas()
|
||||
{
|
||||
var gameObject = Singleton<LoadManager>.Instance.LoadPrefab("Prefabs/XianTuCanvas");
|
||||
var flag = gameObject != null;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
var gameObject2 = Object.Instantiate(gameObject);
|
||||
CanvasObj = gameObject2;
|
||||
CanvasMonoEvent = gameObject2.AddComponent<CanvasMonoEvent>();
|
||||
gameObject2.SetActive(false);
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
private bool LoadCanvas()
|
||||
{
|
||||
var gameObject = Singleton<LoadManager>.Instance.LoadPrefab("Prefabs/XianTuCanvas");
|
||||
var flag = gameObject != null;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
var gameObject2 = Object.Instantiate(gameObject);
|
||||
CanvasObj = gameObject2;
|
||||
CanvasMonoEvent = gameObject2.AddComponent<CanvasMonoEvent>();
|
||||
gameObject2.SetActive(false);
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
private const string CanvasPrefabPath = "Prefabs/XianTuCanvas";
|
||||
private const string CanvasPrefabPath = "Prefabs/XianTuCanvas";
|
||||
|
||||
public readonly Action<object> DebugLog;
|
||||
}
|
||||
public readonly Action<object> DebugLog;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,144 +5,144 @@ using UnityEngine;
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
internal class UITool
|
||||
{
|
||||
public UITool(GameObject uiGameObject)
|
||||
{
|
||||
GameObject = uiGameObject;
|
||||
Transform = GameObject.transform;
|
||||
}
|
||||
internal class UITool
|
||||
{
|
||||
public UITool(GameObject uiGameObject)
|
||||
{
|
||||
GameObject = uiGameObject;
|
||||
Transform = GameObject.transform;
|
||||
}
|
||||
|
||||
public T GetComponentInChild<T>(string path) where T : class
|
||||
{
|
||||
var gameObject = FindChildGameObject(path);
|
||||
bool flag = gameObject;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = gameObject.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
public T GetComponentInChild<T>(string path) where T : class
|
||||
{
|
||||
var gameObject = FindChildGameObject(path);
|
||||
bool flag = gameObject;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = gameObject.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public GameObject FindChildGameObject(string path)
|
||||
{
|
||||
var array = path.Split(['/']);
|
||||
var flag = array.Length == 0;
|
||||
GameObject gameObject;
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogError("空路径");
|
||||
gameObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = array[0] == "";
|
||||
GameObject gameObject2;
|
||||
if (flag2)
|
||||
{
|
||||
gameObject2 = StepByStepFindChild(Transform, array.Skip(1).ToArray());
|
||||
var flag3 = gameObject2 != null;
|
||||
if (flag3)
|
||||
{
|
||||
return gameObject2.gameObject;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject2 = BreadthFindChild(Transform, array[0]);
|
||||
var flag4 = gameObject2 != null && array.Length > 1;
|
||||
if (flag4)
|
||||
{
|
||||
gameObject2 = StepByStepFindChild(gameObject2.transform, array.Skip(1).ToArray());
|
||||
}
|
||||
}
|
||||
var flag5 = gameObject2 == null;
|
||||
if (flag5)
|
||||
{
|
||||
Debug.LogError("找不到" + path);
|
||||
}
|
||||
gameObject = gameObject2;
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
public GameObject FindChildGameObject(string path)
|
||||
{
|
||||
var array = path.Split(['/']);
|
||||
var flag = array.Length == 0;
|
||||
GameObject gameObject;
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogError("空路径");
|
||||
gameObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = array[0] == "";
|
||||
GameObject gameObject2;
|
||||
if (flag2)
|
||||
{
|
||||
gameObject2 = StepByStepFindChild(Transform, array.Skip(1).ToArray());
|
||||
var flag3 = gameObject2 != null;
|
||||
if (flag3)
|
||||
{
|
||||
return gameObject2.gameObject;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject2 = BreadthFindChild(Transform, array[0]);
|
||||
var flag4 = gameObject2 != null && array.Length > 1;
|
||||
if (flag4)
|
||||
{
|
||||
gameObject2 = StepByStepFindChild(gameObject2.transform, array.Skip(1).ToArray());
|
||||
}
|
||||
}
|
||||
var flag5 = gameObject2 == null;
|
||||
if (flag5)
|
||||
{
|
||||
Debug.LogError("找不到" + path);
|
||||
}
|
||||
gameObject = gameObject2;
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
private static GameObject BreadthFindChild(Transform parent, string name)
|
||||
{
|
||||
var flag = parent == null;
|
||||
GameObject gameObject;
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogError("不要传个空的过来!");
|
||||
gameObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var queue = new Queue<Transform>();
|
||||
queue.Enqueue(parent);
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var transform = queue.Dequeue();
|
||||
var transform2 = transform.Find(name);
|
||||
var flag2 = transform2 != null;
|
||||
if (flag2)
|
||||
{
|
||||
return transform2.gameObject;
|
||||
}
|
||||
for (var i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
queue.Enqueue(transform.GetChild(i));
|
||||
}
|
||||
}
|
||||
gameObject = null;
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
private static GameObject BreadthFindChild(Transform parent, string name)
|
||||
{
|
||||
var flag = parent == null;
|
||||
GameObject gameObject;
|
||||
if (flag)
|
||||
{
|
||||
Debug.LogError("不要传个空的过来!");
|
||||
gameObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var queue = new Queue<Transform>();
|
||||
queue.Enqueue(parent);
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var transform = queue.Dequeue();
|
||||
var transform2 = transform.Find(name);
|
||||
var flag2 = transform2 != null;
|
||||
if (flag2)
|
||||
{
|
||||
return transform2.gameObject;
|
||||
}
|
||||
for (var i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
queue.Enqueue(transform.GetChild(i));
|
||||
}
|
||||
}
|
||||
gameObject = null;
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
public T GetOrAddComponentInChildren<T>(string name) where T : Component
|
||||
{
|
||||
var gameObject = FindChildGameObject(name);
|
||||
var flag = gameObject != null;
|
||||
T t2;
|
||||
if (flag)
|
||||
{
|
||||
var t = gameObject.GetComponent<T>();
|
||||
var flag2 = t == null;
|
||||
if (flag2)
|
||||
{
|
||||
t = gameObject.AddComponent<T>();
|
||||
}
|
||||
t2 = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = default(T);
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
public T GetOrAddComponentInChildren<T>(string name) where T : Component
|
||||
{
|
||||
var gameObject = FindChildGameObject(name);
|
||||
var flag = gameObject != null;
|
||||
T t2;
|
||||
if (flag)
|
||||
{
|
||||
var t = gameObject.GetComponent<T>();
|
||||
var flag2 = t == null;
|
||||
if (flag2)
|
||||
{
|
||||
t = gameObject.AddComponent<T>();
|
||||
}
|
||||
t2 = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = default(T);
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
|
||||
[CompilerGenerated]
|
||||
internal static GameObject StepByStepFindChild(Transform parent, string[] filepaths)
|
||||
{
|
||||
var transform = parent;
|
||||
for (var i = 0; i < filepaths.Length; i++)
|
||||
{
|
||||
transform = transform.Find(filepaths[i]);
|
||||
var flag = transform == null;
|
||||
if (flag)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return transform.gameObject;
|
||||
}
|
||||
[CompilerGenerated]
|
||||
internal static GameObject StepByStepFindChild(Transform parent, string[] filepaths)
|
||||
{
|
||||
var transform = parent;
|
||||
for (var i = 0; i < filepaths.Length; i++)
|
||||
{
|
||||
transform = transform.Find(filepaths[i]);
|
||||
var flag = transform == null;
|
||||
if (flag)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return transform.gameObject;
|
||||
}
|
||||
|
||||
public readonly GameObject GameObject;
|
||||
public readonly GameObject GameObject;
|
||||
|
||||
public readonly Transform Transform;
|
||||
}
|
||||
public readonly Transform Transform;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
namespace XianTu.UI
|
||||
{
|
||||
internal class UIType
|
||||
{
|
||||
public UIType(string prefabPath)
|
||||
{
|
||||
this.PrefabPath = prefabPath;
|
||||
Name = prefabPath.Substring(prefabPath.LastIndexOf('/') + 1);
|
||||
}
|
||||
internal class UIType
|
||||
{
|
||||
public UIType(string prefabPath)
|
||||
{
|
||||
this.PrefabPath = prefabPath;
|
||||
Name = prefabPath.Substring(prefabPath.LastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
public string PrefabPath;
|
||||
public string PrefabPath;
|
||||
|
||||
public string Name;
|
||||
}
|
||||
public string Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,414 +8,414 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
internal class UIValue<T> where T : IComparable
|
||||
{
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private event Action<object> ValueUpdate;
|
||||
internal class UIValue<T> where T : IComparable
|
||||
{
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private event Action<object> ValueUpdate;
|
||||
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
public event Action<T> OnValueChange;
|
||||
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
public event Action<T> OnValueChange;
|
||||
|
||||
public T Value
|
||||
{
|
||||
get => _value;
|
||||
public T Value
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
var publicValueLock = _publicValueLock;
|
||||
if (!publicValueLock)
|
||||
{
|
||||
_publicValueLock = true;
|
||||
ValueUpdate(value);
|
||||
_publicValueLock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
var publicValueLock = _publicValueLock;
|
||||
if (!publicValueLock)
|
||||
{
|
||||
_publicValueLock = true;
|
||||
ValueUpdate(value);
|
||||
_publicValueLock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float MaxValue
|
||||
{
|
||||
get => _maxValue;
|
||||
public float MaxValue
|
||||
{
|
||||
get => _maxValue;
|
||||
set
|
||||
{
|
||||
_maxValue = value;
|
||||
for (var i = 0; i < Components.Length; i++)
|
||||
{
|
||||
var component = Components[i];
|
||||
var component2 = component;
|
||||
var slider = component2 as Slider;
|
||||
if (slider != null)
|
||||
{
|
||||
slider.maxValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
_maxValue = value;
|
||||
for (var i = 0; i < Components.Length; i++)
|
||||
{
|
||||
var component = Components[i];
|
||||
var component2 = component;
|
||||
var slider = component2 as Slider;
|
||||
if (slider != null)
|
||||
{
|
||||
slider.maxValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UIValue(T defaultValue, params Component[] components)
|
||||
{
|
||||
var flag = typeof(T) == typeof(bool);
|
||||
if (flag)
|
||||
{
|
||||
_valueType = EValueType.Bool;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = typeof(T) == typeof(int);
|
||||
if (flag2)
|
||||
{
|
||||
_valueType = EValueType.Int;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag3 = typeof(T) == typeof(float);
|
||||
if (flag3)
|
||||
{
|
||||
_valueType = EValueType.Float;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag4 = typeof(T) == typeof(string);
|
||||
if (flag4)
|
||||
{
|
||||
_valueType = EValueType.String;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag5 = typeof(T) == typeof(double);
|
||||
if (flag5)
|
||||
{
|
||||
_valueType = EValueType.Double;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ValueUpdate = delegate(object v)
|
||||
{
|
||||
switch (_valueType)
|
||||
{
|
||||
case EValueType.Bool:
|
||||
_value = (T)((object)Convert.ToBoolean(v));
|
||||
break;
|
||||
case EValueType.Int:
|
||||
_value = (T)((object)Convert.ToInt32(v));
|
||||
break;
|
||||
case EValueType.Float:
|
||||
_value = (T)((object)Convert.ToSingle(v));
|
||||
break;
|
||||
case EValueType.Double:
|
||||
_value = (T)((object)Convert.ToDouble(v));
|
||||
break;
|
||||
case EValueType.String:
|
||||
_value = (T)((object)_valueType.ToString());
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange(_value);
|
||||
}
|
||||
};
|
||||
foreach (var component in components)
|
||||
{
|
||||
var component2 = component;
|
||||
var component3 = component2;
|
||||
var inputField = component3 as InputField;
|
||||
if (inputField == null)
|
||||
{
|
||||
var toggle = component3 as Toggle;
|
||||
if (toggle == null)
|
||||
{
|
||||
var slider = component3 as Slider;
|
||||
if (slider == null)
|
||||
{
|
||||
var text = component3 as Text;
|
||||
if (text == null)
|
||||
{
|
||||
var scrollbar = component3 as Scrollbar;
|
||||
if (scrollbar != null)
|
||||
{
|
||||
Bind(scrollbar);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(slider);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(toggle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(inputField);
|
||||
}
|
||||
}
|
||||
}
|
||||
public UIValue(T defaultValue, params Component[] components)
|
||||
{
|
||||
var flag = typeof(T) == typeof(bool);
|
||||
if (flag)
|
||||
{
|
||||
_valueType = EValueType.Bool;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag2 = typeof(T) == typeof(int);
|
||||
if (flag2)
|
||||
{
|
||||
_valueType = EValueType.Int;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag3 = typeof(T) == typeof(float);
|
||||
if (flag3)
|
||||
{
|
||||
_valueType = EValueType.Float;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag4 = typeof(T) == typeof(string);
|
||||
if (flag4)
|
||||
{
|
||||
_valueType = EValueType.String;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag5 = typeof(T) == typeof(double);
|
||||
if (flag5)
|
||||
{
|
||||
_valueType = EValueType.Double;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ValueUpdate = delegate (object v)
|
||||
{
|
||||
switch (_valueType)
|
||||
{
|
||||
case EValueType.Bool:
|
||||
_value = (T)((object)Convert.ToBoolean(v));
|
||||
break;
|
||||
case EValueType.Int:
|
||||
_value = (T)((object)Convert.ToInt32(v));
|
||||
break;
|
||||
case EValueType.Float:
|
||||
_value = (T)((object)Convert.ToSingle(v));
|
||||
break;
|
||||
case EValueType.Double:
|
||||
_value = (T)((object)Convert.ToDouble(v));
|
||||
break;
|
||||
case EValueType.String:
|
||||
_value = (T)((object)_valueType.ToString());
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
var onValueChange = OnValueChange;
|
||||
if (onValueChange != null)
|
||||
{
|
||||
onValueChange(_value);
|
||||
}
|
||||
};
|
||||
foreach (var component in components)
|
||||
{
|
||||
var component2 = component;
|
||||
var component3 = component2;
|
||||
var inputField = component3 as InputField;
|
||||
if (inputField == null)
|
||||
{
|
||||
var toggle = component3 as Toggle;
|
||||
if (toggle == null)
|
||||
{
|
||||
var slider = component3 as Slider;
|
||||
if (slider == null)
|
||||
{
|
||||
var text = component3 as Text;
|
||||
if (text == null)
|
||||
{
|
||||
var scrollbar = component3 as Scrollbar;
|
||||
if (scrollbar != null)
|
||||
{
|
||||
Bind(scrollbar);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(slider);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(toggle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind(inputField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Bind(Scrollbar scrollBar)
|
||||
{
|
||||
var flag = scrollBar == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(scrollBar).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate(object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
scrollBar.value = Convert.ToSingle(value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
scrollBar.onValueChanged.AddListener(delegate(float value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
hasSet = true;
|
||||
ValueUpdate(value);
|
||||
hasSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public void Bind(Scrollbar scrollBar)
|
||||
{
|
||||
var flag = scrollBar == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(scrollBar).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate (object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
scrollBar.value = Convert.ToSingle(value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
scrollBar.onValueChanged.AddListener(delegate (float value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
hasSet = true;
|
||||
ValueUpdate(value);
|
||||
hasSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Bind(Text text)
|
||||
{
|
||||
var flag = text == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(text).ToArray();
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate(object value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
justUpdate = true;
|
||||
text.text = string.Format("{0:f2}", value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
public void Bind(Text text)
|
||||
{
|
||||
var flag = text == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(text).ToArray();
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate (object value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
justUpdate = true;
|
||||
text.text = string.Format("{0:f2}", value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void Bind(Slider slider)
|
||||
{
|
||||
var flag = slider == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(slider).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate(object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
slider.value = Convert.ToSingle(value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
slider.onValueChanged.AddListener(delegate(float value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
hasSet = true;
|
||||
ValueUpdate(value);
|
||||
hasSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public void Bind(Slider slider)
|
||||
{
|
||||
var flag = slider == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(slider).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate (object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
slider.value = Convert.ToSingle(value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
slider.onValueChanged.AddListener(delegate (float value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
hasSet = true;
|
||||
ValueUpdate(value);
|
||||
hasSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Bind(Toggle toggle)
|
||||
{
|
||||
var flag = toggle == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(toggle).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate(object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
toggle.isOn = Convert.ToBoolean(value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
toggle.onValueChanged.AddListener(delegate(bool value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
hasSet = true;
|
||||
ValueUpdate(value);
|
||||
hasSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public void Bind(Toggle toggle)
|
||||
{
|
||||
var flag = toggle == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(toggle).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate (object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
toggle.isOn = Convert.ToBoolean(value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
toggle.onValueChanged.AddListener(delegate (bool value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
hasSet = true;
|
||||
ValueUpdate(value);
|
||||
hasSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Bind(InputField inputField)
|
||||
{
|
||||
var flag = inputField == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(inputField).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate(object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
inputField.text = string.Format("{0:f2}", value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
inputField.onValueChanged.AddListener(delegate(string value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
var flag2 = value == "-" || value == "";
|
||||
if (!flag2)
|
||||
{
|
||||
hasSet = true;
|
||||
switch (_valueType)
|
||||
{
|
||||
case EValueType.Bool:
|
||||
ValueUpdate(Convert.ToBoolean(value));
|
||||
break;
|
||||
case EValueType.Int:
|
||||
ValueUpdate(Convert.ToInt32(value));
|
||||
break;
|
||||
case EValueType.Float:
|
||||
ValueUpdate(Convert.ToSingle(value));
|
||||
break;
|
||||
case EValueType.Double:
|
||||
ValueUpdate(Convert.ToDouble(value));
|
||||
break;
|
||||
case EValueType.String:
|
||||
ValueUpdate(value);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
hasSet = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public void Bind(InputField inputField)
|
||||
{
|
||||
var flag = inputField == null;
|
||||
if (!flag)
|
||||
{
|
||||
Components = Components.Append(inputField).ToArray();
|
||||
var hasSet = false;
|
||||
var justUpdate = false;
|
||||
ValueUpdate += delegate (object value)
|
||||
{
|
||||
var hasSet2 = hasSet;
|
||||
if (!hasSet2)
|
||||
{
|
||||
justUpdate = true;
|
||||
inputField.text = string.Format("{0:f2}", value);
|
||||
justUpdate = false;
|
||||
}
|
||||
};
|
||||
inputField.onValueChanged.AddListener(delegate (string value)
|
||||
{
|
||||
var justUpdate2 = justUpdate;
|
||||
if (!justUpdate2)
|
||||
{
|
||||
var flag2 = value == "-" || value == "";
|
||||
if (!flag2)
|
||||
{
|
||||
hasSet = true;
|
||||
switch (_valueType)
|
||||
{
|
||||
case EValueType.Bool:
|
||||
ValueUpdate(Convert.ToBoolean(value));
|
||||
break;
|
||||
case EValueType.Int:
|
||||
ValueUpdate(Convert.ToInt32(value));
|
||||
break;
|
||||
case EValueType.Float:
|
||||
ValueUpdate(Convert.ToSingle(value));
|
||||
break;
|
||||
case EValueType.Double:
|
||||
ValueUpdate(Convert.ToDouble(value));
|
||||
break;
|
||||
case EValueType.String:
|
||||
ValueUpdate(value);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
hasSet = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void BindDragControl(GameObject gameObject)
|
||||
{
|
||||
var startPosition = default(Vector2);
|
||||
var defaultValue = 0f;
|
||||
var eventTrigger = gameObject.GetComponent<EventTrigger>();
|
||||
var flag = eventTrigger == null;
|
||||
if (flag)
|
||||
{
|
||||
eventTrigger = gameObject.AddComponent<EventTrigger>();
|
||||
}
|
||||
var speed = 0f;
|
||||
eventTrigger.Add(EventTriggerType.BeginDrag, delegate(BaseEventData edata)
|
||||
{
|
||||
var pointerEventData = edata as PointerEventData;
|
||||
var flag2 = pointerEventData != null;
|
||||
if (flag2)
|
||||
{
|
||||
startPosition = pointerEventData.position;
|
||||
defaultValue = Convert.ToSingle(Value);
|
||||
speed = _maxValue / Screen.width * 4f;
|
||||
}
|
||||
});
|
||||
eventTrigger.Add(EventTriggerType.Drag, delegate(BaseEventData edata)
|
||||
{
|
||||
var pointerEventData2 = edata as PointerEventData;
|
||||
var flag3 = pointerEventData2 != null;
|
||||
if (flag3)
|
||||
{
|
||||
var num = (pointerEventData2.position.x - startPosition.x) * speed;
|
||||
ValueUpdate(defaultValue + num);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void BindDragControl(GameObject gameObject)
|
||||
{
|
||||
var startPosition = default(Vector2);
|
||||
var defaultValue = 0f;
|
||||
var eventTrigger = gameObject.GetComponent<EventTrigger>();
|
||||
var flag = eventTrigger == null;
|
||||
if (flag)
|
||||
{
|
||||
eventTrigger = gameObject.AddComponent<EventTrigger>();
|
||||
}
|
||||
var speed = 0f;
|
||||
eventTrigger.Add(EventTriggerType.BeginDrag, delegate (BaseEventData edata)
|
||||
{
|
||||
var pointerEventData = edata as PointerEventData;
|
||||
var flag2 = pointerEventData != null;
|
||||
if (flag2)
|
||||
{
|
||||
startPosition = pointerEventData.position;
|
||||
defaultValue = Convert.ToSingle(Value);
|
||||
speed = _maxValue / Screen.width * 4f;
|
||||
}
|
||||
});
|
||||
eventTrigger.Add(EventTriggerType.Drag, delegate (BaseEventData edata)
|
||||
{
|
||||
var pointerEventData2 = edata as PointerEventData;
|
||||
var flag3 = pointerEventData2 != null;
|
||||
if (flag3)
|
||||
{
|
||||
var num = (pointerEventData2.position.x - startPosition.x) * speed;
|
||||
ValueUpdate(defaultValue + num);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void BindDragControl(GameObject controller, UIValue<T> uiValueX, UIValue<T> uiValueY)
|
||||
{
|
||||
var startPosition = default(Vector2);
|
||||
var defaultValue1 = 0f;
|
||||
var defaultValue2 = 0f;
|
||||
var eventTrigger = controller.GetComponent<EventTrigger>();
|
||||
var flag = eventTrigger == null;
|
||||
if (flag)
|
||||
{
|
||||
eventTrigger = controller.AddComponent<EventTrigger>();
|
||||
}
|
||||
var speed = 0f;
|
||||
eventTrigger.Add(EventTriggerType.BeginDrag, delegate(BaseEventData edata)
|
||||
{
|
||||
var pointerEventData = edata as PointerEventData;
|
||||
var flag2 = pointerEventData != null;
|
||||
if (flag2)
|
||||
{
|
||||
startPosition = pointerEventData.position;
|
||||
defaultValue1 = Convert.ToSingle(uiValueX.Value);
|
||||
defaultValue2 = Convert.ToSingle(uiValueY.Value);
|
||||
speed = uiValueX._maxValue / Screen.width * 4f;
|
||||
}
|
||||
});
|
||||
eventTrigger.Add(EventTriggerType.Drag, delegate(BaseEventData edata)
|
||||
{
|
||||
var pointerEventData2 = edata as PointerEventData;
|
||||
var flag3 = pointerEventData2 != null;
|
||||
if (flag3)
|
||||
{
|
||||
var vector = (pointerEventData2.position - startPosition) * speed;
|
||||
uiValueX.ValueUpdate(defaultValue1 + vector.x);
|
||||
uiValueY.ValueUpdate(defaultValue2 + vector.y);
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void BindDragControl(GameObject controller, UIValue<T> uiValueX, UIValue<T> uiValueY)
|
||||
{
|
||||
var startPosition = default(Vector2);
|
||||
var defaultValue1 = 0f;
|
||||
var defaultValue2 = 0f;
|
||||
var eventTrigger = controller.GetComponent<EventTrigger>();
|
||||
var flag = eventTrigger == null;
|
||||
if (flag)
|
||||
{
|
||||
eventTrigger = controller.AddComponent<EventTrigger>();
|
||||
}
|
||||
var speed = 0f;
|
||||
eventTrigger.Add(EventTriggerType.BeginDrag, delegate (BaseEventData edata)
|
||||
{
|
||||
var pointerEventData = edata as PointerEventData;
|
||||
var flag2 = pointerEventData != null;
|
||||
if (flag2)
|
||||
{
|
||||
startPosition = pointerEventData.position;
|
||||
defaultValue1 = Convert.ToSingle(uiValueX.Value);
|
||||
defaultValue2 = Convert.ToSingle(uiValueY.Value);
|
||||
speed = uiValueX._maxValue / Screen.width * 4f;
|
||||
}
|
||||
});
|
||||
eventTrigger.Add(EventTriggerType.Drag, delegate (BaseEventData edata)
|
||||
{
|
||||
var pointerEventData2 = edata as PointerEventData;
|
||||
var flag3 = pointerEventData2 != null;
|
||||
if (flag3)
|
||||
{
|
||||
var vector = (pointerEventData2.position - startPosition) * speed;
|
||||
uiValueX.ValueUpdate(defaultValue1 + vector.x);
|
||||
uiValueY.ValueUpdate(defaultValue2 + vector.y);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private T _value;
|
||||
private T _value;
|
||||
|
||||
private float _maxValue = 1f;
|
||||
private float _maxValue = 1f;
|
||||
|
||||
private readonly EValueType _valueType;
|
||||
private readonly EValueType _valueType;
|
||||
|
||||
public Component[] Components = new Component[0];
|
||||
public Component[] Components = new Component[0];
|
||||
|
||||
private bool _publicValueLock = false;
|
||||
private bool _publicValueLock = false;
|
||||
|
||||
private enum EValueType
|
||||
{
|
||||
Bool,
|
||||
Int,
|
||||
Float,
|
||||
Double,
|
||||
String
|
||||
}
|
||||
}
|
||||
private enum EValueType
|
||||
{
|
||||
Bool,
|
||||
Int,
|
||||
Float,
|
||||
Double,
|
||||
String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,144 +6,144 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XianTu.UI
|
||||
{
|
||||
internal class XianTuBasePanel : BasePanel
|
||||
{
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
UIManager = UIManager.Instance;
|
||||
BindBaseEvent();
|
||||
_uRect = UITool.GameObject.GetComponent<RectTransform>();
|
||||
_defaultRect = _uRect.rect;
|
||||
}
|
||||
internal class XianTuBasePanel : BasePanel
|
||||
{
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
UIManager = UIManager.Instance;
|
||||
BindBaseEvent();
|
||||
_uRect = UITool.GameObject.GetComponent<RectTransform>();
|
||||
_defaultRect = _uRect.rect;
|
||||
}
|
||||
|
||||
public UIManager UIManager { get; set; }
|
||||
public UIManager UIManager { get; set; }
|
||||
|
||||
private void BindBaseEvent()
|
||||
{
|
||||
BindCloseWindowBtn();
|
||||
var eventTrigger = UITool.GameObject.AddComponent<EventTrigger>();
|
||||
eventTrigger.triggers = [];
|
||||
var transform = UITool.Transform;
|
||||
TriggerAdd(eventTrigger, EventTriggerType.Drag, delegate(BaseEventData x)
|
||||
{
|
||||
var pointerEventData = x as PointerEventData;
|
||||
var flag = pointerEventData != null;
|
||||
if (flag)
|
||||
{
|
||||
var vector = pointerEventData.position - _dragBias;
|
||||
var width = _defaultRect.width;
|
||||
var height = _defaultRect.height;
|
||||
switch (_dragMode)
|
||||
{
|
||||
case EDragMode.Drag:
|
||||
transform.position = _sourceDragPoint + vector;
|
||||
break;
|
||||
case EDragMode.ScaleX:
|
||||
_uRect.sizeDelta = new Vector2(width + vector.x, height);
|
||||
break;
|
||||
case EDragMode.ScaleY:
|
||||
_uRect.sizeDelta = new Vector2(width, height - vector.y);
|
||||
break;
|
||||
case EDragMode.ScaleXY:
|
||||
_uRect.sizeDelta = new Vector2(width + vector.x, height - vector.y);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
});
|
||||
TriggerAdd(eventTrigger, EventTriggerType.PointerDown, delegate(BaseEventData x)
|
||||
{
|
||||
var pointerEventData2 = x as PointerEventData;
|
||||
_sourceDragPoint = transform.position;
|
||||
_dragBias = pointerEventData2.position;
|
||||
var position = pointerEventData2.position;
|
||||
var position2 = transform.position;
|
||||
var num = position.x - position2.x;
|
||||
var num2 = position.y - position2.y;
|
||||
var rect = _uRect.rect;
|
||||
var flag2 = rect.height - 20f < num2;
|
||||
var flag3 = flag2;
|
||||
if (flag3)
|
||||
{
|
||||
_dragMode = EDragMode.Drag;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag4 = num > rect.width - 20f;
|
||||
var flag5 = -num2 > rect.height - 20f;
|
||||
var flag6 = flag4 && flag5;
|
||||
if (flag6)
|
||||
{
|
||||
_dragMode = EDragMode.ScaleXY;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag7 = flag4;
|
||||
if (flag7)
|
||||
{
|
||||
_dragMode = EDragMode.ScaleX;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag8 = flag5;
|
||||
if (flag8)
|
||||
{
|
||||
_dragMode = EDragMode.ScaleY;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dragMode = EDragMode.Drag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void BindBaseEvent()
|
||||
{
|
||||
BindCloseWindowBtn();
|
||||
var eventTrigger = UITool.GameObject.AddComponent<EventTrigger>();
|
||||
eventTrigger.triggers = [];
|
||||
var transform = UITool.Transform;
|
||||
TriggerAdd(eventTrigger, EventTriggerType.Drag, delegate (BaseEventData x)
|
||||
{
|
||||
var pointerEventData = x as PointerEventData;
|
||||
var flag = pointerEventData != null;
|
||||
if (flag)
|
||||
{
|
||||
var vector = pointerEventData.position - _dragBias;
|
||||
var width = _defaultRect.width;
|
||||
var height = _defaultRect.height;
|
||||
switch (_dragMode)
|
||||
{
|
||||
case EDragMode.Drag:
|
||||
transform.position = _sourceDragPoint + vector;
|
||||
break;
|
||||
case EDragMode.ScaleX:
|
||||
_uRect.sizeDelta = new Vector2(width + vector.x, height);
|
||||
break;
|
||||
case EDragMode.ScaleY:
|
||||
_uRect.sizeDelta = new Vector2(width, height - vector.y);
|
||||
break;
|
||||
case EDragMode.ScaleXY:
|
||||
_uRect.sizeDelta = new Vector2(width + vector.x, height - vector.y);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
});
|
||||
TriggerAdd(eventTrigger, EventTriggerType.PointerDown, delegate (BaseEventData x)
|
||||
{
|
||||
var pointerEventData2 = x as PointerEventData;
|
||||
_sourceDragPoint = transform.position;
|
||||
_dragBias = pointerEventData2.position;
|
||||
var position = pointerEventData2.position;
|
||||
var position2 = transform.position;
|
||||
var num = position.x - position2.x;
|
||||
var num2 = position.y - position2.y;
|
||||
var rect = _uRect.rect;
|
||||
var flag2 = rect.height - 20f < num2;
|
||||
var flag3 = flag2;
|
||||
if (flag3)
|
||||
{
|
||||
_dragMode = EDragMode.Drag;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag4 = num > rect.width - 20f;
|
||||
var flag5 = -num2 > rect.height - 20f;
|
||||
var flag6 = flag4 && flag5;
|
||||
if (flag6)
|
||||
{
|
||||
_dragMode = EDragMode.ScaleXY;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag7 = flag4;
|
||||
if (flag7)
|
||||
{
|
||||
_dragMode = EDragMode.ScaleX;
|
||||
}
|
||||
else
|
||||
{
|
||||
var flag8 = flag5;
|
||||
if (flag8)
|
||||
{
|
||||
_dragMode = EDragMode.ScaleY;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dragMode = EDragMode.Drag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void BindCloseWindowBtn()
|
||||
{
|
||||
var orAddComponentInChildren = UITool.GetOrAddComponentInChildren<Button>("Btn_Close");
|
||||
var flag = orAddComponentInChildren != null;
|
||||
if (flag)
|
||||
{
|
||||
var component = orAddComponentInChildren.gameObject.GetComponent<Button>();
|
||||
component.onClick.AddListener(delegate
|
||||
{
|
||||
UIManager.SetActive(false);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("没有找到关闭按钮");
|
||||
}
|
||||
}
|
||||
private void BindCloseWindowBtn()
|
||||
{
|
||||
var orAddComponentInChildren = UITool.GetOrAddComponentInChildren<Button>("Btn_Close");
|
||||
var flag = orAddComponentInChildren != null;
|
||||
if (flag)
|
||||
{
|
||||
var component = orAddComponentInChildren.gameObject.GetComponent<Button>();
|
||||
component.onClick.AddListener(delegate
|
||||
{
|
||||
UIManager.SetActive(false);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("没有找到关闭按钮");
|
||||
}
|
||||
}
|
||||
|
||||
private static void TriggerAdd(EventTrigger trigger, EventTriggerType eventID, UnityAction<BaseEventData> callback)
|
||||
{
|
||||
var entry = new EventTrigger.Entry();
|
||||
entry.eventID = eventID;
|
||||
entry.callback.AddListener(callback);
|
||||
trigger.triggers.Add(entry);
|
||||
}
|
||||
private static void TriggerAdd(EventTrigger trigger, EventTriggerType eventID, UnityAction<BaseEventData> callback)
|
||||
{
|
||||
var entry = new EventTrigger.Entry();
|
||||
entry.eventID = eventID;
|
||||
entry.callback.AddListener(callback);
|
||||
trigger.triggers.Add(entry);
|
||||
}
|
||||
|
||||
private Vector2 _dragBias;
|
||||
private Vector2 _dragBias;
|
||||
|
||||
private Vector2 _sourceDragPoint;
|
||||
private Vector2 _sourceDragPoint;
|
||||
|
||||
private RectTransform _uRect;
|
||||
private RectTransform _uRect;
|
||||
|
||||
private EDragMode _dragMode = EDragMode.Drag;
|
||||
private EDragMode _dragMode = EDragMode.Drag;
|
||||
|
||||
private Rect _defaultRect;
|
||||
private Rect _defaultRect;
|
||||
|
||||
private enum EDragMode
|
||||
{
|
||||
Drag,
|
||||
ScaleX,
|
||||
ScaleY,
|
||||
ScaleXY
|
||||
}
|
||||
}
|
||||
private enum EDragMode
|
||||
{
|
||||
Drag,
|
||||
ScaleX,
|
||||
ScaleY,
|
||||
ScaleXY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
|
||||
<!--<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />-->
|
||||
<!--<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.*" />-->
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" /> -->
|
||||
<!-- <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.*" /> -->
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
|
||||
@@ -8,40 +8,40 @@ using XianTu.UI;
|
||||
|
||||
namespace XianTu
|
||||
{
|
||||
[BepInPlugin("me.GammaChineYov.plugin.Dyson.XianTu", "XianTu", "1.0.5")]
|
||||
internal class XianTuPlugin : BaseUnityPlugin
|
||||
{
|
||||
[BepInPlugin("me.GammaChineYov.plugin.Dyson.XianTu", "XianTu", "1.0.5")]
|
||||
internal class XianTuPlugin : BaseUnityPlugin
|
||||
{
|
||||
private static KeyCode HotKey => _hotKey.Value;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
_logger = Logger;
|
||||
_hotKey = Config.Bind("config", "HotKey", KeyCode.F2, "显示UI的快捷键");
|
||||
var abload = ABLoader.LoadFromEmbeddedAssets("xiantu");
|
||||
Singleton<LoadManager>.Instance.SetLoader(abload);
|
||||
Singleton<LoadManager>.Instance.AddLoader(new EmbeddedFileLoad());
|
||||
UIManager = new UIManager();
|
||||
UIManager.SetActive(false);
|
||||
UIManager.PanelManager.Push("BlueTuPatchUI");
|
||||
new BlueTuController();
|
||||
_logger.LogInfo("仙图加载完毕");
|
||||
}
|
||||
_hotKey = Config.Bind("config", "HotKey", KeyCode.F2, "显示UI的快捷键");
|
||||
var abload = ABLoader.LoadFromEmbeddedAssets("xiantu");
|
||||
Singleton<LoadManager>.Instance.SetLoader(abload);
|
||||
Singleton<LoadManager>.Instance.AddLoader(new EmbeddedFileLoad());
|
||||
UIManager = new UIManager();
|
||||
UIManager.SetActive(false);
|
||||
UIManager.PanelManager.Push("BlueTuPatchUI");
|
||||
new BlueTuController();
|
||||
_logger.LogInfo("仙图加载完毕");
|
||||
}
|
||||
|
||||
public UIManager UIManager { get; set; }
|
||||
public UIManager UIManager { get; set; }
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var keyDown = Input.GetKeyDown(HotKey);
|
||||
if (keyDown)
|
||||
{
|
||||
UIManager.SetActive(!UIManager.ActiveSelf);
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
var keyDown = Input.GetKeyDown(HotKey);
|
||||
if (keyDown)
|
||||
{
|
||||
UIManager.SetActive(!UIManager.ActiveSelf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static ManualLogSource _logger;
|
||||
|
||||
private static ConfigEntry<KeyCode> _hotKey;
|
||||
private static ConfigEntry<KeyCode> _hotKey;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,31 +5,31 @@ using XianTu.UI;
|
||||
|
||||
namespace XianTu
|
||||
{
|
||||
internal class XianTuTest : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
var abload = ABLoader.LoadFromFile("xiantu", "Assets/AB");
|
||||
Singleton<LoadManager>.Instance.SetLoader(abload);
|
||||
_canvas = new UIManager();
|
||||
cube = GameObject.Find("Cube");
|
||||
_canvas.PanelManager.Push("BlueTuPatchUI");
|
||||
var data = BlueTuUIData.Instance;
|
||||
var trans = cube.transform;
|
||||
BlueTuUIData.Instance.OnValueChange += delegate
|
||||
{
|
||||
trans.localScale = data.Scale;
|
||||
trans.position = data.Bias;
|
||||
trans.eulerAngles = new Vector3(0f, data.Rotate, 0f);
|
||||
};
|
||||
}
|
||||
internal class XianTuTest : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
var abload = ABLoader.LoadFromFile("xiantu", "Assets/AB");
|
||||
Singleton<LoadManager>.Instance.SetLoader(abload);
|
||||
_canvas = new UIManager();
|
||||
cube = GameObject.Find("Cube");
|
||||
_canvas.PanelManager.Push("BlueTuPatchUI");
|
||||
var data = BlueTuUIData.Instance;
|
||||
var trans = cube.transform;
|
||||
BlueTuUIData.Instance.OnValueChange += delegate
|
||||
{
|
||||
trans.localScale = data.Scale;
|
||||
trans.position = data.Bias;
|
||||
trans.eulerAngles = new Vector3(0f, data.Rotate, 0f);
|
||||
};
|
||||
}
|
||||
|
||||
private static void LoadTest()
|
||||
{
|
||||
var text = Path.Combine("Assets/XianTu/AB", "xiantu");
|
||||
var assetBundle = AssetBundle.LoadFromFile(text);
|
||||
var allAssetNames = assetBundle.GetAllAssetNames();
|
||||
foreach (var text2 in allAssetNames)
|
||||
private static void LoadTest()
|
||||
{
|
||||
var text = Path.Combine("Assets/XianTu/AB", "xiantu");
|
||||
var assetBundle = AssetBundle.LoadFromFile(text);
|
||||
var allAssetNames = assetBundle.GetAllAssetNames();
|
||||
foreach (var text2 in allAssetNames)
|
||||
{
|
||||
Debug.Log("全路径: " + text2);
|
||||
var text3 = text2.Substring(0, text2.IndexOf("prefabs"));
|
||||
@@ -45,24 +45,24 @@ namespace XianTu
|
||||
gameObject2.name = "路径: " + text4;
|
||||
}
|
||||
}
|
||||
Debug.Log("路径streamingAssetsPath:" + Application.streamingAssetsPath);
|
||||
Debug.Log("dataPath:" + Application.dataPath);
|
||||
Debug.Log("persistentDataPath:" + Application.persistentDataPath);
|
||||
}
|
||||
Debug.Log("路径streamingAssetsPath:" + Application.streamingAssetsPath);
|
||||
Debug.Log("dataPath:" + Application.dataPath);
|
||||
Debug.Log("persistentDataPath:" + Application.persistentDataPath);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var keyDown = Input.GetKeyDown(hotKey);
|
||||
if (keyDown)
|
||||
{
|
||||
_canvas.SetActive(!_canvas.ActiveSelf);
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
var keyDown = Input.GetKeyDown(hotKey);
|
||||
if (keyDown)
|
||||
{
|
||||
_canvas.SetActive(!_canvas.ActiveSelf);
|
||||
}
|
||||
}
|
||||
|
||||
private UIManager _canvas;
|
||||
|
||||
public KeyCode hotKey = KeyCode.F2;
|
||||
public KeyCode hotKey = KeyCode.F2;
|
||||
|
||||
public GameObject cube;
|
||||
}
|
||||
public GameObject cube;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user