サンプルを動かした所、以下のエラーが発生。
Input color array length needs to match width * height, but 76800 != 320 * 320 UnityEngine.WebCamTexture:GetPixels32(Color32[]) NyARUnityUtils.NyARUnityRaster:updateByWebCamTexture(WebCamTexture) (at Assets/NyARUnityUtils/NyARUnityRaster.cs:66) NyARUnityUtils.NyARUnityWebCam:update() (at Assets/NyARUnityUtils/NyARUnityWebCam.cs:44)
このエラーはプログラムだと 320x240 を指定しているけどMacだとWebカメラが 320x320 の画像データを返すみたいでエラーが発生しているみたいでした。
ARCameraBehaviour.cs の以下の部分を 320x320 に変更して解決。
w=new WebCamTexture(320, 240, 15);
↓
w=new WebCamTexture(320, 320, 15);
すると次にこちらのエラーが発生。
indexOutOfRangeException: Array index is out of range. jp.nyatla.nyartoolkit.cs.core.NyARObserv2IdealMap.observ2IdealBatch (jp.nyatla.nyartoolkit.cs.core.NyARIntPoint2d[] i_coord, Int32 i_start, Int32 i_num, System.Double[] o_x_coord, System.Double[] o_y_coord, Int32 i_out_start_index) (at Assets/NyARToolkitCS/src/cs/core/param/NyARObserv2IdealMap.cs:141) jp.nyatla.nyartoolkit.cs.core.NyARCoord2Linear.coord2Line (Int32 i_st, Int32 i_ed, jp.nyatla.nyartoolkit.cs.core.NyARIntCoordinates i_coord, jp.nyatla.nyartoolkit.cs.core.NyARLinear o_line) (at Assets/NyARToolkitCS/src/cs/core/squaredetect/NyARCoord2Linear.cs:122) jp.nyatla.nyartoolkit.cs.markersystem.RleDetector.onSquareDetect (jp.nyatla.nyartoolkit.cs.core.NyARIntCoordinates i_coord, System.Int32[] i_vertex_index) (at Assets/NyARToolkitCS/src.markersystem/cs/markersystem/NyARMarkerSystem.cs:570) jp.nyatla.nyartoolkit.cs.core.NyARSquareContourDetector_Rle.detectMarker (INyARGrayscaleRaster i_raster, Int32 i_th) (at Assets/NyARToolkitCS/src/cs/core/squaredetect/NyARSquareContourDetector_Rle.cs:254) jp.nyatla.nyartoolkit.cs.markersystem.RleDetector.detectMarker (jp.nyatla.nyartoolkit.cs.markersystem.NyARSensor i_sensor, Int64 i_time_stamp, Int32 i_th) (at Assets/NyARToolkitCS/src.markersystem/cs/markersystem/NyARMarkerSystem.cs:606) jp.nyatla.nyartoolkit.cs.markersystem.NyARMarkerSystem.update (jp.nyatla.nyartoolkit.cs.markersystem.NyARSensor i_sensor) (at Assets/NyARToolkitCS/src.markersystem/cs/markersystem/NyARMarkerSystem.cs:474) ARCameraBehaviour.Update () (at Assets/ARCameraBehaviour.cs:66)
自分ではここで挫折して、「Windowsで試すかな?」って思っていたのですが作者さんよりアドバイスを受けて解決しました。
ARCameraBehaviour.cs の以下の部分を 320x320 に変更すると無事にMacでもエラーが無くなり、ちゃんと赤いボックスが表示されました。
NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(320,240);
↓
NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(320,320);