Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. private void OnAssignMaterialModel(Material material, Renderer renderer)
  2. {
  3.  
  4. string materialPathnew = "Assets/ArtAssets/Materials/walls/";
  5. int fileNameIndex = assetPath.LastIndexOf('/');
  6. string fileName = assetPath.Substring(fileNameIndex + 1);
  7. fileName = fileName.Substring(0, fileName.Length - 4) + "_mat.mat";
  8. materialPathnew = materialPathnew + fileName;
  9.  
  10. Debug.Log(materialPathnew);
  11. string[] split = assetPath.Split('/');
  12. string newAssetPath = "";
  13.  
  14.  
  15. for (int i = 0; i < split.Length - 1; i++)
  16. {
  17. newAssetPath += split[i] + "/";
  18. }
  19. newAssetPath = (newAssetPath + "Materials/") + fileName ;
  20.  
  21.  
  22. // Debug.Log(newAssetPath);
  23.  
  24. var assetType = AssetDatabase.GetMainAssetTypeAtPath(newAssetPath);
  25. Debug.Log(newAssetPath);
  26. Debug.Log(assetType);
  27. AssetDatabase.MoveAsset(newAssetPath, materialPathnew);
  28. AssetDatabase.SaveAssets();
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement