unity3d questions!

时间:2015-05-13 19:00:12   收藏:0   阅读:113

UnityVS: Web Target with Web Security enabled will prevent opening files and communication with UnityVS.

 解决方法

直接在  unity中  File-》build setting -> 更换一个平台就行,不要选择web的

just go to File->Build Settings then select something other than web player and then press Switch Platform

======================================================================================

捕获日志

using UnityEngine;
using System.Collections;
public class SetupVerification : MonoBehaviour
{
 public string message = "";
 private bool badSetup = false;
 void Awake ()
 {
  Application.RegisterLogCallback (OnLog);
 }
 void OnLog (string message, string stacktrace, LogType type)
 {
  if (message.IndexOf ("UnityException: Input Axis") == 0 ||
   message.IndexOf ("UnityException: Input Button") == 0
  )
  {
                   //处理异常信息
  }
 }
}

 

 

 

===============================================================

InternalGetGameObject can only be called from the main thread.

然后socketclient对象是异步的,所以做了多线程处理,当socketclient接收到消息时,回调了主线程的函数(继承自monobehaviour),这时候就导致了报错。上面第一篇unity论坛博文解释得比较清楚,大概就是unity对于API调用主线程做了限制:

“Unity chose to limit API calls to main-thread, to make a simple and solid threading model that everyone can understand and use.”

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!