Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Staki |
Using Godot 3.2 on Windows 10
I am trying to get code from a reddit post on creating an ImageTexture through code. I modified the code to work for C# (below). I do not get any compile errors, but I get the following run time error:
E 0:00:01:0272 System.MissingMethodException: Method not found: void Godot.ImageTexture.CreateFromImage(Godot.Image,uint)
modules/mono/mono_gd/gd_mono_utils.cpp:610 @ debug_send_unhandled_exception_error()
I can see the method both in the official 3.2 docs and here http://godotsharp.net/api/3.2.0/Godot.ImageTexture/#properties, I honestly don’t know whats wrong other than possibly having an incomplete mono build? If that is the case how do I repair/get a working mono build?
using Godot;
using System;
public class tex : TextureRect
{
public override void _Ready()
{
ImageTexture imgTex = new ImageTexture();
Image dynImage = new Image();
dynImage.Create(256, 256, false, Image.Format.Rgba8);
dynImage.Fill(new Color(1, 0, 0, 1));
imgTex.CreateFromImage(dynImage);
this.Texture = imgTex;
imgTex.ResourceName = "CreatedTex";
GD.Print(this.Texture.ResourceName);
}
}
That looks like a bug with the C# version of Godot.
Does it work if you do imgTex.CreateFromImage(dynImage, 7);
?
Zylann | 2020-02-11 13:50
tex.CreateFromImage(image, 7); still produces the same error. I assume its missing in the 3.2 C# build or I have a bad set of bindings. I will try a reinstall later and see if it fixes the issue.
Staki | 2020-02-11 20:44
If the issue persists, report it in the issue tracker
Zylann | 2020-02-11 21:14
After reinstalling the issue was resolved.
Staki | 2020-02-11 23:37
Hey, what did you reinstalled? The Godot Engine? Mono? Visual Studio? I’m having the same issue and can’t fix it by reinstalling these.
paulohyy | 2020-04-16 01:19