Exemplo n.º 1
0
    private static Texture2D CreateIconWithMipLevels(GenerateIconsWithMipLevels.InputData inputData, string baseName, List <string> assetPathsOfAllIcons)
    {
        List <string>    list  = assetPathsOfAllIcons.FindAll((string o) => o.IndexOf('/' + baseName + inputData.mipIdentifier) >= 0);
        List <Texture2D> list2 = new List <Texture2D>();

        foreach (string current in list)
        {
            Texture2D texture2D = GenerateIconsWithMipLevels.GetTexture2D(current);
            if (texture2D != null)
            {
                list2.Add(texture2D);
            }
            else
            {
                Debug.LogError("Mip not found " + current);
            }
        }
        int num  = 99999;
        int num2 = 0;

        foreach (Texture2D current2 in list2)
        {
            int width = current2.width;
            if (width > num2)
            {
                num2 = width;
            }
            if (width < num)
            {
                num = width;
            }
        }
        if (num2 == 0)
        {
            return(null);
        }
        Texture2D texture2D2 = new Texture2D(num2, num2, TextureFormat.ARGB32, true, true);

        if (GenerateIconsWithMipLevels.BlitMip(texture2D2, inputData.GetMipFileName(baseName, num2), 0))
        {
            texture2D2.Apply(true);
            int num3 = num2;
            for (int i = 1; i < texture2D2.mipmapCount; i++)
            {
                num3 /= 2;
                if (num3 < num)
                {
                    break;
                }
                GenerateIconsWithMipLevels.BlitMip(texture2D2, inputData.GetMipFileName(baseName, num3), i);
            }
            texture2D2.Apply(false, true);
            return(texture2D2);
        }
        return(texture2D2);
    }
    private static bool BlitMip(Texture2D iconWithMips, string mipFile, int mipLevel)
    {
        Texture2D texture2D = GenerateIconsWithMipLevels.GetTexture2D(mipFile);

        if ((bool)((UnityEngine.Object)texture2D))
        {
            GenerateIconsWithMipLevels.Blit(texture2D, iconWithMips, mipLevel);
            return(true);
        }
        Debug.Log((object)("Mip file NOT found: " + mipFile));
        return(false);
    }
    private static Texture2D CreateIconWithMipLevels(GenerateIconsWithMipLevels.InputData inputData, string baseName, List <string> assetPathsOfAllIcons)
    {
        // ISSUE: object of a compiler-generated type is created
        // ISSUE: variable of a compiler-generated type
        GenerateIconsWithMipLevels.\u003CCreateIconWithMipLevels\u003Ec__AnonStorey39 levelsCAnonStorey39 = new GenerateIconsWithMipLevels.\u003CCreateIconWithMipLevels\u003Ec__AnonStorey39();
        // ISSUE: reference to a compiler-generated field
        levelsCAnonStorey39.baseName = baseName;
        // ISSUE: reference to a compiler-generated field
        levelsCAnonStorey39.inputData = inputData;
        // ISSUE: reference to a compiler-generated method
        List <string>    all           = assetPathsOfAllIcons.FindAll(new Predicate <string>(levelsCAnonStorey39.\u003C\u003Em__4F));
        List <Texture2D> texture2DList = new List <Texture2D>();

        using (List <string> .Enumerator enumerator = all.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                string    current   = enumerator.Current;
                Texture2D texture2D = GenerateIconsWithMipLevels.GetTexture2D(current);
                if ((UnityEngine.Object)texture2D != (UnityEngine.Object)null)
                {
                    texture2DList.Add(texture2D);
                }
                else
                {
                    Debug.LogError((object)("Mip not found " + current));
                }
            }
        }
        int num1 = 99999;
        int num2 = 0;

        using (List <Texture2D> .Enumerator enumerator = texture2DList.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                int width = enumerator.Current.width;
                if (width > num2)
                {
                    num2 = width;
                }
                if (width < num1)
                {
                    num1 = width;
                }
            }
        }
        if (num2 == 0)
        {
            return((Texture2D)null);
        }
        Texture2D iconWithMips = new Texture2D(num2, num2, TextureFormat.ARGB32, true, true);

        // ISSUE: reference to a compiler-generated field
        // ISSUE: reference to a compiler-generated field
        if (!GenerateIconsWithMipLevels.BlitMip(iconWithMips, levelsCAnonStorey39.inputData.GetMipFileName(levelsCAnonStorey39.baseName, num2), 0))
        {
            return(iconWithMips);
        }
        iconWithMips.Apply(true);
        int mipResolution = num2;

        for (int mipLevel = 1; mipLevel < iconWithMips.mipmapCount; ++mipLevel)
        {
            mipResolution /= 2;
            if (mipResolution >= num1)
            {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                GenerateIconsWithMipLevels.BlitMip(iconWithMips, levelsCAnonStorey39.inputData.GetMipFileName(levelsCAnonStorey39.baseName, mipResolution), mipLevel);
            }
            else
            {
                break;
            }
        }
        iconWithMips.Apply(false, true);
        return(iconWithMips);
    }