Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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

Discussion in 'Scripting' started by shemtom2002ke, Mar 24, 2022.

Thread Status:
Not open for further replies.
  1. shemtom2002ke

    shemtom2002ke

    Joined:
    Jul 5, 2021
    Posts:
    25
    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.

    Code (CSharp):
    1.  
    2.      
    3. /* Joystick graphic */
    4.     private Image gui;
    5.  
    6.        
    7. /* Store the default rect for the gui, so we can snap back to it */
    8.         defaultRect = gui.pixelInset;
    9.  
    10.         if (!touchPad)
    11.         {
    12.             /* Get a value between -1 and 1 based on the joystick graphic location */
    13.             position = new Vector2
    14.                 (
    15.                   (gui.pixelInset.x + guiTouchOffset.x - guiCenter.x) / guiTouchOffset.x,
    16.                   (gui.pixelInset.y + guiTouchOffset.y - guiCenter.y) / guiTouchOffset.y
    17.                 );
    18.         }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,717
    Image has zero relationship to GUITexture.

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

    shemtom2002ke

    Joined:
    Jul 5, 2021
    Posts:
    25
    In that case how would this be solved?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,717
    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
     
  5. shemtom2002ke

    shemtom2002ke

    Joined:
    Jul 5, 2021
    Posts:
    25
    Thank you
     
  6. YousafGrewal

    YousafGrewal

    Joined:
    Jul 5, 2018
    Posts:
    17
    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.....:):):):);)
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,717
    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!"
     
    YousafGrewal likes this.
  8. NamelessDeveloper777

    NamelessDeveloper777

    Joined:
    May 9, 2021
    Posts:
    11
    does any body get any solution
     
Thread Status:
Not open for further replies.