我试图在创建后从我的页面填充我的场景,但我得到了上面的错误。
这是针对安卓系统的,适用于iOS (线程安全方面的一些问题)
01-05 18:45:19.139 E/Urho3D (32719): Sending events is only supported from the main thread
01-05 18:45:19.139 E/Urho3D (32719): Sending events is only supported from the main thread
01-05 18:45:19.139 E/Urho3D (32719): Sending events is only supported from the main thread
01-05 18:45:19.139 E/Urho3D (32719): Attempted to get resource Models/Box.mdl from outside the main thread
01-05 18:45:19.149 E/Urho3D (32719): Attempted to get resource Materials/Stone.xml from outside the main thread知道如何在场景创建后将项目添加到场景中吗?
urhoApp?.addItem(urhoval);
在我的urho应用中:
public void addItem(string p)
{
modelNode2 = scene.CreateChild(p);
modelNode2.Position = new Vector3(5.0f, 1.0f, 5.0f);
modelNode2.SetScale(10.0f);
var obj2 = modelNode2.CreateComponent<StaticModel>();
obj2.Model = ResourceCache.GetModel("Models/Box.mdl");
obj2.SetMaterial(urhoAssets.GetMaterial("Materials/Stone.xml"));
} 发布于 2017-03-16 00:44:45
您可以尝试在主线程上调用它:
InvokeOnMain(() =>{
//Your code here
}发布于 2017-06-11 05:14:38
android活动的每个事件总是在一个线程上调用--“主线程”。
这个线程由一个队列支持,所有的活动事件都被发送到这个队列中。它们是按插入顺序执行的。
如果您正在调用Finish(),则线程将从当前任务中释放。
当Urho启动时,启动Urho线程的Android线程仍然有效,它被视为主。因此它不能处理你的ResourceCache。
你应该完成启动你的Urho线程的Android线程()。
startBtn.Click += (sender, e) =>
{
Intent intent = new Intent(this, typeof(Urho3DActivity));
intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop);
StartActivity(intent);
Finish();
};iOS是不同的。没有主线程,Apple OS以固有的稳定性处理事件。
startButton.TouchUpInside += delegate
{
Urho.Application Urho3DApp = Urho.Application.CreateInstance(typeof(Urho3DApp), new ApplicationOptions("Data"));
Urho3DApp.Run();
};https://stackoverflow.com/questions/41496762
复制相似问题