一些自己的项目优化收集整理

 

/

Mesh buffers are 16 bit by default. See Mesh-indexFormat:

Index buffer can either be 16 bit (supports up to 65535 vertices in a mesh), or 32 bit (supports up to 4 billion vertices). Default index format is 16 bit, since that takes less memory and bandwidth.

Without looking too closely at the rest of your code, I do note that you've not set a 32 bit buffer. Try:

mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;

Format of the mesh index buffer data.

Index buffer can either be 16 bit (supports up to 65535 vertices in a mesh), or 32 bit (supports up to 4 billion vertices). Default index format is 16 bit, since that takes less memory and bandwidth.

Note that GPU support for 32 bit indices is not guaranteed on all platforms; for example Android devices with Mali-400 GPU do not support them. When using 32 bit indices on such a platform, a warning message will be logged and mesh will not render.

Changing indexFormat sets subMeshCount to one and clears the index buffer.

See Also: IndexFormat, ModelImporter.indexFormat, SetIndices, SetTriangles, SetIndexBufferParams, SetIndexBufferData.

The number of sub-meshes inside the Mesh object.

Each sub-mesh corresponds to a Material in a Renderer, such as MeshRenderer or SkinnedMeshRenderer. A sub-mesh consists of a list of triangles, which refer to a set of vertices. Vertices can be shared between multiple sub-meshes.

See Also: GetTriangles, SetTriangles.

For advanced lower-level sub-mesh and mesh data manipulation functions, see SubMeshDescriptor, SetSubMesh, SetIndexBufferParams, SetIndexBufferData.

Note that changing subMeshCount to a smaller value than it was previously resizes the Mesh index buffer to be smaller. The new index buffer size is set to SubMeshDescriptor.indexStart of the first removed sub-mesh.

一个批次的顶点数在2~3万左右,大概7~8个批次

我是不是可以理解为一个FBO有大概8个draw,每个draw的vertex数目是2-3万?

Mali GPU是tile-based GPU,所以在运行过程中会为shader中出现的varying分配memory,假设一个shader的vertex shader用到了4个vec4 varying输出,那么一个FBO所需要的memory大概是30000 * 8(8个draw) * 4(4个vec4) * 4(1个vec4是4个float) * sizeof(float) = 15360000 bytes = 14.65M bytes.

因为GPU是按照pipeline执行的,假设同时有3个FBO可以同时运行,那么运行你这个app所需要的memory就是14.65M * 3 ~ 44M。

这是一个不小的数字,在老的手机上很可能会导致out of memory。

memory大概是9000 * 1(1个draw) * 1(1个vec4) * 4(1个vec4是4个float) * sizeof(float) = 144000 bytes = 140.625K bytes.

解决方法:

Android Device Monitor ---  LogCat  ---- SavedFilters  ---   +  ----  by Log Tag   (unity)  Filter Name (随便写)

 

 

 

The profiler has run out of samples for this frame. This framewill be skipped. Increase the sample limit usingProfiler.maxNumberOfSamplesPerFrame

解决方法:

 

花屏:

 

摇杆:在3d场景中有物理检测时,人物跑动,跑跑停停,但是摇杆一直在前进状态

解决方法:ETC Joystick use Fixed Update

 

合并材质:

 

 

打包Altas报错:   Can't resize to a compressed texture format

UnityEngine.Texture2D:Resize(Int32, Int32)

Unsupported texture format - needs to be ARGB32, RGBA32,RGB24, Alpha8 or one of float formats

UnityEngine.Texture2D:SetPixels(Color[])

UITexturePacker:PackTextures(Texture2D, Texture2D[], Int32,Int32, Int32, Int32) (at Assets/NGUI/Scripts/Editor/UITexturePacker.cs:111)

 

 

 

Agent必须在OnNavMesh的报错:

if (unit.navMeshAgent.enabled &&unit.navMeshAgent.isOnNavMesh)

                unit.navMeshAgent.Stop();

 

copy 一行数字:

TextEditor textEditor = new TextEditor ();

textEditor.content =newGUIContent (lblUID.text);

textEditor.OnFocus ();

textEditor.Copy ();

 

Failed toimport package with error: Couldn't decompress package

解决方法:路径中包含中文字符,更改成英文路径即可

 

 

分析C:\Users\[你的用户名]\AppData\Local\Unity\Editor\Editor.log当中的构建日志部分,查看打包资源列表

 

 

 

http://answers.unity3d.com/questions/13185/turn-off-shadows-for-a-specific-camera.html

 

Ihave two cameras in my scene. One is a top-down camera that is used to render a"radar" (2D) on the HUD. The other camera is the 3rd person gameplaycamera that follows the player.

Ialso have a single directional light in my scene that generates shadows. For mytop-down camera, I do not want shadows to be rendered. For the player camera Ido want shadows to be rendered.

Isthere a way to turn off shadows for a specific camera?

 

Youcan do what you describe using the Camera.OnPreRender () and Camera.OnPostRender () methods. So, you would attach a script to your minimap camerawhere, in OnPreRender, you store the current shadow distance in a classvariable usingQualitySettings.shadowDistance and set the shadow distance to 0. In OnPostRender, you simplyrestore the stored shadow distance.

var storedShadowDistance : float;

functionOnPreRender () { storedShadowDistance = QualitySettings.shadowDistance;QualitySettings.shadowDistance = 0; }

functionOnPostRender () { QualitySettings.shadowDistance = storedShadowDistance; }

 

1.  public classShadowToggler:MonoBehaviour

2.  {

3.       public Light[]SoftLights;

4.      publicLight[] HardLights;

5.       void Start()

6.      {

7.           if (gameObject.GetComponent<Camera>()==null){Debug.Log("No Camera Found");}

8.      }

9.   

10.     voidOnPreRender()

11.      {

12.         foreach(Light l inSoftLights){ l.shadows=LightShadows.None;}

13.          foreach (Light linHardLights){ l.shadows=LightShadows.None;}

14.     }

15.  

16.     voidOnPostRender()

17.      {

18.         foreach(Light l inSoftLights){ l.shadows=LightShadows.Soft;}

19.          foreach (Light linHardLights){ l.shadows=LightShadows.Hard;}

20.     }

21.  }

22. 

There is probably a better way than having to add yourlights to the arrays, but this is the simple method that allows for multiplelights and shadow types.

 

Frommy experiemnce, using PreCull and PostRender methods are extremely resourceintensive. There is a far easier way to do it: Just pass the Camera areplacement shader, one which doesn't render shadows (Unlit/Texture, forexample).

1.   using UnityEngine;
2.   using System.Collections;
3.   
4.   public class MapCamera : MonoBehaviour {
5.   
6.       public Shader unlitShader;
7.   
8.       void Start() {
9.           //unlitShader = Shader.Find("Unlit/Texture");
10.          GetComponent<Camera>().SetReplacementShader(unlitShader,"");
11.      }
12.  }

 

 

 

var e = myDic.GetEnumerator();

while (e.MoveNext())

{

   string typeName =e.Current.Key;

//todo something

}

 

 

子树拖拽?选中这个子树的根节点,然后按住Shift+鼠标左边

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值