修复编译错误
This commit is contained in:
parent
62fbb6e11b
commit
7b29000a70
@ -1,4 +1,4 @@
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class AxiProjectTools : EditorWindow
|
||||
{
|
||||
@ -28,7 +29,7 @@ public class AxiProjectTools : EditorWindow
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Axibug移植工具/[1]采集所有预制体和场景下的UGUI组件")]
|
||||
[MenuItem("Axibug移植工具/[1]采集所有预制体和场景下的UGUI组件")]
|
||||
public static void Part1()
|
||||
{
|
||||
GoTAxiProjectToolsSence();
|
||||
@ -42,17 +43,17 @@ public class AxiProjectTools : EditorWindow
|
||||
|
||||
EditorSceneManager.OpenScene(path);
|
||||
|
||||
// 创建一个列表来存储根节点
|
||||
// 创建一个列表来存储根节点
|
||||
List<GameObject> rootNodes = new List<GameObject>();
|
||||
|
||||
// 遍历场景中的所有对象
|
||||
// 遍历场景中的所有对象
|
||||
GameObject[] allObjects = FindObjectsOfType<GameObject>();
|
||||
foreach (GameObject obj in allObjects)
|
||||
{
|
||||
// 检查对象是否有父对象
|
||||
// 检查对象是否有父对象
|
||||
if (obj.transform.parent == null)
|
||||
{
|
||||
// 如果没有父对象,则它是一个根节点
|
||||
// 如果没有父对象,则它是一个根节点
|
||||
rootNodes.Add(obj);
|
||||
}
|
||||
}
|
||||
@ -76,7 +77,7 @@ public class AxiProjectTools : EditorWindow
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
GoTAxiProjectToolsSence();
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [1]采集所有预制体和场景下的UGUI组件</color>");
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [1]采集所有预制体和场景下的UGUI组件</color>");
|
||||
}
|
||||
|
||||
static void GetPrefab(string path)
|
||||
@ -102,11 +103,11 @@ public class AxiProjectTools : EditorWindow
|
||||
Type monoType = monoCom.GetType();
|
||||
if (!monoType.Assembly.FullName.Contains("UnityEngine.UI"))
|
||||
continue;
|
||||
// 获取MonoScript资源
|
||||
// 获取MonoScript资源
|
||||
MonoScript monoScript = MonoScript.FromMonoBehaviour(monoCom);
|
||||
if (monoScript != null)
|
||||
{
|
||||
// 获取MonoScript资源的GUID
|
||||
// 获取MonoScript资源的GUID
|
||||
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(monoScript));
|
||||
Debug.Log($"{nodename} | <color=#FFF333>[{monoType.Name}]</color> <color=#FF0000>{guid}</color><color=#00FF00>({monoType.FullName})</color>");
|
||||
ComType2GUID[monoType.FullName] =
|
||||
@ -119,19 +120,19 @@ public class AxiProjectTools : EditorWindow
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("!!!! 没得");
|
||||
Debug.LogError("!!!! 没得");
|
||||
}
|
||||
}
|
||||
|
||||
//遍历
|
||||
//遍历
|
||||
foreach (Transform child in trans.transform)
|
||||
LoopPrefabNode(nodename, child.gameObject, depth + 1);
|
||||
#else
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
#endif
|
||||
}
|
||||
|
||||
[MenuItem("Axibug移植工具/[2]生成中间脚本代码")]
|
||||
[MenuItem("Axibug移植工具/[2]生成中间脚本代码")]
|
||||
public static void Part2()
|
||||
{
|
||||
if (UnityEngine.Windows.Directory.Exists(outCsDir))
|
||||
@ -151,16 +152,16 @@ public class AxiProjectTools : EditorWindow
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError("写入失败" + ex.ToString());
|
||||
Debug.LogError("写入失败" + ex.ToString());
|
||||
}
|
||||
}
|
||||
Debug.Log("写入完毕");
|
||||
Debug.Log("写入完毕");
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [2]生成中间脚本代码</color>");
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [2]生成中间脚本代码</color>");
|
||||
}
|
||||
|
||||
[MenuItem("Axibug移植工具/[3]收集生成的脚本")]
|
||||
[MenuItem("Axibug移植工具/[3]收集生成的脚本")]
|
||||
public static void Part3()
|
||||
{
|
||||
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
|
||||
@ -170,17 +171,17 @@ public class AxiProjectTools : EditorWindow
|
||||
MonoScript monoScript = allMonoScripts.FirstOrDefault(w => w.name == data.ToName);
|
||||
if (monoScript == null)
|
||||
{
|
||||
Debug.LogError("没找到" + data.ToName);
|
||||
Debug.LogError("没找到" + data.ToName);
|
||||
continue;
|
||||
}
|
||||
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(monoScript));
|
||||
data.ToGUID = guid;
|
||||
data.monoScript = monoScript;
|
||||
}
|
||||
Debug.Log("写入完毕");
|
||||
Debug.Log("写入完毕");
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [3]收集生成的脚本</color>");
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [3]收集生成的脚本</color>");
|
||||
}
|
||||
|
||||
static List<T> FindAllAssetsOfType<T>() where T : UnityEngine.Object
|
||||
@ -191,7 +192,7 @@ public class AxiProjectTools : EditorWindow
|
||||
foreach (string guid in allGuids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
if (path.EndsWith(".cs") || path.EndsWith(".js") || path.EndsWith(".boo")) // Unity支持多种脚本语言,但现代Unity主要使用C#
|
||||
if (path.EndsWith(".cs") || path.EndsWith(".js") || path.EndsWith(".boo")) // Unity支持多种脚本语言,但现代Unity主要使用C#
|
||||
{
|
||||
T asset = AssetDatabase.LoadAssetAtPath<T>(path);
|
||||
if (asset != null)
|
||||
@ -204,7 +205,7 @@ public class AxiProjectTools : EditorWindow
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("Axibug移植工具/[4]替换所有预制体和场景中的组件")]
|
||||
[MenuItem("Axibug移植工具/[4]替换所有预制体和场景中的组件")]
|
||||
public static void Part4()
|
||||
{
|
||||
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
|
||||
@ -218,7 +219,7 @@ public class AxiProjectTools : EditorWindow
|
||||
ProcessAllPrefabs("*.anim", tempReplaceDict);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [4]替换所有预制体和场景中的组件</color>");
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [4]替换所有预制体和场景中的组件</color>");
|
||||
}
|
||||
|
||||
static void ProcessAllPrefabs(string form, Dictionary<string, string> tempReplaceDict, bool reverse = false)
|
||||
@ -235,15 +236,15 @@ public class AxiProjectTools : EditorWindow
|
||||
string newValue = reverse ? VARIABLE.Key : VARIABLE.Value;
|
||||
ReplaceValue(absolutePaths[i], oldValue, newValue);
|
||||
}
|
||||
EditorUtility.DisplayProgressBar("处理预制体……", "处理预制体中……", (float)i / absolutePaths.Length);
|
||||
EditorUtility.DisplayProgressBar("处理预制体……", "处理预制体中……", (float)i / absolutePaths.Length);
|
||||
}
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换值
|
||||
/// 替换值
|
||||
/// </summary>
|
||||
/// <param name="strFilePath">文件路径</param>
|
||||
/// <param name="strFilePath">文件路径</param>
|
||||
static void ReplaceValue(string strFilePath, string oldLine, string newLine)
|
||||
{
|
||||
if (File.Exists(strFilePath))
|
||||
@ -258,7 +259,7 @@ public class AxiProjectTools : EditorWindow
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")]
|
||||
[MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")]
|
||||
public static void UnpackPrefabs()
|
||||
{
|
||||
|
||||
@ -276,7 +277,7 @@ public class AxiProjectTools : EditorWindow
|
||||
prefabCount++;
|
||||
}
|
||||
}
|
||||
Debug.Log($"{prefabCount}个预制体Unpack");
|
||||
Debug.Log($"{prefabCount}个预制体Unpack");
|
||||
|
||||
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
|
||||
foreach (string guid in sceneGuids)
|
||||
@ -290,21 +291,21 @@ public class AxiProjectTools : EditorWindow
|
||||
GameObject[] rootObjects = currentScene.GetRootGameObjects();
|
||||
foreach (GameObject rootObj in rootObjects)
|
||||
{
|
||||
// 遍历场景中的所有对象
|
||||
// 遍历场景中的所有对象
|
||||
TraverseHierarchy(rootObj);
|
||||
}
|
||||
// Save the scene // 获取当前打开的场景
|
||||
// Save the scene // 获取当前打开的场景
|
||||
currentScene = EditorSceneManager.GetActiveScene();
|
||||
// 保存场景到文件(默认路径和名称)
|
||||
// 保存场景到文件(默认路径和名称)
|
||||
bool success = EditorSceneManager.SaveScene(currentScene, currentScene.path);
|
||||
|
||||
Debug.Log($"{currentScene.name}场景中 所有物体Unpack");
|
||||
Debug.Log($"{currentScene.name}场景中 所有物体Unpack");
|
||||
}
|
||||
|
||||
GoTAxiProjectToolsSence();
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
|
||||
#else
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -323,33 +324,33 @@ public class AxiProjectTools : EditorWindow
|
||||
PrefabUtility.SaveAsPrefabAsset(obj, prefabPath);
|
||||
GameObject.DestroyImmediate(obj);
|
||||
#else
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void TraverseHierarchy(GameObject obj)
|
||||
{
|
||||
#if UNITY_2018_4_OR_NEWER
|
||||
// 检查该对象是否是预制体的实例
|
||||
// 检查该对象是否是预制体的实例
|
||||
if (PrefabUtility.IsPartOfPrefabInstance(obj))
|
||||
{
|
||||
// 将预制体实例转换为普通游戏对象
|
||||
// 将预制体实例转换为普通游戏对象
|
||||
PrefabUtility.UnpackPrefabInstance(obj, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
|
||||
Debug.Log("Prefab instance converted to game object: " + obj.name);
|
||||
}
|
||||
|
||||
// 递归遍历子对象
|
||||
// 递归遍历子对象
|
||||
for (int i = 0; i < obj.transform.childCount; i++)
|
||||
{
|
||||
TraverseHierarchy(obj.transform.GetChild(i).gameObject);
|
||||
}
|
||||
#else
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
Debug.Log("低版本不要执行本函数");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("Axibug移植工具/[6]修复Sprite")]
|
||||
[MenuItem("Axibug移植工具/[6]修复Sprite")]
|
||||
public static void FixMultipleMaterialSprites()
|
||||
{
|
||||
string[] guids = AssetDatabase.FindAssets("t:sprite");
|
||||
@ -360,7 +361,7 @@ public class AxiProjectTools : EditorWindow
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
||||
|
||||
// 检查是否有多个材质
|
||||
// 检查是否有多个材质
|
||||
if (IsUsingMultipleMaterials(sprite))
|
||||
{
|
||||
spritesToFix.Add(sprite);
|
||||
@ -368,7 +369,7 @@ public class AxiProjectTools : EditorWindow
|
||||
}
|
||||
}
|
||||
|
||||
// 修复每个找到的Sprite
|
||||
// 修复每个找到的Sprite
|
||||
foreach (var sprite in spritesToFix)
|
||||
{
|
||||
FixSprite(sprite);
|
||||
@ -376,14 +377,14 @@ public class AxiProjectTools : EditorWindow
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [6]修复Sprite</color>");
|
||||
Debug.Log("<Color=#FFF333>处理完毕 [6]修复Sprite</color>");
|
||||
}
|
||||
|
||||
private static bool IsUsingMultipleMaterials(Sprite sprite)
|
||||
{
|
||||
if (sprite == null) return false;
|
||||
|
||||
// 获取精灵的材质
|
||||
// 获取精灵的材质
|
||||
var textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(sprite)) as TextureImporter;
|
||||
|
||||
return textureImporter != null && textureImporter.spriteImportMode == SpriteImportMode.Multiple;
|
||||
@ -391,24 +392,24 @@ public class AxiProjectTools : EditorWindow
|
||||
|
||||
private static void FixSprite(Sprite sprite)
|
||||
{
|
||||
// 获取Sprite的路径
|
||||
// 获取Sprite的路径
|
||||
string path = AssetDatabase.GetAssetPath(sprite);
|
||||
var textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
|
||||
if (textureImporter != null)
|
||||
{
|
||||
// 保存当前切割信息
|
||||
// 保存当前切割信息
|
||||
SpriteMetaData[] originalMetaData = textureImporter.spritesheet;
|
||||
|
||||
// 临时禁用Sprite导入
|
||||
// 临时禁用Sprite导入
|
||||
textureImporter.spriteImportMode = SpriteImportMode.None;
|
||||
textureImporter.SaveAndReimport();
|
||||
|
||||
// 重新启用Sprite导入并保持原样切割参数
|
||||
// 重新启用Sprite导入并保持原样切割参数
|
||||
textureImporter.spriteImportMode = SpriteImportMode.Multiple;
|
||||
textureImporter.spritesheet = originalMetaData; // 恢复原来的切割信息
|
||||
textureImporter.spritesheet = originalMetaData; // 恢复原来的切割信息
|
||||
|
||||
// 重新导入以应用更改
|
||||
// 重新导入以应用更改
|
||||
textureImporter.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
|
@ -46,14 +46,12 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
//result = RenderTexture.GetTemporary(Screen.width, Screen.height);
|
||||
result = Initer.instance.renderTest;
|
||||
result = RenderTexture.GetTemporary(Screen.width, Screen.height);
|
||||
}
|
||||
else if (result.width != Screen.width || result.height != Screen.height)
|
||||
{
|
||||
//RenderTexture.ReleaseTemporary(result);
|
||||
//result = RenderTexture.GetTemporary(Screen.width, Screen.height);
|
||||
result = Initer.instance.renderTest;
|
||||
RenderTexture.ReleaseTemporary(result);
|
||||
result = RenderTexture.GetTemporary(Screen.width, Screen.height);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user