public static Material CreateMaterial(string mPath, string name, string shaderName) { string path = MegascansUtilities.FixPath(mPath); /// Unity doesn't allow you to create objects in directories which don't exist. /// So in this function, we create any and all necessary subdirectories that are required. /// We return the final subdirectory, which is used later in the asset creation too. //first, create the user specified path from the importer settings. string[] pathParts = MegascansUtilities.FixSlashes(path).Split('/'); string defPath = "Assets"; if (pathParts.Length > 0) { for (int i = 0; i < pathParts.Length; ++i) { defPath = MegascansUtilities.ValidateFolderCreate(defPath, pathParts[i]); } } defPath = defPath + "/" + name + ".mat"; Material terrainMaterial = new Material(Shader.Find(shaderName)); AssetDatabase.CreateAsset(terrainMaterial, defPath); AssetDatabase.Refresh(); return(terrainMaterial); }
void LoadPreferences() { path = MegascansUtilities.FixPath(EditorPrefs.GetString("QuixelDefaultPath", "Quixel/Megascans/")); dispType = EditorPrefs.GetInt("QuixelDefaultDisplacement"); texPack = EditorPrefs.GetInt("QuixelDefaultTexPacking"); shaderType = EditorPrefs.GetInt("QuixelDefaultShader"); lodFadeMode = EditorPrefs.GetInt("QuixelDefaultLodFadeMode", 1); setupCollision = EditorPrefs.GetBool("QuixelDefaultSetupCollision", true); applyToSelection = EditorPrefs.GetBool("QuixelDefaultApplyToSelection", false); addAssetToScene = EditorPrefs.GetBool("QuixelDefaultAddAssetToScene", false); importAllTextures = EditorPrefs.GetBool("QuixelDefaultImportAllTextures", false); }