http://unity.jb51.net/xuexipeixun/rumenjiaocheng/1461.html
在换装前,我先讲讲WWW的相关事宜。
c#里用WWW去读取资源时,需要用到迭代器IEnumerator和 MonoBehaviour的StartCoroutine方法。
这是在MONO下开线程来读取资源的一种方法。在读取资源前,我们必须先建立资源。
这种资源建立的方法,需要用到Unity3d里EDIT的API,对指定资源进行打包处理。
if (BuildPipeline.BuildAssetBundle(o, null, pathd, BuildAssetBundleOptions.CollectDependencies)) { Debug.Log(“create assetBundle [” + pathd + “] BINGO!”); } else { Debug.Log(“create assetBundle [” + pathd + “] ERROR!!!”); }
最后,懂得以上启蒙知识后就可以对人物模型进行换装了。
对一个人物模型里的个别模块换装,可分为:材质更换,模型更换和骨架更换。
就像下面这段程序那样。
在得到人物SkinnedMeshRenderer后,它的模型进行更换,对其骨架进行更换,最后对其材质球进行更换。
如此而已。
SkinnedMeshRenderer r = root.GetComponent(); r.sharedMesh = new Mesh();