コード例 #1
0
ファイル: TextureManager.cs プロジェクト: WChrisK/HelionUnity
        private static bool TryCreateAnyNamespaceTexture(UpperString name, out Texture texture,
                                                         out ResourceNamespace newNamespace)
        {
            if (loadedImages.TryGetAnyValue(name, out RgbaImage loadedImage, out newNamespace))
            {
                texture = CreateAndTrackTexture(name, newNamespace, loadedImage);
                return(true);
            }

            if (TextureDefinitionManager.TryGetAny(name, out TextureDefinition definition, out ResourceNamespace definitionNamespace))
            {
                RgbaImage compiledImage = TextureDefinitionToImage(definition);
                loadedImages.Add(name, definitionNamespace, compiledImage);
                texture = CreateAndTrackTexture(name, definitionNamespace, compiledImage);
                return(true);
            }

            if (Data.TryFindAny(name, out IEntry entry))
            {
                if (TryReadImageEntry(entry, entry.Namespace, out RgbaImage newImage))
                {
                    loadedImages.Add(name, entry.Namespace, newImage);
                    texture = CreateAndTrackTexture(name, entry.Namespace, newImage);
                    return(true);
                }
            }

            texture      = null;
            newNamespace = ResourceNamespace.Global;
            return(false);
        }
コード例 #2
0
ファイル: TextureManager.cs プロジェクト: WChrisK/HelionUnity
        public static bool TryGetTexture(UpperString name, ResourceNamespace priorityNamespace,
                                         out Texture texture)
        {
            if (textures.TryGetValue(name, priorityNamespace, out texture))
            {
                return(true);
            }

            // This is a heuristic to make failed lookups less expensive, as
            // there is a lot of work done to create the texture if it does
            // not exist after this.
            if (missingTextureNames.Contains(name))
            {
                texture = NullTexture;
                return(false);
            }

            if (TryCreateExactNamespaceTexture(name, priorityNamespace, out texture))
            {
                textures.Add(name, priorityNamespace, texture);
                return(true);
            }

            if (textures.TryGetAnyValue(name, out texture, out _))
            {
                return(true);
            }

            if (TryCreateAnyNamespaceTexture(name, out texture, out ResourceNamespace newNamespace))
            {
                textures.Add(name, newNamespace, texture);
                return(true);
            }

            missingTextureNames.Add(name);

            texture = NullTexture;
            return(false);
        }
コード例 #3
0
 public static bool TryGetAny(UpperString name, out TextureDefinition definition,
                              out ResourceNamespace resourceNamespace)
 {
     return(textureDefinitions.TryGetAnyValue(name, out definition, out resourceNamespace));
 }