Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Terrain Splat 0 is null

Discussion in 'Scripting' started by Rasped, Mar 11, 2013.

  1. Rasped

    Rasped

    Joined:
    Oct 21, 2012
    Posts:
    14
    Code (csharp):
    1. SplatPrototype[] terrainTexture = new SplatPrototype[1];
    2.         terrainTexture[0] = new SplatPrototype();
    3.         terrainTexture[0].texture = (Texture2D)Resources.Load("Assets/Standard Assets/Terrain Assets/Terrain Textures/Grass (Hill)");
    4.         t.terrainData.splatPrototypes = terrainTexture;
    The last line produces the error "Terrain Splat 0 is null"

    What am I doing wrong?
    I have tried different paths for the asset. Can't figure it out, the path should be right.
     
  2. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    938
    Just guessing here, but maybe the spaces in the path could create a problem. Other than that, I know the "Standard Assets" folder is somewhat sealed and hard to reach from other folders and such. You might want to try placing it in another folder.

    I got the error when I deleted the splat map from the terrain from the asset folder, not triggered by one of my scripts but by unity itself.
     
  3. Rasped

    Rasped

    Joined:
    Oct 21, 2012
    Posts:
    14
    Thanks, I tried it but without luck. Any other ideas?
     
  4. Rasped

    Rasped

    Joined:
    Oct 21, 2012
    Posts:
    14
  5. Garrett-Lynch

    Garrett-Lynch

    Joined:
    Mar 13, 2013
    Posts:
    14
    arggggggg how stupid is that. Been trying to apply a texture to a terrain for over a week now.
    Thanks for posting your solution.
     
  6. m-sajjad

    m-sajjad

    Joined:
    May 27, 2015
    Posts:
    5
    The errors about terrain splats are because you have a terrain with empty texture references Select your terrain, and make sure all the entries defined in the "Paint" tab are assigned to valid textures.
     
  7. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Holy necro, batman! You answered a 2 year old question that had already been answered. ^_^
     
    Kiwasi likes this.
  8. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    And with an irrelevant answer too. It's not quite a record, but it must be close.