public Texture2D LoadTexture(string path, CreateTextureOptions options) { Ensure.That(nameof(path)).IsNotNull(path); Texture2D texture2D = Resources.Load <Texture2D>(path); return(texture2D); }
public static EditorTexture Load(IResourceProvider resources, string path, CreateTextureOptions options, bool required) { using (ProfilingUtility.SampleBlock("Load Editor Texture")) { Ensure.That(nameof(resources)).IsNotNull(resources); Ensure.That(nameof(path)).IsNotNull(path); var set = new EditorTexture(); var name = Path.GetFileNameWithoutExtension(path).PartBefore('@'); var extension = Path.GetExtension(path); var directory = Path.GetDirectoryName(path); var personalPath = Path.Combine(directory, $"{name}{extension}"); var professionalPath = Path.Combine(directory, $"{name}_Pro{extension}"); var texture = resources.LoadTexture(personalPath, options); if (texture != null) { set.personal.Add(texture.width, texture); } texture = resources.LoadTexture(professionalPath, options); if (texture != null) { set.professional.Add(texture.width, texture); } if (set.personal.Count == 0) { if (required) { Debug.LogWarning($"Missing editor texture: {name}\n{resources.DebugPath(path)}"); } // Never return an empty set; the codebase assumes this guarantee return(null); } set.textureName = path; return(set); } }
public Texture2D LoadTexture(string path, CreateTextureOptions options) { path = ResourceLoader.NormalizerPath(path); string name = $"{VISUAL_SCRIPTING_PACKAGE}.{path}"; Texture2D texture = LoadFromMemoryResources(name); if (texture == null) { byte[] textureData = ResourceLoader.LoadTexture(path); texture = new Texture2D(0, 0); texture.name = name; texture.alphaIsTransparency = options.alphaIsTransparency; texture.filterMode = options.filterMode; texture.hideFlags = options.hideFlags; texture.LoadImage(textureData); cache[name] = texture; } return(texture); }
public EditorTexture LoadTexture(string path, TextureResolution[] resolutions, CreateTextureOptions options, bool required = true) { return(EditorTexture.Load(providers, path, resolutions, options, required)); }
public static EditorTexture Load(IResourceProvider resources, string path, TextureResolution[] resolutions, CreateTextureOptions options, bool required) { using (ProfilingUtility.SampleBlock("Load Editor Texture")) { Ensure.That(nameof(resources)).IsNotNull(resources); Ensure.That(nameof(path)).IsNotNull(path); Ensure.That(nameof(resolutions)).HasItems(resolutions); var set = new EditorTexture(); // Try with explicit resolutions first foreach (var resolution in resolutions) { var width = resolution.width; // var height = resolution.height; var personalPath = String.Empty; var professionalPath = String.Empty; personalPath = resources.GetPersonalPath(path, width); professionalPath = resources.GetProfessionalPath(path, width); if (resources.FileExists(personalPath)) { var tex = resources.LoadTexture(personalPath, options); set.personal.Add(width, tex); } if (resources.FileExists(professionalPath)) { var tex = resources.LoadTexture(professionalPath, options); set.professional.Add(width, tex); } } if (set.personal.Count == 0) { if (required) { Debug.LogWarning($"Missing editor texture: {path}\n{resources.DebugPath(path)}"); } // Never return an empty set; the codebase assumes this guarantee return(null); } set.textureName = path; return(set); } }
public static EditorTexture Load(IEnumerable <IResourceProvider> resourceProviders, string path, TextureResolution[] resolutions, CreateTextureOptions options, bool required) { foreach (var resources in resourceProviders) { var texture = Load(resources, path, resolutions, options, false); if (texture != null) { return(texture); } } if (required) { var message = new StringBuilder(); message.AppendLine("Missing editor texture: "); foreach (var resources in resourceProviders) { message.AppendLine($"{resources.GetType().HumanName()}: {resources.DebugPath(path)}"); } Debug.LogWarning(message.ToString()); } return(null); }
public Texture2D LoadTexture(string path, CreateTextureOptions options) { return(LoadAsset <Texture2D>(path)); }
public static EditorTexture Load(IResourceProvider resources, string path, TextureResolution[] resolutions, CreateTextureOptions options, bool required) { using (ProfilingUtility.SampleBlock("Load Editor Texture")) { Ensure.That(nameof(resources)).IsNotNull(resources); Ensure.That(nameof(path)).IsNotNull(path); Ensure.That(nameof(resolutions)).HasItems(resolutions); var set = new EditorTexture(); var name = Path.GetFileNameWithoutExtension(path).PartBefore('@'); var extension = Path.GetExtension(path); var directory = Path.GetDirectoryName(path); // Try with explicit resolutions first foreach (var resolution in resolutions) { var width = resolution.width; // var height = resolution.height; var personalPath = Path.Combine(directory, $"{name}@{width}x{extension}"); var professionalPath = Path.Combine(directory, $"{name}_Pro@{width}x{extension}"); if (resources.FileExists(personalPath)) { set.personal.Add(width, resources.LoadTexture(personalPath, options)); } if (resources.FileExists(professionalPath)) { set.professional.Add(width, resources.LoadTexture(professionalPath, options)); } } if (set.personal.Count == 0) { if (required) { Debug.LogWarning($"Missing editor texture: {name}\n{resources.DebugPath(path)}"); } // Never return an empty set; the codebase assumes this guarantee return(null); } return(set); } }