Search Unity

Duplicate terrain

Discussion in 'Scripting' started by asdx, Nov 18, 2013.

  1. asdx

    asdx

    Joined:
    Jun 3, 2013
    Posts:
    18
    Hello. I'm trying to make a duplicate of my terrain by pressing a key in-game. I've tried
    Code (csharp):
    1. using UnityEditor;
    2. AssetDatabase.CopyAsset("Assets/My Assets/NewTerrain.asset", "Assets/My Assets/NewTerrain2.asset");
    3. AssetDatabase.Refresh();
    but it doesn't work.. it stops a bit but there is no new asset created. Is the path not declared this way?

    Please help!

    Edit: solved. srry I just mistyped the name of my terrain :neutral:
     
    Last edited: Nov 18, 2013
  2. LividRabbit

    LividRabbit

    Joined:
    May 13, 2013
    Posts:
    13
    When dealing with backslashes "/" your compiler will interpret them as a line break, either double backslash all your backslashes or put a @ in front of your string. Im not sure, but you might have to use AssetDatabase.SaveAssets(); as well