'Image' does not contain a definition for 'pixelInset' and no accessible extension method 'pixelInse

Below is an outdated code (from an old asset) that I’m trying to upgrade to the latest version of unity code. I was able to change the GUItexture to Image but I encounter other errors which are not within the image scope.

/* Joystick graphic */
    private Image gui;

       
/* Store the default rect for the gui, so we can snap back to it */
        defaultRect = gui.pixelInset;
 
        if (!touchPad)
        {
            /* Get a value between -1 and 1 based on the joystick graphic location */
            position = new Vector2
                (
                  (gui.pixelInset.x + guiTouchOffset.x - guiCenter.x) / guiTouchOffset.x,
                  (gui.pixelInset.y + guiTouchOffset.y - guiCenter.y) / guiTouchOffset.y
                );
        }

Image has zero relationship to GUITexture.

You would probably want to refactor whatever it is you are doing to use UnityEngine.UI.Image correctly.

In that case how would this be solved?

Same as any other engineering problem.

  1. describe the problem to google

  2. learn about it a bit

  3. do some experimentation

  4. engineer a solution

Thank you

error CS1061: ‘Image’ does not contain a definition for ‘pixelInset’ and no accessible extension method ‘pixelInset’ accepting a first argument of type ‘Image’ could be found (are you missing a using directive or an assembly reference?)

===========================================================================================
the issue is still there no engineering work needed a solid answer to overcome this problem…:):):):):wink:

Your first stop before necro-posting to this old thread should to look up the documentation.

Then when you necro post you would include a direct link to that documentation saying “See these docs? Image has this pixelInset property / field according to the docs and it STILL doesn’t work for me!”

1 Like