public void TutorialShowSky() { scrollVelocity = new Vector2(0, 3000); selectedLayer = 0; paint.material = ResourcesDirectory.GetMaterial("Materials/Sky"); handler(paint); UpdateMaterialSelector(); }
void UpdateMaterialDirectory() { materialSubDirectories = new List <string>(); if (materialDirectory != rootDirectory) { materialSubDirectories.Add(BACK_BUTTON); } materials = new List <Material>(); foreach (string dirEntry in ResourcesDirectory.dirList) { if (dirEntry.Length <= 2) { continue; } string newDirEntry = dirEntry.Substring(2); int slash = newDirEntry.LastIndexOf("/"); if (slash != -1) { if (newDirEntry.Substring(0, slash) != materialDirectory) { continue; } } else { if (materialDirectory != "") { continue; } } string fileName = newDirEntry.Substring(slash + 1); if (fileName.StartsWith("$")) { continue; // special alternate materials for game } if (!fileName.Contains(".")) { materialSubDirectories.Add(fileName); } else if (fileName.EndsWith(".mat")) { if (fileName.EndsWith(PREVIEW_SUFFIX_EXT)) { materials.RemoveAt(materials.Count - 1); // special preview material which replaces the previous } materials.Add(ResourcesDirectory.GetMaterial(newDirEntry)); } } AssetManager.UnusedAssets(); }
private Material ReadMaterial(JSONObject matObject) { if (matObject["name"] != null) { string name = matObject["name"]; foreach (string dirEntry in ResourcesDirectory.dirList) { if (dirEntry.Length <= 2) { continue; } string newDirEntry = dirEntry.Substring(2); string checkFileName = Path.GetFileNameWithoutExtension(newDirEntry); if ((!editor) && checkFileName.StartsWith("$")) // special alternate materials for game { checkFileName = checkFileName.Substring(1); } if (checkFileName == name) { return(ResourcesDirectory.GetMaterial(newDirEntry)); } } warnings.Add("Unrecognized material: " + name); return(ReadWorldFile.missingMaterial); } else if (matObject["mode"] != null) { ColorMode mode = (ColorMode)System.Enum.Parse(typeof(ColorMode), matObject["mode"]); if (matObject["color"] != null) { Color color = ReadColor(matObject["color"].AsArray); bool alpha = color.a != 1; if (matObject["alpha"] != null) { alpha = matObject["alpha"].AsBool; // new with version 4 } Material mat = ResourcesDirectory.MakeCustomMaterial(mode, alpha); mat.color = color; return(mat); } else { return(ResourcesDirectory.MakeCustomMaterial(mode)); } } else { warnings.Add("Error reading material"); return(ReadWorldFile.missingMaterial); } }
private Material ReadMaterial(MessagePackObjectDictionary matDict, bool alpha) { if (matDict.ContainsKey(FileKeys.MATERIAL_NAME)) { string name = matDict[FileKeys.MATERIAL_NAME].AsString(); foreach (string dirEntry in ResourcesDirectory.dirList) { if (dirEntry.Length <= 2) { continue; } string newDirEntry = dirEntry.Substring(2); string checkFileName = Path.GetFileNameWithoutExtension(newDirEntry); if ((!editor) && checkFileName.StartsWith("$")) // special alternate materials for game { checkFileName = checkFileName.Substring(1); } if (checkFileName == name) { return(ResourcesDirectory.GetMaterial(newDirEntry)); } } warnings.Add("Unrecognized material: " + name); return(ReadWorldFile.missingMaterial); } else if (matDict.ContainsKey(FileKeys.MATERIAL_MODE)) { ColorMode mode = (ColorMode)System.Enum.Parse(typeof(ColorMode), matDict[FileKeys.MATERIAL_MODE].AsString()); if (matDict.ContainsKey(FileKeys.MATERIAL_COLOR)) { Color color = ReadColor(matDict[FileKeys.MATERIAL_COLOR]); if (matDict.ContainsKey(FileKeys.MATERIAL_ALPHA)) { alpha = matDict[FileKeys.MATERIAL_ALPHA].AsBoolean(); } Material mat = ResourcesDirectory.MakeCustomMaterial(mode, alpha); mat.color = color; return(mat); } else { return(ResourcesDirectory.MakeCustomMaterial(mode)); } } else { warnings.Add("Error reading material"); return(ReadWorldFile.missingMaterial); } }
private void MaterialSelected(Material material) { highlightMaterial = material; if (handler != null) { if (material != null && material.name.EndsWith(PREVIEW_SUFFIX)) { string newPath = materialDirectory + "/" + material.name.Substring(0, material.name.Length - PREVIEW_SUFFIX.Length); material = ResourcesDirectory.GetMaterial(newPath); } handler(material); } if (closeOnSelect) { Destroy(this); } }
void UpdateMaterialDirectory() { materialSubDirectories = new List <string>(); if (materialDirectory != rootDirectory) { materialSubDirectories.Add(BACK_BUTTON); } materials = new List <Material>(); foreach (string dirEntry in ResourcesDirectory.dirList) { if (dirEntry.Length <= 2) { continue; } string newDirEntry = dirEntry.Substring(2); string fileName = Path.GetFileName(newDirEntry); string extension = Path.GetExtension(newDirEntry); string directory = Path.GetDirectoryName(newDirEntry); if (fileName.StartsWith("$")) { continue; // special alternate materials for game } if (directory != materialDirectory) { continue; } if (extension == "") { materialSubDirectories.Add(fileName); } else if (extension == ".mat") { if (fileName.EndsWith(PREVIEW_SUFFIX_EXT)) { materials.RemoveAt(materials.Count - 1); // special preview material which replaces the previous } materials.Add(ResourcesDirectory.GetMaterial(newDirEntry)); } } AssetManager.UnusedAssets(); }