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 where is Tilemaps.GridPaintingState.isEditing?

Discussion in '2D' started by superBang, Jul 4, 2023.

  1. superBang

    superBang

    Joined:
    Jun 5, 2017
    Posts:
    4
  2. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    238
    it's there. Reading is public, writing is 'internal' which means that to write to that property you'd need to use reflection.

    Code (CSharp):
    1. var isEditing = GridPaintingState.isEditing;
    works for me.

    You should note though, that this generally only indicates what the active palette brush is doing, and not other tilemap painting tools.
     
    Kurt-Dekker likes this.
  3. superBang

    superBang

    Joined:
    Jun 5, 2017
    Posts:
    4
    Can you tell me how to get GridPaintingState?

    The code I use is as follows and does not work.

    unity version is 2021.3.15
    and tilemap editor package version is version 1.0.0.
     

    Attached Files:

  4. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    238
    Actually it is a scriptable singleton and not a static class.

    As such, your code needs to be in an Editor folder. If it isn't then that's possibly why you get a compile error.

    Regarding your versions and such I doubt it makes a difference.
     
  5. superBang

    superBang

    Joined:
    Jun 5, 2017
    Posts:
    4
    The script already exists under the Editor folder.

    I went to the definition of GridPaintingState and looked it up, but I couldn't find "isEditing".
     
  6. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    238
    Maybe it does not exist in that unity version. Try a newer one like 2022.3 LTS.

    I opened that class in my editor and that property is present.
     
  7. superBang

    superBang

    Joined:
    Jun 5, 2017
    Posts:
    4

    It works in the latest version !!!

    The tile map versions are all 1.0.0, so I thought there would be no difference...
     
  8. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    238
    No they've made many changes. For example, newer Tilemaps have new code with better animation control, better batch-mode tile movement, enhanced callbacks, and much more.