Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string thePath = AssetDatabase.GetAssetPath(go.renderer.sharedMaterials[i]);
- int li = thePath.LastIndexOf("/");
- string assetName = thePath.Substring(li+1, thePath.Length-li-1);
- string assetPath = thePath.Substring(0, li+1);
- //Debug.Log(assetPath);
- //string folderGUID = AssetDatabase.AssetPathToGUID(assetPath);
- string guid1 = AssetDatabase.CreateFolder("Assets", "ClonedMaterials");
- AssetDatabase.Refresh();
- assetPath = AssetDatabase.GUIDToAssetPath(guid1);
- Debug.Log(assetPath);
- string newPath = assetPath + "/clone" + assetName;
- AssetDatabase.CopyAsset(thePath, newPath);
- AssetDatabase.Refresh();
- AssetDatabase.SaveAssets();
- AssetDatabase.ImportAsset(newPath);
- Material m = (Material)AssetDatabase.LoadAssetAtPath(newPath, typeof(Material));
- Debug.Log(m);
- go.renderer.sharedMaterials[i] = m;
- Debug.Log(go.renderer.sharedMaterials[i]);
Advertisement
Add Comment
Please, Sign In to add comment