您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

32 行
992 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class GraphicTestTools
{
[MenuItem("GraphicTest Tools/Make Material Scene Instance")]
public static void MakeMaterialSceneInstance()
{
foreach(Object obj in Selection.objects)
{
Renderer rndr = ((GameObject)obj).GetComponent<Renderer>();
if(rndr!=null)
{
Material[] mats = rndr.sharedMaterials;
for (int i=0; i< mats.Length; ++i)
{
if (mats[i] != null)
{
//Debug.Log("Instantiate materal " + rndr.sharedMaterials[i].ToString() + " of object " + rndr.gameObject.name);
Material mat = Object.Instantiate(rndr.sharedMaterials[i]);
mats[i] = mat;
}
}
rndr.sharedMaterials = mats;
}
}
}
}