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


C# Texture2D.Any方法代码示例

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


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

示例1: load

        /**
         * Post-load initialisation.
         */
        public void load()
        {
            Texture2D[] envMapFaces = new Texture2D[6];

              foreach (GameDatabase.TextureInfo texInfo in GameDatabase.Instance.databaseTexture)
              {
            Texture2D texture = texInfo.texture;
            if (texture == null || !texture.name.StartsWith(DIR_ENVMAP, System.StringComparison.Ordinal))
              continue;

            string originalName = texture.name.Substring(DIR_ENVMAP.Length);

            switch (originalName)
            {
              case "PositiveX":
            envMapFaces[0] = texture;
            break;
              case "NegativeX":
            envMapFaces[1] = texture;
            break;
              case "PositiveY":
            envMapFaces[2] = texture;
            break;
              case "NegativeY":
            envMapFaces[3] = texture;
            break;
              case "PositiveZ":
            envMapFaces[4] = texture;
            break;
              case "NegativeZ":
            envMapFaces[5] = texture;
            break;
              default:
            Util.log("Invalid enironment map texture name {0}", texture.name);
            break;
            }
              }

              // Generate generic reflection cube map texture.
              if (envMapFaces.Any(t => t == null))
              {
            Util.log("Some environment map faces are missing. Static reflections disabled.");
              }
              else
              {
            int envMapSize = envMapFaces[0].width;

            if (envMapFaces.Any(t => t.width != envMapSize || t.height != envMapSize)
            || envMapFaces.Any(t => !Util.isPow2(t.width) || !Util.isPow2(t.height)))
            {
              Util.log("Invalid environment map faces. Static reflections disabled.");
            }
            else
            {
              try
              {
            staticEnvMap = new Cubemap(envMapSize, TextureFormat.RGB24, true);
            staticEnvMap.hideFlags = HideFlags.HideAndDontSave;
            staticEnvMap.wrapMode = TextureWrapMode.Clamp;
            staticEnvMap.SetPixels(envMapFaces[0].GetPixels(), CubemapFace.PositiveX);
            staticEnvMap.SetPixels(envMapFaces[1].GetPixels(), CubemapFace.NegativeX);
            staticEnvMap.SetPixels(envMapFaces[2].GetPixels(), CubemapFace.PositiveY);
            staticEnvMap.SetPixels(envMapFaces[3].GetPixels(), CubemapFace.NegativeY);
            staticEnvMap.SetPixels(envMapFaces[4].GetPixels(), CubemapFace.PositiveZ);
            staticEnvMap.SetPixels(envMapFaces[5].GetPixels(), CubemapFace.NegativeZ);
            staticEnvMap.Apply(true, false);

            Util.log("Static environment map cube texture generated.");
              }
              catch (UnityException)
              {
            if (staticEnvMap != null)
              Object.DestroyImmediate(staticEnvMap);

            staticEnvMap = null;

            Util.log("Failed to set up static reflections. Textures not readable?");
              }
            }
              }

              try
              {
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream stream = assembly.GetManifestResourceStream("TextureReplacer.Visor-compiled.shader");
            StreamReader reader = new StreamReader(stream);

            shaderMaterial = new Material(reader.ReadToEnd());
            visorShader = shaderMaterial.shader;

            Util.log("Visor shader sucessfully compiled.");
              }
              catch
              {
            isVisorReflectionEnabled = false;
            Util.log("Visor shader loading failed. Visor reflections disabled.");
              }
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:TextureReplacer,代码行数:101,代码来源:Reflections.cs


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