unity3d坑收集

1. Raycast 没有效果

通过collider的射线收集碰撞体,没有效果,不知道为什么?

    Ray ray = new Ray {
      origin = transform.position,
      direction = transform.forward
      };
      RaycastHit hit;
    ray.direction = ray.direction * 100;
      if(transform.GetComponent<Collider>().Raycast(ray, out hit, 20000))
    {
      Debug.Log("hit = yes"));
    }

但是通过 Physics射线收集就有效果

    var hits = Physics.RaycastAll(ray, 10);
    if (hits != null && hits.Length > 0)
    {
      Debug.Log("log="+hits[0].collider.name);
    }

2. SceneManager.loadSceneAsyn其实这行代码卡住很久时间(仅在editor中卡),在release包之后才正常。

3. 在edit模式中,使用PrefabUtility.InstantiatePrefab去实例化prefab,这样才能真正关联prefab,否则使用instantiate方法去实例化的话,在编辑器中会产生一个全新的不关联的对象。

4。有时候粒子系统显示不出来,原因是没有设置摄像机的rendering path为deferred

5。PrefabUtility.InstantiatePrefab实例化预制时,会自动把物体添加到场景中,并激活,所有需要注意物体在哪里显示。

6。一个场景被unload时候,里面的coroutine如果还未运行完成将会被强制退出。

7。如果有底层包引用了系统包,但是系统包缺失时候会报错:Plugins: Failed to load xxx.dll because one or more of its dependencies could not be loaded.  这时候需要使用工具Dependency Walker去检查底层包,在正常机器和异常机器中检查这个底层包dll有什么不同。

8. the type or namespace name 'xxx' does not exist in the namespace 'midiapipe.unity' 错误发生的原因是,导入的Packages中少了asmdef文件,unity导入外部依赖包时,不是把文件放入文件夹中就可以的,而是需要asmdef这个文件才行,这样在visual studio解决方案中才看到依赖的工程。(project)

9。打包aab包时从google上下载测试报错:check apk path fail, reported:/data/app/~~J9wzVfKZE_BMftcIRx3yEg==/com.ufv.fly-yNGCYigE2rF2ZbrQ4lEUsg==/split_UnityDataAssetPack.apk, actual:/data/app/~~J9wzVfKZE_BMftcIRx3yEg==/com.ufv.fly-yNGCYigE2rF2ZbrQ4lEUsg==/base.apk

Unity : Illegal usage of unity detected, shutdown unity.

原因是不能使用中文网站下载的编辑器,需要到国际站上下载编辑器。

猜你喜欢

转载自blog.csdn.net/cention168/article/details/124087888