资源简介
2DGameplayTutorialProject.zip for unity3d开发..
代码片段和文件信息
using UnityEngine;
using System.Collections;
/*
Attach this script as a parent to some game objects. The script will then combine the meshes at startup.
This is useful as a performance optimization since it is faster to render one big mesh than many small meshes. See the docs on graphics performance optimization for more info.
Different materials will cause multiple meshes to be created thus it is useful to share as many textures/material as you can.
*/
[AddComponentMenu(“Mesh/Combine Children“)]
public class CombineChildren : MonoBehaviour {
/// Usually rendering with triangle strips is faster.
/// However when combining objects with very low triangle counts it can be faster to use triangles.
/// Best is to try out which value is faster in practice.
public bool generateTriangleStrips = true;
public bool castShadows = true;
public bool receiveShadows = true;
/// This option has a far longer preprocessing time at startup but leads to better runtime performance.
void Start () {
Component[] filters = GetComponentsInChildren(typeof(MeshFilter));
Matrix4x4 myTransform = transform.worldToLocalMatrix;
Hashtable materialToMesh= new Hashtable();
for (int i=0;i MeshFilter filter = (MeshFilter)filters[i];
Renderer curRenderer = filters[i].renderer;
MeshCombineUtility.MeshInstance instance = new MeshCombineUtility.MeshInstance ();
instance.mesh = filter.sharedMesh;
if (curRenderer != null && curRenderer.enabled && instance.mesh != null) {
instance.transform = myTransform * filter.transform.localToWorldMatrix;
Material[] materials = curRenderer.sharedMaterials;
for (int m=0;m instance.subMeshIndex = System.Math.Min(m instance.mesh.subMeshCount - 1);
ArrayList objects = (ArrayList)materialToMesh[materials[m]];
if (objects != null) {
objects.Add(instance);
}
else
{
objects = new ArrayList ();
objects.Add(instance);
materialToMesh.Add(materials[m] objects);
}
}
curRenderer.enabled = false;
}
}
foreach (DictionaryEntry de in materialToMesh) {
ArrayList elements = (ArrayList)de.Value;
MeshCombineUtility.MeshInstance[] instances = (MeshCombineUtility.MeshInstance[])elements.ToArray(typeof(MeshCombineUtility.MeshInstance));
// We have a maximum of one material so just attach the mesh to our own game object
if (materialToMesh.Count == 1)
{
// Make sure we have a mesh filter & renderer
if (GetComponent(typeof(MeshFilter)) == null)
gameobject.AddComponent(typeof(MeshFilter));
if (!GetComponent(“MeshRenderer“))
gameobject.AddComponent(“MeshRenderer“);
MeshFilter filter = (MeshFilter)GetComponent(typeof(MeshFilter));
filter.mesh = MeshCombineUtility.Combine(instances generateTriangleStrips);
renderer.material = (Material)de.Key;
renderer.enabled = true;
renderer.castShadows = castShadows;
renderer.receiveShadows = re
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2009-11-24 14:03 2DGameplayTutorial\
目录 0 2009-11-24 14:02 2DGameplayTutorial\Assets\
文件 235663 2009-11-24 14:02 2DGameplayTutorial\Assets\2D Platformer.unity
目录 0 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\
文件 68958 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Crate.fbx
文件 1304960 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Lerpz.fbx
目录 0 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\
文件 3301 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\crate-_empty_.mat
文件 3269 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\crate-cratemat.mat
文件 3643 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\lerpzuv.mat
文件 3285 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\movingplatform-moving_platformmat.mat
文件 3309 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platform slope-_empty_.mat
文件 3285 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platform slope-angled_platformmat.mat
文件 3672 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platform texture.mat
文件 3301 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platforms-_empty_.mat
文件 3277 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platforms-angled_platformmat.mat
文件 3277 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platforms-end_cap_003mat.mat
文件 3277 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platforms-end_cap_rightmat.mat
文件 3269 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platforms-end_capmat.mat
文件 3277 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platforms-level_platformmat.mat
文件 3277 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\platforms-moving_platformmat.mat
文件 3674 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\spaceship texture.mat
文件 3309 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\spaceship-default mat.mat
文件 3648 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Materials\xplosive.mat
文件 27312 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\MovingPlatform.fbx
文件 71762 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Platform Slope.fbx
文件 122107 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Platforms.fbx
文件 189600 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Spaceship.fbx
目录 0 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Textures\
文件 809020 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Textures\lerpzBump.tif
文件 1079508 2009-11-24 14:02 2DGameplayTutorial\Assets\Artwork\Textures\lerpzUV.tif
............此处省略542个文件信息
- 上一篇:Atoll2.8破解版
- 下一篇:土工原理与计算第二版钱家欢 殷宗泽
相关资源
- 安卓Unity 3D dll文件解密工具get_dll_fr
- Helios 1.3.1 录制全景视频 VR
- unity2d实现的贪吃蛇游戏
- unity高速设施资源
- AR室内导航Demo
- Unity Sci-FI UI Design for UGUI1.0
- unity3d小游戏
- Unity3D模型-各种石头、蘑菇、小草、树
- unity3d 真实世界地形插件
- Unity3D三国群英传完整源码
- Unity3d-SkyBox-35个天空盒(含预览图)
- Unity3D游戏开发 第二版PDF part2
- 一款unity3d做得小游戏
- 水花、瀑布等特效,unity自带粒子系统
- Unity3D横版射击游戏《G小队-中东战争
- Unity3D特效插件 多彩光晕特效包 ProF
- Unity 3D NGUI实战教程(完整版)
- Unity3D 游戏开发_宣雨松著 第一版加第
- unity图表工具graphmaker
- Unity3D游戏开发 第二版
- Kinect一代插件unity3d
- Unity坦克大战案例源码
- 200个WEB前端小游戏!
- SimpleWebView.zip
- Unity3D城市模拟道路5.0以上版本
- unity3D城市智能交通系统源码
- Unity3D flappy bird
- Snapdragon Profiler v2019.3
- Unity3D/2D游戏开发从0到1199230
- unity3d 仿王者荣耀 源代码
评论
共有 条评论