TexeL

Untitled

Apr 12th, 2012
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1.                     string thePath = AssetDatabase.GetAssetPath(go.renderer.sharedMaterials[i]);
  2.                     int li = thePath.LastIndexOf("/");
  3.                     string assetName = thePath.Substring(li+1, thePath.Length-li-1);
  4.                     string assetPath = thePath.Substring(0, li+1);
  5.                     //Debug.Log(assetPath);
  6.                     //string folderGUID = AssetDatabase.AssetPathToGUID(assetPath);
  7.                     string guid1 = AssetDatabase.CreateFolder("Assets", "ClonedMaterials");
  8.                     AssetDatabase.Refresh();
  9.                     assetPath = AssetDatabase.GUIDToAssetPath(guid1);
  10.                     Debug.Log(assetPath);
  11.                     string newPath = assetPath + "/clone" + assetName;
  12.                     AssetDatabase.CopyAsset(thePath, newPath);
  13.                     AssetDatabase.Refresh();
  14.                     AssetDatabase.SaveAssets();
  15.  
  16.                     AssetDatabase.ImportAsset(newPath);
  17.                     Material m = (Material)AssetDatabase.LoadAssetAtPath(newPath, typeof(Material));
  18.  
  19.                     Debug.Log(m);
  20.                     go.renderer.sharedMaterials[i] = m;
  21.                     Debug.Log(go.renderer.sharedMaterials[i]);
Advertisement
Add Comment
Please, Sign In to add comment