Search Unity

New Terrain System - How Do I Work Around This?

Discussion in 'Editor & General Support' started by Old_Wolf, Apr 15, 2019.

  1. Old_Wolf

    Old_Wolf

    Joined:
    Apr 3, 2017
    Posts:
    38

    public SurfaceData GetSurfaceData(Collider collider, Vector3 position, int triangleIndex)
    {
    Texture texture = null;

    // If the ground is a terrain.
    if(collider.GetType() == typeof(TerrainCollider))
    {
    Terrain terrain = collider.GetComponent<Terrain>();
    TerrainData terrainData = terrain.terrainData;
    float[] textureMix = GetTerrainTextureMix(position, terrainData, terrain.GetPosition());
    int textureIndex = GetTerrainTextureIndex(position, textureMix);
    texture = terrainData.splatPrototypes[textureIndex].texture;
    }
    // If the ground is a normal mesh.
    else
    texture = GetMeshTexture(collider, triangleIndex);

    if(texture)
    {
    for(int i = 0;i < m_Surfaces.Length;i ++)
    if(m_Surfaces[i].HasTexture(texture))
    return m_Surfaces[i];

    return m_DefaultSurface;
    }
    else
    return m_DefaultSurface;
    }


    Not used to the new terrain system yet, and I am trying to update an older project. How do I fix the Splat texture obsolete error? Not a gamebreaker...but driving me bonkers.