- Home /
InvalidProgramException: Invalid IL code with Mono.Cairo on MacOS
Hi everyone,
I have "solved" a previous problem with a DllFoundException on MacOS, but I now have a new problem.
I want to use Mono.Cairo with Unity on MacOs (and Windows and Android).
My application on Windows works fine, so I tried to build my solution for MacOS, it didn't work. So I import it on my Mac and change the Mono.Cairo.dll (specific for Mac) in the Plugins folder.
I find this exception for each accessor I want to use:
     InvalidProgramException: Invalid IL code in Cairo.ImageSurface:get_Data (): IL_0000: ret 
 (NB: In this case it is get_Data but it can be any accessors from my ImageSurface or my Context).
 
     Draw.Start () (at Assets/Scripts/Draw.cs:39)
Here is my code which works for windows to assign a texture I draw to my GameObject:
 using UnityEngine;
 using System;
 using System.Collections;
 using Cairo;
 
 public class Draw : MonoBehaviour
 {
     // Use this for initialization
     void Start()
     {
         ImageSurface surface = new ImageSurface(Format.ARGB32, 120, 120);
         Context cr = new Context(surface);
         // Examples are in 1.0 x 1.0 coordinate space
         cr.Scale(120, 120);
 
         // Drawing code goes here
         cr.SetSourceColor(new Cairo.Color(0, 0, 0));
         cr.MoveTo(0, 0);
         cr.LineTo(1, 1);
         cr.MoveTo(1, 0);
         cr.LineTo(0, 1);
         cr.LineWidth = 0.2;
         cr.Stroke();
 
         cr.Rectangle(0, 0, 0.5, 0.5);
         cr.SetSourceRGBA(1, 0, 0, 0.80);
         cr.Fill();
 
         cr.Rectangle(0, 0.5, 0.5, 0.5);
         cr.SetSourceRGBA(0, 1, 0, 0.60);
         cr.Fill();
 
         cr.Rectangle(0.5, 0, 0.5, 0.5);
         cr.SetSourceRGBA(0, 0, 0, 0.40);
         cr.Fill();
         // Create my texture and assign it
         Texture2D text = new Texture2D(120, 120, TextureFormat.BGRA32, false);
         text.LoadRawTextureData(surface.Data);
         text.Apply();
         this.renderer.material.mainTexture = text;
         ((IDisposable)cr.GetTarget()).Dispose();
         ((IDisposable)cr).Dispose();
     }
 }
It draws this image : 
If anyone of you has an idea or suggestion, feel free to post it! :-)
Bye
Your answer
 
 
             Follow this Question
Related Questions
DllNotFoundException libcairo.so.2 on MacOS 1 Answer
Multiple Cars not working 1 Answer
The requested feature is not implemented 0 Answers
Distribute terrain in zones 3 Answers
dll error when build 4 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                