低版本C#兼容 完善移植工具

This commit is contained in:
sin365 2024-12-25 23:48:55 +08:00
parent dc9d42de5c
commit 64b9c02ef7
7 changed files with 290 additions and 155 deletions

View File

@ -5,6 +5,7 @@ using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEditor.SceneManagement; using UnityEditor.SceneManagement;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
public class AxiProjectTools : EditorWindow public class AxiProjectTools : EditorWindow
{ {
@ -95,11 +96,6 @@ public class AxiProjectTools : EditorWindow
if (com == null) if (com == null)
continue; continue;
if (com.name.Contains("VideoPlayer"))
{
}
MonoBehaviour monoCom = com as MonoBehaviour; MonoBehaviour monoCom = com as MonoBehaviour;
if (monoCom == null) if (monoCom == null)
continue; continue;
@ -262,10 +258,12 @@ public class AxiProjectTools : EditorWindow
} }
[MenuItem("Axibug移植工具/[5]UnPack所有预制体")] [MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")]
public static void UnpackPrefabs() public static void UnpackPrefabs()
{ {
#if UNITY_2018_4_OR_NEWER
GoTAxiProjectToolsSence();
string[] allAssetPaths = AssetDatabase.GetAllAssetPaths(); string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
int prefabCount = 0; int prefabCount = 0;
@ -278,13 +276,41 @@ public class AxiProjectTools : EditorWindow
prefabCount++; prefabCount++;
} }
} }
Debug.Log($"Unpacked {prefabCount} prefabs."); Debug.Log($"{prefabCount}个预制体Unpack");
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
foreach (string guid in sceneGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(toolSenceName))
continue;
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("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>"); Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
#else
Debug.Log("低版本不要执行本函数");
#endif
} }
static void UnpackPrefab(string prefabPath) static void UnpackPrefab(string prefabPath)
{ {
#if UNITY_2018_4_OR_NEWER
GameObject prefabInstance = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath); GameObject prefabInstance = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
if (prefabInstance == null) if (prefabInstance == null)
{ {
@ -296,10 +322,14 @@ public class AxiProjectTools : EditorWindow
TraverseHierarchy(obj); TraverseHierarchy(obj);
PrefabUtility.SaveAsPrefabAsset(obj, prefabPath); PrefabUtility.SaveAsPrefabAsset(obj, prefabPath);
GameObject.DestroyImmediate(obj); GameObject.DestroyImmediate(obj);
#else
Debug.Log("低版本不要执行本函数");
#endif
} }
static void TraverseHierarchy(GameObject obj) static void TraverseHierarchy(GameObject obj)
{ {
#if UNITY_2018_4_OR_NEWER
// 检查该对象是否是预制体的实例 // 检查该对象是否是预制体的实例
if (PrefabUtility.IsPartOfPrefabInstance(obj)) if (PrefabUtility.IsPartOfPrefabInstance(obj))
{ {
@ -313,6 +343,9 @@ public class AxiProjectTools : EditorWindow
{ {
TraverseHierarchy(obj.transform.GetChild(i).gameObject); TraverseHierarchy(obj.transform.GetChild(i).gameObject);
} }
#else
Debug.Log("低版本不要执行本函数");
#endif
} }

View File

@ -1,6 +1,8 @@
using AxibugEmuOnline.Client; using AxibugEmuOnline.Client;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections.Generic;
namespace AxibugEmuOnline.Editors namespace AxibugEmuOnline.Editors
{ {
[CustomEditor(typeof(CommandDispatcher))] [CustomEditor(typeof(CommandDispatcher))]
@ -13,8 +15,8 @@ namespace AxibugEmuOnline.Editors
if (!Application.isPlaying) return; if (!Application.isPlaying) return;
var dispacather = target as CommandDispatcher; var dispacather = target as CommandDispatcher;
IReadOnlyList<CommandExecuter> normal; IReadOnlyList<CommandExecuter> solo;
dispacather.GetRegisters(out var normal, out var solo); dispacather.GetRegisters(out normal, out solo);
EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("NORMAL"); EditorGUILayout.LabelField("NORMAL");

View File

@ -60,7 +60,7 @@ namespace AxiReplay
if (!bNetInit) if (!bNetInit)
{ {
data = default(ReplayStep); data = default(ReplayStep);
frameDiff = default; frameDiff = default(int);
inputDiff = false; inputDiff = false;
return false; return false;
} }
@ -73,7 +73,7 @@ namespace AxiReplay
if (!bNetInit) if (!bNetInit)
{ {
data = default(ReplayStep); data = default(ReplayStep);
frameDiff = default; frameDiff = default(int);
inputDiff = false; inputDiff = false;
return false; return false;
} }

View File

@ -111,8 +111,10 @@ namespace AxiReplay
public void SaveData(string path, bool bWithDump = false, string dumppath = null) public void SaveData(string path, bool bWithDump = false, string dumppath = null)
{ {
ReplayData.GetStringByteData(mTitle, out byte[] titleData, out int titleLenghtWithEnd, TexEncoding); byte[] titleData; int titleLenghtWithEnd;
ReplayData.GetStringByteData(mNote, out byte[] noteData, out int noteLenghtWithEnd, TexEncoding); ReplayData.GetStringByteData(mTitle, out titleData, out titleLenghtWithEnd, TexEncoding);
byte[] noteData; int noteLenghtWithEnd;
ReplayData.GetStringByteData(mNote, out noteData, out noteLenghtWithEnd, TexEncoding);
ReplayHandler handler = new ReplayHandler(); ReplayHandler handler = new ReplayHandler();
handler.Format = (int)this.mFormat; handler.Format = (int)this.mFormat;

View File

@ -1,7 +1,92 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: eb76ae7b43c117c449fe04e536cf3f34 guid: eb76ae7b43c117c449fe04e536cf3f34
MonoAssemblyImporter: PluginImporter:
serializedVersion: 1 externalObjects: {}
serializedVersion: 2
iconMap: {} iconMap: {}
executionOrder: {} 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: userData:
assetBundleName:
assetBundleVariant:

View File

@ -64,7 +64,9 @@ namespace AxibugEmuOnline.Client
else return null; else return null;
} }
static HashSet<uint> s_temp = new HashSet<uint>(4); //static HashSet<uint> s_temp = new HashSet<uint>(4);
//低版本不能这样初始化
static HashSet<uint> s_temp = new HashSet<uint>();
public uint? GetFreeSlotIndex() public uint? GetFreeSlotIndex()
{ {
s_temp.Clear(); s_temp.Clear();
@ -84,14 +86,25 @@ namespace AxibugEmuOnline.Client
public void LetControllerConnect(int conIndex, uint slotIndex) public void LetControllerConnect(int conIndex, uint slotIndex)
{ {
var targetController = conIndex switch Controller targetController;
switch (conIndex)
{ {
0 => Controller0, case 0: targetController = Controller0;break;
1 => Controller1, case 1: targetController = Controller1; break;
2 => Controller2, case 2: targetController = Controller2; break;
3 => Controller3, case 3: targetController = Controller3; break;
_ => throw new System.Exception($"Not Allowed conIndex Range: {conIndex}") 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; if (targetController.ConnectSlot.HasValue) return;

View File

@ -44,7 +44,7 @@ public class SonyVitaCommonDialog : MonoBehaviour
Debug.Log("IME text: " + result.text); Debug.Log("IME text: " + result.text);
if (result.result == Sony.Vita.Dialog.Ime.EnumImeDialogResult.RESULT_OK) if (result.result == Sony.Vita.Dialog.Ime.EnumImeDialogResult.RESULT_OK)
{ {
resultAct.Invoke(result); resultAct.Invoke(result.text);
resultAct = null; resultAct = null;
} }
} }