您的位置:首页 > 移动开发 > Unity3D

unity自定义工具

2017-01-03 21:51 190 查看
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using System.Collections.Generic;

public class SetTools
{

[MenuItem("Custom/SetMaterrial")]
public static void SetMaterrial()
{
foreach (GameObject volumeGo in Selection.gameObjects)
{
string volumeName = volumeGo.name;
foreach (Transform t in volumeGo.transform)
{
t.gameObject.SetActive(false);
string timeName = t.name;
char[] c = timeName.ToCharArray();
foreach (Transform t2 in t)
{
t2.gameObject.AddComponent<MeshCollider>();
string path = "Assets/water/" + volumeName + "/Animation000" + c[1] + ".jpg";
Texture texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture)) as Texture;
t2.GetComponent<MeshRenderer>().sharedMaterial.mainTexture = texture;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: