我有一个 Unity3D Mobile Chess 应用程序,我正在使用 Unity 3D 4.6.5f1 从 32 位移植到 64 位。它使用 OpenGLS2.0、.NET 2.0 库,并且正在生成通用二进制文件。
我收到一个运行时错误,在调试器中显示如下:
NullReferenceException: A null value was found where an object instance was required.
at <PrivateImplementationDetails>..ctor () [0x00000] in <filename unknown>:0
at ValilScriptObject.Update () [0x00000] in <filename unknown>:0
at System.Collections.Generic.Dictionary`2+ShimEnumerator[Boo.Lang.Runtime.DynamicDispatching.DispatcherKey,Boo.Lang.Runtime.DynamicDispatching.Dispatcher].get_Current () [0x00000] in <filename unknown>:0
System.Collections.Generic.ShimEnumerator:get_Current()
(文件名:目前在 il2cpp 线:4294967295 上不可用)
它使用 Mono 2.0 可以很好地编译,但是一旦我将它移植到 IL2CPP 以获得 64 位通用二进制文件,它就会抛出错误。
它引用 Update() 的函数似乎没问题。
void Update () {
if(Request.Length>0)
{
string answ="";
Answer=Engine1.GetNextMove(Request, null, Deep);
Request="";
if(Answer.Length>0) answ=Answer.Substring(0,2)+"-"+Answer.Substring(2,2);
if(Answer.Length>4) answ+="="+(Answer.Substring(4,1)).ToUpper();
((TextMesh)GetComponent(typeof(TextMesh))).text=answ;
//Application.ExternalCall("JSAnswer", answ);
(GameObject.Find("Script2")).SendMessage("EngineAnswer",answ);
}
}
它只是使用 Valil Chess Engine(用 C# 编写)来获得适当的答案(下一步)。它在 Mono 2.0 中工作正常,但在 IL2CPP 中失败。有什么想法吗?
最佳答案
我终于找到了答案。初始化 ChessEngine 时,会初始化一个 ChessEngine.OpeningBook 类。我只是完全取消了这门课,它就像一个魅力。该类看起来像:
using System;
using System.IO;
using System.Collections.Generic;
using System.Reflection;
//using Valil.Chess.Engine.Properties;
namespace Valil.Chess.Engine
{
public sealed partial class ChessEngine
{
// hashtable with the board hash as the key and a list of moves for this board configuration as the value
public static Dictionary<int, List<short>> book;
// helps choose a move when the list contains more than one
private Random random;
/// <summary>
/// Initializes the opening book.
/// </summary>
private void InitializeOpeningBook()
{
// initialize the random generator
random = new Random(unchecked((int)DateTime.Now.Ticks));
int Settings_Default_OpeningBookSize = 2755;
//int Settings_Default_OpeningBookByteSize = 16530;
//Assembly assembly = Assembly.GetExecutingAssembly();
//String[] ss = assembly.GetManifestResourceNames();
// THERE IS NO FILE & MANIFEST ASSEMBLY IN UNITY3D FOR FREE...
// SO, CLASS ObookMem IS AS OPENING BOOK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Stream readstream = Assembly.GetExecutingAssembly().GetManifestResourceStream("valil_silverlightchess.book.bin");
// the "book.bin" file is a binary file with this pattern: int,short,int,short etc.
// a 4-byte int represent a board hash, the following 2-byte short is a move (the first byte represents the starting square, the second one the ending square)
// read "book.bin" and put the values in the hashtable
try
{
using (BinaryReader br = new BinaryReader( readstream ))
// using (BinaryReader br = new BinaryReader(new BufferedStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("Valil.Chess.Engine.book.bin"), Settings.Default.OpeningBookByteSize)))
// using (BinaryReader br = new BinaryReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("book.bin")))
{
book = new Dictionary<int, List<short>>(Settings_Default_OpeningBookSize);
for (int i = 0; i < Settings_Default_OpeningBookSize; i++)
{
int hash = br.ReadInt32();
short move = br.ReadInt16();
// if the hashtable already contains this hash, add the move to the list
// otherwise create a new list and add the pair to the hashtable
if (book.ContainsKey(hash))
{
book[hash].Add(move);
}
else
{
List<short> list = new List<short>(1);
list.Add(move);
book.Add(hash, list);
}
}
}
}
catch
{
}
}
}
}
我认为 IL2CPP 编译器不喜欢 System.Reflection 以及我的 Dictionary 和 List 类型。
关于c# - Unity3D iOS 64 位的 IL2CPP 编译器运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30244908/
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe