Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by HCN · Jul 07, 2015 at 04:48 PM · c#dllexceptionmacosxcairo

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 : alt text

If anyone of you has an idea or suggestion, feel free to post it! :-)

Bye

test.png (1.3 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges