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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Prefab deleted my terrain.

Discussion in 'Editor & General Support' started by almartin, Mar 30, 2015.

  1. almartin

    almartin

    Joined:
    Mar 5, 2015
    Posts:
    9
    I have just spent several hours, up to four in the morning creating quite a complex terrain. When I was happy with it. I created a new prefab and dragged the terrain to it. Both the prefab and the terrain name turned blue as you would expect.

    However I went to a separate scene and dragged in the new prefab but the terrain wasn't there. In the inspector it said terrain asset missing. Huh?

    I went back to my original scene to discover the terrain wasn't there either. I've looked everywhere in my assets folder and haven't been able to find it. The annoying thing is I saved the project right after making the prefab.

    Has anyone else had this problem?

    Al
     
  2. almartin

    almartin

    Joined:
    Mar 5, 2015
    Posts:
    9
    I think I've found the problem.

    I created the terrain using the script obj2terrain. It seems the terrain created using this script doesn't get saved as a terrain.asset. Does anyone know how to fix this?

    Regards
    Al
     
  3. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    I believe AssetDatabase.CreateAsset(Object asset, string path) is what you need. Pass your terrainData object as the 'asset' parameter.
     
  4. laforced

    laforced

    Joined:
    Sep 4, 2012
    Posts:
    16
    Use the Obj2Terrain script to create the terrain. Next export the new terrain as a raw file. Delete the terrain created
    with the Obj2Terrain script and create a New terrain the standard way using the RAW file you exported earlier. Using this method will allow you to use the grass/tree/detail mesh painting features.
     
  5. almartin

    almartin

    Joined:
    Mar 5, 2015
    Posts:
    9
    This is what I did in the end.

    I did want to edit the RAW file and crop out the extra area's that Obj2Terrain adds in but unfortunately Photoshop doesn't like 16bit RAW files. Does anyone know of a good free editor for RAW files?

    Thanks
    Al
     
  6. almartin

    almartin

    Joined:
    Mar 5, 2015
    Posts:
    9