public void newMat() { // Create a unique material name. string matName = Util.getUniqueInternalName("newMaterial", "TerrainMaterialSet", true); // Create the new material. ObjectCreator oc = new ObjectCreator("TerrainMaterial"); oc["internalName"] = matName; oc["parentGroup"] = "TerrainMaterialDlgNewGroup"; TerrainMaterial newMat = oc.Create(); newMat.setFilename("art/terrains/materials.cs"); // Mark it as dirty and to be saved in the default location. PersistenceManager ETerrainMaterialPersistMan = "ETerrainMaterialPersistMan"; ETerrainMaterialPersistMan.setDirty(newMat, "art/terrains/materials.cs"); GuiTreeViewCtrl matLibTree = this.findObjectByInternalName("matLibTree", true); //TerrainPainterAddition int root = matLibTree.findItemByName("RootMaterial"); int folder = matLibTree.findItemByName("Unused"); if (folder == 0) { folder = matLibTree.insertItem(root, "Unused", "Unused", ""); } matLibTree.insertObject(folder, newMat, true); matLibTree.buildVisibleTree(true); SimObject item = matLibTree.findItemByObjectId(newMat); matLibTree.selectItem(item); }