0 votes

Hi i have small question because i try get pixel color under my mouse and everything was good but when i open my game i got many errors with locking and unlocking image i trying fix it but i failed it. Someone could tell my how can i fix it ?

I using c# :)

under i give image with my errors and code

https://prnt.sc/pvd0ab

https://prnt.sc/pvd0gj

in Projects by (65 points)

1 Answer

+1 vote
Best answer

You don't need to load an image. You get an image via GetViewport()...

var image = GetViewport().GetTexture().GetData();
image.Lock();
GD.Print(image.GetPixel(.....and so on.....));
image.UnLock();
by (3,214 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories