首页 > 编程语言 > 详细

unity自定义工具

时间:2017-01-03 23:33:04      阅读:226      评论:0      收藏:0      [点我收藏+]

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;
}
}
}

unity自定义工具

原文:http://www.cnblogs.com/943711466qq/p/6246598.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!