81 lines
3.2 KiB
C#
81 lines
3.2 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Text;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
|
||
namespace PolyReduction
|
||
{
|
||
/// <summary>
|
||
/// 所有菜单项都从这里出口
|
||
/// </summary>
|
||
public class ClearFbxUvClrMenuItems
|
||
{
|
||
//任务配置检测的菜单
|
||
[MenuItem("Funcell/清楚Fbx顶点Color和Uv属性", false, 900)]
|
||
public static void Start()
|
||
{
|
||
StringBuilder sb = new StringBuilder();
|
||
string exeFullPath = System.Environment.CurrentDirectory;
|
||
exeFullPath = exeFullPath.Replace("Client\\Main", "Tool\\ClearUvClr");
|
||
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
|
||
psi.FileName = exeFullPath + "\\ClearUv_Clr.exe";
|
||
|
||
string RootPath = Application.dataPath;
|
||
RootPath = RootPath.Substring(0, RootPath.LastIndexOf("/")) + "/";
|
||
var allFbx = AssetDatabase.FindAssets("t:Model");
|
||
int index = 0;
|
||
for (int i = 0; i < allFbx.Length; i++)
|
||
{
|
||
string fbxPath = AssetDatabase.GUIDToAssetPath(allFbx[i]);
|
||
if (fbxPath.Contains(" "))
|
||
{
|
||
Debug.LogError(string.Format("Path:{0}-----有空格处理不了!!!!", fbxPath));
|
||
continue;
|
||
}
|
||
var assets = AssetDatabase.LoadAllAssetsAtPath(fbxPath);
|
||
if (assets != null)
|
||
{
|
||
bool bNeedAdd = false;
|
||
bool bNeedColor = false;
|
||
for (int j = 0; j < assets.Length; ++j)
|
||
{
|
||
var mesh = assets[j] as Mesh;
|
||
if (mesh != null)
|
||
{
|
||
if (mesh.uv3.Length != 0 || mesh.uv4.Length != 0
|
||
|| mesh.uv5.Length != 0
|
||
|| mesh.uv6.Length != 0
|
||
|| mesh.uv7.Length != 0
|
||
|| mesh.uv8.Length != 0)
|
||
{
|
||
bNeedAdd = true;
|
||
}
|
||
if (!fbxPath.Contains("_color"))
|
||
{
|
||
if (mesh.colors.Length != 0)
|
||
{
|
||
bNeedColor = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (bNeedAdd)
|
||
{
|
||
//exe里会处理参数,空格前的是输入的路径,空格后的是fbx输出的路径
|
||
string arg1 = bNeedAdd ? "1" : "0";
|
||
string arg2 = bNeedColor ? "1" : "0";
|
||
string src = RootPath + fbxPath;
|
||
sb.Append(" " + src + " " + arg1 + " " + arg2);
|
||
index += 1;
|
||
}
|
||
}
|
||
}
|
||
string str = string.Format("{0}{1}", index, sb.ToString());
|
||
psi.Arguments = str;
|
||
System.Diagnostics.Process.Start(psi);
|
||
}
|
||
}
|
||
}
|