当前位置: 首页 > news >正文

去哪个网站做吃播简单的网站建设怎么做

去哪个网站做吃播,简单的网站建设怎么做,网站首页设计教程,网店代运营代理Unity Shader编辑器工具类ShaderUtil 常用函数和用法 Unity的Shader编辑器工具类ShaderUtil提供了一系列函数#xff0c;用于编译、导入和管理着色器。本文将介绍ShaderUtil类中的常用函数和用法。 编译和导入函数 CompileShader 函数签名#xff1a;public static bool C…Unity Shader编辑器工具类ShaderUtil 常用函数和用法 Unity的Shader编辑器工具类ShaderUtil提供了一系列函数用于编译、导入和管理着色器。本文将介绍ShaderUtil类中的常用函数和用法。 编译和导入函数 CompileShader 函数签名public static bool CompileShader(string source, out string error); CompileShader函数用于编译一个着色器。它接受一个字符串参数source表示要编译的着色器代码返回一个布尔值表示编译是否成功。如果编译失败可以通过out参数error获取错误信息。 以下是一个使用CompileShader函数的示例 string shaderCode Shader CustomShader {// 着色器代码} ;string error; bool success ShaderUtil.CompileShader(shaderCode, out error);if (success) {Debug.Log(Shader compiled successfully!); } else {Debug.LogError(Shader compilation failed: error); } OpenCompiledShader 函数签名public static void OpenCompiledShader(string pathName, int line); OpenCompiledShader函数用于在外部程序中打开已编译的着色器文件。它接受两个参数pathName表示要打开的着色器文件的路径line表示要跳转到的行数。 以下是一个使用OpenCompiledShader函数的示例 string shaderPath Assets/Shaders/CustomShader.shader; int line 10;ShaderUtil.OpenCompiledShader(shaderPath, line); 属性和关键字函数 GetPropertyCount 函数签名public static int GetPropertyCount(Shader shader); 这个函数用于获取指定着色器中属性的数量。它接受一个Shader对象作为参数并返回该着色器中属性的数量。属性是在Shader编辑器中定义的变量用于控制材质的外观和行为。 以下是一个示例代码演示了如何使用GetPropertyCount函数获取着色器中属性的数量 Shader shader Shader.Find(MyShader); int propertyCount ShaderUtil.GetPropertyCount(shader); Debug.Log(Property count: propertyCount); GetPropertyName 函数签名public static string GetPropertyName(Shader shader, int propertyIndex); 这个函数用于获取指定着色器中属性的名称。它接受一个Shader对象和属性的索引作为参数并返回该属性的名称。 以下是一个示例代码演示了如何使用GetPropertyName函数获取着色器中属性的名称 Shader shader Shader.Find(MyShader); int propertyIndex 0; string propertyName ShaderUtil.GetPropertyName(shader, propertyIndex); Debug.Log(Property name: propertyName); GetShaderKeywords 函数签名public static string[] GetShaderKeywords(Shader shader); 这个函数用于获取指定着色器的关键字。关键字是在Shader编辑器中定义的标识符用于控制着色器的不同功能和效果。 以下是一个示例代码演示了如何使用GetShaderKeywords函数获取着色器的关键字 Shader shader Shader.Find(MyShader); string[] keywords ShaderUtil.GetShaderKeywords(shader); Debug.Log(Shader keywords: string.Join(, , keywords)); SetShaderKeywords 函数签名 public static void SetShaderKeywords(Shader shader, string[] keywords); 这个函数用于设置指定着色器的关键字。它接受一个Shader对象和一个关键字数组作为参数并将这些关键字应用到着色器上。 以下是一个示例代码演示了如何使用SetShaderKeywords函数设置着色器的关键字 Shader shader Shader.Find(MyShader); string[] keywords new string[] { KEYWORD1, KEYWORD2 }; ShaderUtil.SetShaderKeywords(shader, keywords); 渲染纹理函数 1. GetRenderTextureFormat public static RenderTextureFormat GetRenderTextureFormat(string name); 该函数用于获取指定名称的渲染纹理格式。它接受一个字符串参数name表示渲染纹理的名称返回一个RenderTextureFormat枚举值表示对应的渲染纹理格式。 2. GetRenderTargetCount public static int GetRenderTargetCount(); 该函数用于获取当前渲染目标的数量。它返回一个整数值表示当前渲染目标的数量。 3. GetRenderTargetName public static string GetRenderTargetName(int index); 该函数用于获取指定索引的渲染目标的名称。它接受一个整数参数index表示渲染目标的索引返回一个字符串值表示对应渲染目标的名称。 4. GetRenderTargetPropertyCount public static int GetRenderTargetPropertyCount(int index); 该函数用于获取指定渲染目标的属性数量。它接受一个整数参数index表示渲染目标的索引返回一个整数值表示对应渲染目标的属性数量。 5. GetRenderTargetPropertyName public static string GetRenderTargetPropertyName(int index, int propIndex); 该函数用于获取指定渲染目标的属性名称。它接受两个整数参数index和propIndex分别表示渲染目标的索引和属性的索引返回一个字符串值表示对应属性的名称。 6. GetRenderTargetPropertyType public static ShaderUtil.ShaderPropertyType GetRenderTargetPropertyType(int index, int propIndex); 该函数用于获取指定渲染目标的属性类型。它接受两个整数参数index和propIndex分别表示渲染目标的索引和属性的索引返回一个ShaderUtil.ShaderPropertyType枚举值表示对应属性的类型。 7. GetRenderTargetPropertyValue public static float GetRenderTargetPropertyValue(int index, int propIndex); 该函数用于获取指定渲染目标的属性值。它接受两个整数参数index和propIndex分别表示渲染目标的索引和属性的索引返回一个浮点数值表示对应属性的值。 8. SetRenderTargetPropertyCount public static void SetRenderTargetPropertyCount(int index, int count); 该函数用于设置指定渲染目标的属性数量。它接受两个整数参数index和count分别表示渲染目标的索引和属性的数量。 9. SetRenderTargetPropertyName public static void SetRenderTargetPropertyName(int index, int propIndex, string name); 该函数用于设置指定渲染目标的属性名称。它接受三个参数index、propIndex和name分别表示渲染目标的索引、属性的索引和属性的名称。 10. SetRenderTargetPropertyType public static void SetRenderTargetPropertyType(int index, int propIndex, ShaderUtil.ShaderPropertyType type); 该函数用于设置指定渲染目标的属性类型。它接受三个参数index、propIndex和type分别表示渲染目标的索引、属性的索引和属性的类型。 11. SetRenderTargetPropertyValue public static void SetRenderTargetPropertyValue(int index, int propIndex, float value); 该函数用于设置指定渲染目标的属性值。它接受三个参数index、propIndex和value分别表示渲染目标的索引、属性的索引和属性的值。 示例代码 using UnityEngine;public class ShaderUtilExample : MonoBehaviour {void Start(){// 获取渲染纹理格式RenderTextureFormat format ShaderUtil.GetRenderTextureFormat(MyRenderTexture);Debug.Log(RenderTexture format: format);// 获取渲染目标数量int targetCount ShaderUtil.GetRenderTargetCount();Debug.Log(Render target count: targetCount);// 获取渲染目标名称string targetName ShaderUtil.GetRenderTargetName(0);Debug.Log(Render target name: targetName);// 获取渲染目标属性数量int propertyCount ShaderUtil.GetRenderTargetPropertyCount(0);Debug.Log(Render target property count: propertyCount);// 获取渲染目标属性名称string propertyName ShaderUtil.GetRenderTargetPropertyName(0, 0);Debug.Log(Render target property name: propertyName);// 获取渲染目标属性类型ShaderUtil.ShaderPropertyType propertyType ShaderUtil.GetRenderTargetPropertyType(0, 0);Debug.Log(Render target property type: propertyType);// 获取渲染目标属性值float propertyValue ShaderUtil.GetRenderTargetPropertyValue(0, 0);Debug.Log(Render target property value: propertyValue);// 设置渲染目标属性数量ShaderUtil.SetRenderTargetPropertyCount(0, 2);// 设置渲染目标属性名称ShaderUtil.SetRenderTargetPropertyName(0, 0, Property1);ShaderUtil.SetRenderTargetPropertyName(0, 1, Property2);// 设置渲染目标属性类型ShaderUtil.SetRenderTargetPropertyType(0, 0, ShaderUtil.ShaderPropertyType.Float);ShaderUtil.SetRenderTargetPropertyType(0, 1, ShaderUtil.ShaderPropertyType.Color);// 设置渲染目标属性值ShaderUtil.SetRenderTargetPropertyValue(0, 0, 1.0f);ShaderUtil.SetRenderTargetPropertyValue(0, 1, Color.red);} } 其他函数 GetMaterial public static Material GetMaterial(Renderer renderer, int materialIndex); 该函数用于获取指定渲染器Renderer上指定索引materialIndex的材质Material实例。在Unity中渲染器可以包含多个材质每个材质对应一个子网格SubMesh。以下是一个使用示例 Renderer renderer GetComponentRenderer(); Material material ShaderUtil.GetMaterial(renderer, 0); GetMaterialProperty public static float GetMaterialProperty(Material material, int propertyIndex); public static Vector4 GetMaterialProperty(Material material, int propertyIndex, bool isBatchable); 这个函数用于获取材质Material上指定索引propertyIndex的属性Property的值。属性可以是浮点数、向量等类型。以下是一个使用示例 Material material GetComponentRenderer().material; float floatValue ShaderUtil.GetMaterialProperty(material, 0); Vector4 vectorValue ShaderUtil.GetMaterialProperty(material, 1); GetMaterialPropertyIndex public static int GetMaterialPropertyIndex(Material material, string propertyName); 该函数用于获取材质Material上指定属性propertyName的索引propertyIndex。以下是一个使用示例 Material material GetComponentRenderer().material; int propertyIndex ShaderUtil.GetMaterialPropertyIndex(material, _Color); GetMaterialPropertyType public static ShaderUtil.ShaderPropertyType GetMaterialPropertyType(Material material, int propertyIndex); 这个函数用于获取材质Material上指定索引propertyIndex的属性Property的类型ShaderPropertyType。以下是一个使用示例 Material material GetComponentRenderer().material; ShaderUtil.ShaderPropertyType propertyType ShaderUtil.GetMaterialPropertyType(material, 0); GetMaterialPropertyDefaultValue public static float GetMaterialPropertyDefaultValue(Material material, int propertyIndex); public static Vector4 GetMaterialPropertyDefaultValue(Material material, int propertyIndex, bool isBatchable); 该函数用于获取材质Material上指定索引propertyIndex的属性Property的默认值。以下是一个使用示例 Material material GetComponentRenderer().material; float defaultValue ShaderUtil.GetMaterialPropertyDefaultValue(material, 0); Vector4 defaultVector ShaderUtil.GetMaterialPropertyDefaultValue(material, 1); GetMaterialPropertyTextureDimension public static TextureDimension GetMaterialPropertyTextureDimension(Material material, int propertyIndex); 这个函数用于获取材质Material上指定索引propertyIndex的纹理属性Texture Property的维度TextureDimension。以下是一个使用示例 Material material GetComponentRenderer().material; TextureDimension dimension ShaderUtil.GetMaterialPropertyTextureDimension(material, 0); GetMaterialPropertyTextureDefaultName public static string GetMaterialPropertyTextureDefaultName(Material material, int propertyIndex); 该函数用于获取材质Material上指定索引propertyIndex的纹理属性Texture Property的默认名称。以下是一个使用示例 Material material GetComponentRenderer().material; string defaultName ShaderUtil.GetMaterialPropertyTextureDefaultName(material, 0); GetGlobalFloat public static float GetGlobalFloat(string name); 这个函数用于获取全局浮点数属性Global Float Property的值。以下是一个使用示例 float globalFloat ShaderUtil.GetGlobalFloat(_MyGlobalFloat); GetGlobalInt public static int GetGlobalInt(string name); 该函数用于获取全局整数属性Global Int Property的值。以下是一个使用示例 int globalInt ShaderUtil.GetGlobalInt(_MyGlobalInt); GetGlobalVector public static Vector4 GetGlobalVector(string name); 这个函数用于获取全局向量属性Global Vector Property的值。以下是一个使用示例 Vector4 globalVector ShaderUtil.GetGlobalVector(_MyGlobalVector); GetGlobalMatrix public static Matrix4x4 GetGlobalMatrix(string name); 该函数用于获取全局矩阵属性Global Matrix Property的值。以下是一个使用示例 Matrix4x4 globalMatrix ShaderUtil.GetGlobalMatrix(_MyGlobalMatrix); GetGlobalTexture public static Texture GetGlobalTexture(string name); 这个函数用于获取全局纹理属性Global Texture Property的值。以下是一个使用示例 Texture globalTexture ShaderUtil.GetGlobalTexture(_MyGlobalTexture); SetGlobalFloat public static void SetGlobalFloat(string name, float value); 该函数用于设置全局浮点数属性Global Float Property的值。以下是一个使用示例 ShaderUtil.SetGlobalFloat(_MyGlobalFloat, 1.5f); 这将把名为_MyGlobalFloat的全局浮点数属性设置为1.5。 SetGlobalInt public static void SetGlobalInt(string name, int value); 这个函数用于设置全局整数属性Global Int Property的值。以下是一个使用示例 ShaderUtil.SetGlobalInt(_MyGlobalInt, 10); 这将把名为_MyGlobalInt的全局整数属性设置为10。 SetGlobalVector public static void SetGlobalVector(string name, Vector4 value); 该函数用于设置全局向量属性Global Vector Property的值。以下是一个使用示例 ShaderUtil.SetGlobalVector(_MyGlobalVector, new Vector4(1, 2, 3, 4)); 这将把名为_MyGlobalVector的全局向量属性设置为(1, 2, 3, 4)。 SetGlobalMatrix public static void SetGlobalMatrix(string name, Matrix4x4 value); 这个函数用于设置全局矩阵属性Global Matrix Property的值。以下是一个使用示例 Matrix4x4 matrix Matrix4x4.identity; ShaderUtil.SetGlobalMatrix(_MyGlobalMatrix, matrix); 这将把名为_MyGlobalMatrix的全局矩阵属性设置为单位矩阵。 SetGlobalTexture public static void SetGlobalTexture(string name, Texture value); 该函数用于设置全局纹理属性Global Texture Property的值。以下是一个使用示例 Texture texture Resources.LoadTexture(MyTexture); ShaderUtil.SetGlobalTexture(_MyGlobalTexture, texture); 这将把名为_MyGlobalTexture的全局纹理属性设置为名为MyTexture的资源纹理。 我对技术文章中可能存在的错误向您表示诚挚的歉意。我努力确保提供准确可靠的信息但由于技术领域的不断变化错误难以避免。如果您发现了错误或有任何疑问请与我联系。我将竭尽全力纠正错误并提供更准确的信息。 再次向您表示最诚挚的歉意我将更加谨慎地审查和更新文章以提供更好的阅读体验和准确的技术信息。 谢谢您的理解和支持。
http://www.w-s-a.com/news/56338/

相关文章:

  • asp.net网站发布到虚拟主机电商设计网站哪个好
  • 做的网站怎么转成网址链接企业为什么要找会计
  • 关于建设网站的情况说明书文化建设方面的建议
  • 订票网站开发公司大通证券手机版下载官方网站下载
  • 网店美工的意义与发展佛山推广seo排名
  • 网站在建设中模板自助云商城
  • 珠海网站设计建建建设网站公司网站
  • 广州高端网站制作公司哪家好网页制作公司 软件
  • 最快做网站的语言百度站长反馈
  • 简单网站设计价格手机网站技巧
  • 什么颜色做网站显的大气网站建设的含盖哪方面
  • 没网站怎么做二维码扫描连接济南做网站推广哪家好
  • 台州建设规划局网站搞外贸一般是干什么的
  • 怎么提高自己网站的知名度电子商务是建网站
  • 官方查企业的网站办公用品网站建设策划书
  • 微信网站搭建哪家好网站中转页
  • 阿里巴巴网站开发是谁长沙自助模板建站
  • 阿里云网站方案建设书网络公司运营是干啥的
  • 南通seo网站排名优化nginx wordpress rewrite
  • 网站做成软件做内部网站费用
  • 浙江企业网站建设网站域名有了 网站如何建设
  • 学编程哪个机构有权威德州做网站优化
  • 最火的网站开发语言福州网站建设服务商
  • 嘉兴网站制作哪里好asp网站源码免费版
  • 如何给网站配置域名百度网站统计添加网址
  • 搭建wap网站磁力引擎
  • 如何给公司网站做推广个人网站可以做社区吗
  • 网站建设为什么不给源代码大理如何做百度的网站
  • 网站代理违法吗网站备份流程
  • 免费域名查询网站wordpress wordfence