From 64b9c02ef7e8eec3d2d201b00a8c1ae7f3bf15fc Mon Sep 17 00:00:00 2001
From: sin365 <353374337@qq.com>
Date: Wed, 25 Dec 2024 23:48:55 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BD=8E=E7=89=88=E6=9C=ACC#=E5=85=BC=E5=AE=B9?=
=?UTF-8?q?=20=E5=AE=8C=E5=96=84=E7=A7=BB=E6=A4=8D=E5=B7=A5=E5=85=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Editors/AxiProjectTools.cs | 55 +++-
.../Assets/Editors/CommandDispatcherEditor.cs | 6 +-
.../Assets/Plugins/AxiReplay/NetReplay.cs | 4 +-
.../Assets/Plugins/AxiReplay/ReplayWriter.cs | 260 +++++++++---------
.../SonyVitaCommonDialog.dll.meta | 89 +++++-
.../NesEmulator/NesControllerMapper.cs | 29 +-
.../AppMain/PSVita/SonyVitaCommonDialog.cs | 2 +-
7 files changed, 290 insertions(+), 155 deletions(-)
diff --git a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs
index bbb362b..73aa830 100644
--- a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs
+++ b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs
@@ -5,6 +5,7 @@ using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
+using UnityEngine.SceneManagement;
public class AxiProjectTools : EditorWindow
{
@@ -95,11 +96,6 @@ public class AxiProjectTools : EditorWindow
if (com == null)
continue;
- if (com.name.Contains("VideoPlayer"))
- {
-
- }
-
MonoBehaviour monoCom = com as MonoBehaviour;
if (monoCom == null)
continue;
@@ -262,11 +258,13 @@ public class AxiProjectTools : EditorWindow
}
- [MenuItem("Axibug移植工具/[5]UnPack所有预制体")]
+ [MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")]
public static void UnpackPrefabs()
{
- string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
+#if UNITY_2018_4_OR_NEWER
+ GoTAxiProjectToolsSence();
+ string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
int prefabCount = 0;
foreach (string path in allAssetPaths)
@@ -278,13 +276,41 @@ public class AxiProjectTools : EditorWindow
prefabCount++;
}
}
- Debug.Log($"Unpacked {prefabCount} prefabs.");
+ Debug.Log($"{prefabCount}个预制体Unpack");
- Debug.Log("处理完毕 [5]UnPack所有预制体");
- }
+ string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
+ foreach (string guid in sceneGuids)
+ {
+ string path = AssetDatabase.GUIDToAssetPath(guid);
+ if (path.Contains(toolSenceName))
+ continue;
- static void UnpackPrefab(string prefabPath)
+ EditorSceneManager.OpenScene(path);
+ Scene currentScene = SceneManager.GetActiveScene();
+ GameObject[] rootObjects = currentScene.GetRootGameObjects();
+ foreach (GameObject rootObj in rootObjects)
+ {
+ // 遍历场景中的所有对象
+ TraverseHierarchy(rootObj);
+ }
+ // Save the scene // 获取当前打开的场景
+ currentScene = EditorSceneManager.GetActiveScene();
+ // 保存场景到文件(默认路径和名称)
+ bool success = EditorSceneManager.SaveScene(currentScene, currentScene.path);
+
+ Debug.Log($"{currentScene.name}场景中 所有物体Unpack");
+ }
+
+ GoTAxiProjectToolsSence();
+ Debug.Log("处理完毕 [5]UnPack所有预制体");
+#else
+ Debug.Log("低版本不要执行本函数");
+#endif
+ }
+
+ static void UnpackPrefab(string prefabPath)
{
+#if UNITY_2018_4_OR_NEWER
GameObject prefabInstance = AssetDatabase.LoadAssetAtPath(prefabPath);
if (prefabInstance == null)
{
@@ -296,10 +322,14 @@ public class AxiProjectTools : EditorWindow
TraverseHierarchy(obj);
PrefabUtility.SaveAsPrefabAsset(obj, prefabPath);
GameObject.DestroyImmediate(obj);
+#else
+ Debug.Log("低版本不要执行本函数");
+#endif
}
static void TraverseHierarchy(GameObject obj)
{
+#if UNITY_2018_4_OR_NEWER
// 检查该对象是否是预制体的实例
if (PrefabUtility.IsPartOfPrefabInstance(obj))
{
@@ -313,6 +343,9 @@ public class AxiProjectTools : EditorWindow
{
TraverseHierarchy(obj.transform.GetChild(i).gameObject);
}
+#else
+ Debug.Log("低版本不要执行本函数");
+#endif
}
diff --git a/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs b/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs
index b4b4da7..7077016 100644
--- a/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs
+++ b/AxibugEmuOnline.Client/Assets/Editors/CommandDispatcherEditor.cs
@@ -1,6 +1,8 @@
锘縰sing AxibugEmuOnline.Client;
using UnityEditor;
using UnityEngine;
+using System.Collections.Generic;
+
namespace AxibugEmuOnline.Editors
{
[CustomEditor(typeof(CommandDispatcher))]
@@ -13,8 +15,8 @@ namespace AxibugEmuOnline.Editors
if (!Application.isPlaying) return;
var dispacather = target as CommandDispatcher;
-
- dispacather.GetRegisters(out var normal, out var solo);
+ IReadOnlyList normal; IReadOnlyList solo;
+ dispacather.GetRegisters(out normal, out solo);
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("NORMAL");
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
index 366ec90..29894d8 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
@@ -60,7 +60,7 @@ namespace AxiReplay
if (!bNetInit)
{
data = default(ReplayStep);
- frameDiff = default;
+ frameDiff = default(int);
inputDiff = false;
return false;
}
@@ -73,7 +73,7 @@ namespace AxiReplay
if (!bNetInit)
{
data = default(ReplayStep);
- frameDiff = default;
+ frameDiff = default(int);
inputDiff = false;
return false;
}
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/ReplayWriter.cs b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/ReplayWriter.cs
index a65f40d..950767e 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/ReplayWriter.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/ReplayWriter.cs
@@ -5,152 +5,154 @@ using System.Text;
namespace AxiReplay
{
- public class ReplayWriter : IReplayWriter
- {
- public ReplayData.ReplayFormat mFormat { get; private set; }
- public Encoding TexEncoding { get; private set; }
- ReplayHandler handler;
- string mTitle;
- string mNote;
- int mAllFrame;
- int mAllTime;
- long mData;
- int mSingleInputLenght;
- int mSingleDataLenght;
- MemoryStream mStream;
- BinaryWriter mBinaryWriter;
+ public class ReplayWriter : IReplayWriter
+ {
+ public ReplayData.ReplayFormat mFormat { get; private set; }
+ public Encoding TexEncoding { get; private set; }
+ ReplayHandler handler;
+ string mTitle;
+ string mNote;
+ int mAllFrame;
+ int mAllTime;
+ long mData;
+ int mSingleInputLenght;
+ int mSingleDataLenght;
+ MemoryStream mStream;
+ BinaryWriter mBinaryWriter;
- int mCurrFrame;
- UInt64 mCurrInput;
- ReplayStep wirteStep;
+ int mCurrFrame;
+ UInt64 mCurrInput;
+ ReplayStep wirteStep;
- List dbgList = new List();
+ List dbgList = new List();
- public ReplayWriter(string Title, string Note, ReplayData.ReplayFormat format, Encoding encoding)
- {
- mTitle = Title;
- mNote = Note;
- TexEncoding = encoding;
- mFormat = format;
- switch (mFormat)
- {
- case ReplayData.ReplayFormat.FM32IP64: mSingleInputLenght = sizeof(UInt64); break;
- case ReplayData.ReplayFormat.FM32IP32: mSingleInputLenght = sizeof(UInt32); break;
- case ReplayData.ReplayFormat.FM32IP16: mSingleInputLenght = sizeof(UInt16); break;
- case ReplayData.ReplayFormat.FM32IPBYTE: mSingleInputLenght = sizeof(byte); break;
- }
- mSingleDataLenght = (sizeof(UInt32)) + mSingleInputLenght;
+ public ReplayWriter(string Title, string Note, ReplayData.ReplayFormat format, Encoding encoding)
+ {
+ mTitle = Title;
+ mNote = Note;
+ TexEncoding = encoding;
+ mFormat = format;
+ switch (mFormat)
+ {
+ case ReplayData.ReplayFormat.FM32IP64: mSingleInputLenght = sizeof(UInt64); break;
+ case ReplayData.ReplayFormat.FM32IP32: mSingleInputLenght = sizeof(UInt32); break;
+ case ReplayData.ReplayFormat.FM32IP16: mSingleInputLenght = sizeof(UInt16); break;
+ case ReplayData.ReplayFormat.FM32IPBYTE: mSingleInputLenght = sizeof(byte); break;
+ }
+ mSingleDataLenght = (sizeof(UInt32)) + mSingleInputLenght;
- mStream = new MemoryStream();
- mBinaryWriter = new BinaryWriter(mStream);
+ mStream = new MemoryStream();
+ mBinaryWriter = new BinaryWriter(mStream);
- mCurrFrame = -1;
- mCurrInput = int.MaxValue;
- wirteStep = new ReplayStep();
+ mCurrFrame = -1;
+ mCurrInput = int.MaxValue;
+ wirteStep = new ReplayStep();
- dbgList.Clear();
+ dbgList.Clear();
- }
+ }
- int byFrameIdx = 0;
- ///
- /// 寰鍓嶆帹杩涘抚鐨,鎸囧畾甯т笅鏍
- ///
- ///
- public void NextFramebyFrameIdx(int FrameID, UInt64 frameInput)
- {
- TakeFrame(FrameID - byFrameIdx, frameInput);
- byFrameIdx = FrameID;
- }
+ int byFrameIdx = 0;
+ ///
+ /// 寰鍓嶆帹杩涘抚鐨,鎸囧畾甯т笅鏍
+ ///
+ ///
+ public void NextFramebyFrameIdx(int FrameID, UInt64 frameInput)
+ {
+ TakeFrame(FrameID - byFrameIdx, frameInput);
+ byFrameIdx = FrameID;
+ }
- ///
- /// 寰鍓嶆帹杩1甯х殑Input
- ///
- ///
- public void NextFrame(UInt64 frameInput)
- {
- TakeFrame(1, frameInput);
- }
+ ///
+ /// 寰鍓嶆帹杩1甯х殑Input
+ ///
+ ///
+ public void NextFrame(UInt64 frameInput)
+ {
+ TakeFrame(1, frameInput);
+ }
- ///
- /// 寰鍓嶆帹杩涙寚瀹氬抚鏁伴噺鐨処nput
- ///
- ///
- public void TakeFrame(int addFrame, UInt64 frameInput)
- {
- if (addFrame < 0)
- {
+ ///
+ /// 寰鍓嶆帹杩涙寚瀹氬抚鏁伴噺鐨処nput
+ ///
+ ///
+ public void TakeFrame(int addFrame, UInt64 frameInput)
+ {
+ if (addFrame < 0)
+ {
- }
- mCurrFrame += addFrame;
- if (mCurrInput == frameInput)
- return;
- mCurrInput = frameInput;
+ }
+ mCurrFrame += addFrame;
+ if (mCurrInput == frameInput)
+ return;
+ mCurrInput = frameInput;
- wirteStep.FrameStartID = mCurrFrame;
- wirteStep.InPut = mCurrInput;
- dbgList.Add($"{mCurrFrame} | {mCurrInput}");
+ wirteStep.FrameStartID = mCurrFrame;
+ wirteStep.InPut = mCurrInput;
+ dbgList.Add($"{mCurrFrame} | {mCurrInput}");
- switch (mFormat)
- {
- case ReplayData.ReplayFormat.FM32IP64:
- mBinaryWriter.Write(wirteStep.FrameStartID);
- mBinaryWriter.Write(wirteStep.InPut);
- break;
- case ReplayData.ReplayFormat.FM32IP32:
- mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 4);
- break;
- case ReplayData.ReplayFormat.FM32IP16:
- mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 2);
- break;
- case ReplayData.ReplayFormat.FM32IPBYTE:
- mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 1);
- break;
- }
- }
+ switch (mFormat)
+ {
+ case ReplayData.ReplayFormat.FM32IP64:
+ mBinaryWriter.Write(wirteStep.FrameStartID);
+ mBinaryWriter.Write(wirteStep.InPut);
+ break;
+ case ReplayData.ReplayFormat.FM32IP32:
+ mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 4);
+ break;
+ case ReplayData.ReplayFormat.FM32IP16:
+ mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 2);
+ break;
+ case ReplayData.ReplayFormat.FM32IPBYTE:
+ mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 1);
+ break;
+ }
+ }
- public void SaveData(string path, bool bWithDump = false, string dumppath = null)
- {
- ReplayData.GetStringByteData(mTitle, out byte[] titleData, out int titleLenghtWithEnd, TexEncoding);
- ReplayData.GetStringByteData(mNote, out byte[] noteData, out int noteLenghtWithEnd, TexEncoding);
+ public void SaveData(string path, bool bWithDump = false, string dumppath = null)
+ {
+ byte[] titleData; int titleLenghtWithEnd;
+ ReplayData.GetStringByteData(mTitle, out titleData, out titleLenghtWithEnd, TexEncoding);
+ byte[] noteData; int noteLenghtWithEnd;
+ ReplayData.GetStringByteData(mNote, out noteData, out noteLenghtWithEnd, TexEncoding);
- ReplayHandler handler = new ReplayHandler();
- handler.Format = (int)this.mFormat;
- handler.DataOffset = ReplayData.HandlerLenght;
- handler.CreateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
- handler.AllFrame = wirteStep.FrameStartID;
- handler.SingleLenght = mSingleDataLenght;
+ ReplayHandler handler = new ReplayHandler();
+ handler.Format = (int)this.mFormat;
+ handler.DataOffset = ReplayData.HandlerLenght;
+ handler.CreateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
+ handler.AllFrame = wirteStep.FrameStartID;
+ handler.SingleLenght = mSingleDataLenght;
- using (FileStream fs = new FileStream(path, FileMode.Create))
- {
- using (BinaryWriter bw = new BinaryWriter(fs))
- {
- //鍐欏叆Handler
- bw.Write(ReplayData.GetHandlerData(handler));
- //鍐欏叆Data
- bw.Write(mStream.ToArray());
- }
- }
+ using (FileStream fs = new FileStream(path, FileMode.Create))
+ {
+ using (BinaryWriter bw = new BinaryWriter(fs))
+ {
+ //鍐欏叆Handler
+ bw.Write(ReplayData.GetHandlerData(handler));
+ //鍐欏叆Data
+ bw.Write(mStream.ToArray());
+ }
+ }
- if (bWithDump)
- {
- List temp = new List();
- temp.Add($"Format => {handler.Format}");
- temp.Add($"DataOffset => {handler.DataOffset}");
- temp.Add($"CreateTime => {handler.CreateTime}");
- temp.Add($"AllFrame => {handler.AllFrame}");
- temp.Add($"SingleLenght => {handler.SingleLenght}");
- dbgList.InsertRange(0, temp);
- File.WriteAllLines(dumppath, dbgList);
- }
- }
+ if (bWithDump)
+ {
+ List temp = new List();
+ temp.Add($"Format => {handler.Format}");
+ temp.Add($"DataOffset => {handler.DataOffset}");
+ temp.Add($"CreateTime => {handler.CreateTime}");
+ temp.Add($"AllFrame => {handler.AllFrame}");
+ temp.Add($"SingleLenght => {handler.SingleLenght}");
+ dbgList.InsertRange(0, temp);
+ File.WriteAllLines(dumppath, dbgList);
+ }
+ }
- public void Dispose()
- {
- mStream.Dispose();
- mBinaryWriter.Dispose();
- //TODO
- }
+ public void Dispose()
+ {
+ mStream.Dispose();
+ mBinaryWriter.Dispose();
+ //TODO
+ }
- }
+ }
}
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/PSVita/SonyAssemblies/SonyVitaCommonDialog.dll.meta b/AxibugEmuOnline.Client/Assets/Plugins/PSVita/SonyAssemblies/SonyVitaCommonDialog.dll.meta
index 4584fa5..ec3ff35 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/PSVita/SonyAssemblies/SonyVitaCommonDialog.dll.meta
+++ b/AxibugEmuOnline.Client/Assets/Plugins/PSVita/SonyAssemblies/SonyVitaCommonDialog.dll.meta
@@ -1,7 +1,92 @@
fileFormatVersion: 2
guid: eb76ae7b43c117c449fe04e536cf3f34
-MonoAssemblyImporter:
- serializedVersion: 1
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
iconMap: {}
executionOrder: {}
+ isPreloaded: 0
+ isOverridable: 0
+ platformData:
+ - first:
+ '': Any
+ second:
+ enabled: 0
+ settings:
+ Exclude Editor: 0
+ Exclude Linux: 1
+ Exclude Linux64: 1
+ Exclude LinuxUniversal: 1
+ Exclude OSXUniversal: 1
+ Exclude PSP2: 0
+ Exclude Win: 1
+ Exclude Win64: 1
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ DefaultValueInitialized: true
+ OS: AnyOS
+ - first:
+ Facebook: Win
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ - first:
+ Facebook: Win64
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ - first:
+ PSP2: PSP2
+ second:
+ enabled: 1
+ settings: {}
+ - first:
+ Standalone: Linux
+ second:
+ enabled: 0
+ settings:
+ CPU: x86
+ - first:
+ Standalone: Linux64
+ second:
+ enabled: 0
+ settings:
+ CPU: x86_64
+ - first:
+ Standalone: OSXUniversal
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ - first:
+ Standalone: Win
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ - first:
+ Standalone: Win64
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ - first:
+ Windows Store Apps: WindowsStoreApps
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs
index 23b6e8f..6813d06 100644
--- a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesControllerMapper.cs
@@ -64,7 +64,9 @@ namespace AxibugEmuOnline.Client
else return null;
}
- static HashSet s_temp = new HashSet(4);
+ //static HashSet s_temp = new HashSet(4);
+ //浣庣増鏈笉鑳借繖鏍峰垵濮嬪寲
+ static HashSet s_temp = new HashSet();
public uint? GetFreeSlotIndex()
{
s_temp.Clear();
@@ -84,14 +86,25 @@ namespace AxibugEmuOnline.Client
public void LetControllerConnect(int conIndex, uint slotIndex)
{
- var targetController = conIndex switch
+ Controller targetController;
+ switch (conIndex)
{
- 0 => Controller0,
- 1 => Controller1,
- 2 => Controller2,
- 3 => Controller3,
- _ => throw new System.Exception($"Not Allowed conIndex Range: {conIndex}")
- };
+ case 0: targetController = Controller0;break;
+ case 1: targetController = Controller1; break;
+ case 2: targetController = Controller2; break;
+ case 3: targetController = Controller3; break;
+ default:
+ throw new System.Exception($"Not Allowed conIndex Range: {conIndex}");
+ break;
+ }
+ //var targetController = conIndex switch
+ //{
+ // 0 => Controller0,
+ // 1 => Controller1,
+ // 2 => Controller2,
+ // 3 => Controller3,
+ // _ => throw new System.Exception($"Not Allowed conIndex Range: {conIndex}")
+ //};
if (targetController.ConnectSlot.HasValue) return;
diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/PSVita/SonyVitaCommonDialog.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/PSVita/SonyVitaCommonDialog.cs
index 66de300..dd8420d 100644
--- a/AxibugEmuOnline.Client/Assets/Script/AppMain/PSVita/SonyVitaCommonDialog.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/PSVita/SonyVitaCommonDialog.cs
@@ -44,7 +44,7 @@ public class SonyVitaCommonDialog : MonoBehaviour
Debug.Log("IME text: " + result.text);
if (result.result == Sony.Vita.Dialog.Ime.EnumImeDialogResult.RESULT_OK)
{
- resultAct.Invoke(result);
+ resultAct.Invoke(result.text);
resultAct = null;
}
}