【材质检查】增加材质检查
parent
3eb13f87ec
commit
12dc9e46e0
|
|
@ -1 +1 @@
|
|||
Subproject commit 1ca8c2bcb2cbbb3d08af9d4735f30c4f690fb7e7
|
||||
Subproject commit e9a71f9687a5bded7d4d003abf3198d835527614
|
||||
|
|
@ -14,7 +14,37 @@ using UnityFS;
|
|||
public class TestCode: Editor
|
||||
{
|
||||
|
||||
[MenuItem("Test/测试")]
|
||||
// [MenuItem("GameObject/LTTest/检查材质路径", false, 0)]
|
||||
public static void Test6()
|
||||
{
|
||||
Object selectObj = Selection.activeObject;
|
||||
if (null == selectObj)
|
||||
{
|
||||
DebugUtil.Log("尚未选择任何对象");
|
||||
return;
|
||||
}
|
||||
var selectGo = selectObj as GameObject;
|
||||
if (selectGo == null)
|
||||
{
|
||||
DebugUtil.Log("选择的对象不是GameObject类型");
|
||||
return;
|
||||
}
|
||||
var render = selectGo.GetComponent<Renderer>();
|
||||
var materials = render.sharedMaterials;
|
||||
if (materials == null || materials.Length == 0)
|
||||
{
|
||||
DebugUtil.LogError("渲染器没有材质:" + selectGo.name);
|
||||
return;
|
||||
}
|
||||
foreach (var mat in materials)
|
||||
{
|
||||
var materialPath = AssetDatabase.GetAssetPath(mat);
|
||||
DebugUtil.LogError("材质路径:" + materialPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// [MenuItem("Test/测试")]
|
||||
public static void Test5()
|
||||
{
|
||||
var checkPath = "Art/Grass01/FlowerGroup_2 (8)";
|
||||
|
|
|
|||
Loading…
Reference in New Issue