特效处理

This commit is contained in:
2026-10-20 18:30:03 +08:00
parent 40bd235e67
commit bee2d42356
131 changed files with 837 additions and 456 deletions
@@ -0,0 +1,54 @@
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using TMPro;
using System.IO;
using System.Collections.Generic;
public class CollectPlayerNameChars : EditorWindow
{
[MenuItem("Tools/收集玩家名字字符(场景+预制体)")]
static void Collect()
{
HashSet<char> chars = new HashSet<char>();
// 1. 基础字符集
string baseChars = "一二三四五六七八九十" +
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789" +
"_-.,";
foreach (char c in baseChars) chars.Add(c);
// 2. 扫描所有场景
foreach (var scene in EditorBuildSettings.scenes)
{
if (!scene.enabled) continue;
var sceneObj = EditorSceneManager.OpenScene(scene.path);
foreach (var tmpText in Object.FindObjectsOfType<TMP_Text>())
{
foreach (char c in tmpText.text) chars.Add(c);
}
}
// 3. 扫描所有预制体
string[] prefabGuids = AssetDatabase.FindAssets("t:Prefab");
foreach (string guid in prefabGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
if (prefab == null) continue;
foreach (var tmpText in prefab.GetComponentsInChildren<TMP_Text>(true))
{
foreach (char c in tmpText.text) chars.Add(c);
}
}
// 4. 保存到文本文件
string savePath = Application.dataPath + "/player_name_chars.txt";
File.WriteAllText(savePath, new string(new List<char>(chars).ToArray()));
AssetDatabase.Refresh();
Debug.Log($"已收集 {chars.Count} 个字符,保存至:{savePath}");
}
}