当前位置: 首页>>代码示例>>C#>>正文


C# Texture2D.LoadImage方法代码示例

本文整理汇总了C#中Texture2D.LoadImage方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.LoadImage方法的具体用法?C# Texture2D.LoadImage怎么用?C# Texture2D.LoadImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture2D的用法示例。


在下文中一共展示了Texture2D.LoadImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupFootprintPrefab

        private static void SetupFootprintPrefab()
        {
            footprintPrefab = new GameObject ("KerbalEVAFootprint");
            footprintPrefab.layer = GameLayers.LocalSpace;
            footprintPrefab.SetActive (false);

            var mf = footprintPrefab.AddComponent<MeshFilter> ();
            var mr = footprintPrefab.AddComponent<MeshRenderer> ();

            mf.mesh = new Quad (0.15f, 0.3f, true);

            var material = new Material (Shaders.Footprint);
            var footprintMask = new Texture2D (4, 4);
            footprintMask.LoadImage (Textures.KerbalEVAFootprintMask);
            material.SetTexture ("_MainTex", footprintMask);
            material.SetFloat ("_Opacity", 0.8f);
            material.SetColor ("_Color", Color.black);
            mr.material = material;
            mr.castShadows = false;

            footprintPrefab.AddComponent<KerbalEVAFootprint> ();

            Utils.Log ("Footprint prefab created");
        }
开发者ID:HappyFaceIndustries,项目名称:KopernicusExpansion,代码行数:24,代码来源:EVAFootprintsLoader.cs

示例2: LoadTexture


//.........这里部分代码省略.........
                                    }
                                    else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDXT5)
                                    {
                                        map = new Texture2D((int)dDSHeader.dwWidth, (int)dDSHeader.dwHeight, TextureFormat.DXT5, mipmap);
                                        map.LoadRawTextureData(LoadRestOfReader(binaryReader));
                                    }
                                    else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDXT2)
                                    {
                                        Debug.Log("[Kopernicus]: DXT2 not supported" + path);
                                    }
                                    else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDXT4)
                                    {
                                        Debug.Log("[Kopernicus]: DXT4 not supported: " + path);
                                    }
                                    else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDX10)
                                    {
                                        Debug.Log("[Kopernicus]: DX10 dds not supported: " + path);
                                    }
                                    else
                                        fourcc = false;
                                }
                                if (!fourcc)
                                {
                                    TextureFormat textureFormat = TextureFormat.ARGB32;
                                    bool ok = true;
                                    if (rgb && (rgb888 /*|| bgr888*/))
                                    {
                                        // RGB or RGBA format
                                        textureFormat = alphapixel
                                        ? TextureFormat.RGBA32
                                        : TextureFormat.RGB24;
                                    }
                                    else if (rgb && rgb565)
                                    {
                                        // Nvidia texconv B5G6R5_UNORM
                                        textureFormat = TextureFormat.RGB565;
                                    }
                                    else if (rgb && alphapixel && argb4444)
                                    {
                                        // Nvidia texconv B4G4R4A4_UNORM
                                        textureFormat = TextureFormat.ARGB4444;
                                    }
                                    else if (rgb && alphapixel && rbga4444)
                                    {
                                        textureFormat = TextureFormat.RGBA4444;
                                    }
                                    else if (!rgb && alpha != luminance)
                                    {
                                        // A8 format or Luminance 8
                                        textureFormat = TextureFormat.Alpha8;
                                    }
                                    else
                                    {
                                        ok = false;
                                        Debug.Log("[Kopernicus]: Only DXT1, DXT5, A8, RGB24, RGBA32, RGB565, ARGB4444 and RGBA4444 are supported");
                                    }
                                    if (ok)
                                    {
                                        map = new Texture2D((int)dDSHeader.dwWidth, (int)dDSHeader.dwHeight, textureFormat, mipmap);
                                        map.LoadRawTextureData(LoadRestOfReader(binaryReader));
                                    }

                                }
                                if (map != null)
                                    if (upload)
                                        map.Apply(false, unreadable);
                            }
                            else
                                Debug.Log("[Kopernicus]: Bad DDS header.");
                        }
                        else
                        {
                            map = new Texture2D(2, 2);
                            byte[] data = LoadWholeFile(path);
                            if (data == null)
                                throw new Exception("LoadWholeFile failed");

                            map.LoadImage(data);
                            if (compress)
                                map.Compress(true);
                            if (upload)
                                map.Apply(false, unreadable);
                        }
                    }
                    catch (Exception ex)
                    {
                        uncaught = false;
                        Debug.Log("[Kopernicus]: failed to load " + path + " with exception " + ex.Message);
                    }
                    if (map == null && uncaught)
                    {
                        Debug.Log("[Kopernicus]: failed to load " + path);
                    }
                    map.name = path.Remove(0, (KSPUtil.ApplicationRootPath + "GameData/").Length);
                }
                else
                    Debug.Log("[Kopernicus]: texture does not exist! " + path);

                return map;
            }
开发者ID:FrancoisHarvey,项目名称:Kopernicus,代码行数:101,代码来源:OnDemandStorage.cs


注:本文中的Texture2D.LoadImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。