您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
43 行
1.3 KiB
43 行
1.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
public class GraphicTestTools
|
|
{
|
|
[MenuItem("Internal/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;
|
|
}
|
|
}
|
|
}
|
|
|
|
[MenuItem("Internal/GraphicTest Tools/Update All Material Placers")]
|
|
public static void UpdateAllPlacers()
|
|
{
|
|
MultiMaterialPlacer[] placers = Object.FindObjectsOfType<MultiMaterialPlacer>();
|
|
|
|
for (int i=0; i<placers.Length; ++i)
|
|
{
|
|
MultiMaterialPlacerEditor.PlaceObjects(placers[i]);
|
|
}
|
|
}
|
|
}
|