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

⭐ Unity 开发bug —— 打包后shader失效或者bug (我这里用Shader做两张图片的合并发现了问题)

1.这里我代码没啥问题~~~编辑器里也没毛病

 void Start(){// 加载底图和上层图片string backgroundImagePath = Application.streamingAssetsPath + "/background.jpg";Texture2D backgroundTexture = new Texture2D(2, 2);byte[] backgroundImageData = System.IO.File.ReadAllBytes(backgroundImagePath);backgroundTexture.LoadImage(backgroundImageData);string overlayImagePath = Application.streamingAssetsPath + "/1.png";Texture2D overlayTexture = new Texture2D(2, 2);byte[] overlayImageData = System.IO.File.ReadAllBytes(overlayImagePath);overlayTexture.LoadImage(overlayImageData);// 创建合成材质Material imageProcessingMaterial = new Material(Shader.Find("Custom/ImageProcessingShader"));imageProcessingMaterial.SetTexture("_MainTex", backgroundTexture);imageProcessingMaterial.SetTexture("_OverlayTex", overlayTexture);// 创建RenderTexture,并渲染到其中RenderTexture renderTexture = new RenderTexture(backgroundTexture.width, backgroundTexture.height, 0);Graphics.Blit(null, renderTexture, imageProcessingMaterial);// 将RenderTexture转换为Texture2DTexture2D outputTexture = new Texture2D(renderTexture.width, renderTexture.height, TextureFormat.RGBA32, false);RenderTexture.active = renderTexture;outputTexture.ReadPixels(new UnityEngine.Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);outputTexture.Apply();RenderTexture.active = null;// 显示处理后的图像raw.texture = outputTexture;}

2.但是打包完之后,原本要合并的图片却没有反应

3.解决方法如下:

选择Edit->ProjectSettings->Graphics:

在ProjectSettings里面的Graphics,Always Included Shaders数组更改size,并将所需用到的Shader拖入其中

相关文章:

  • php获取过去一段的时间范围
  • repo常用命令解析(持续更新)
  • 公网穿透和RTC
  • 【HuggingFace Transformer库学习笔记】基础组件学习:Tokenizer
  • 【Excel】WPS快速按某列查重数据
  • 安装vscode插件与安装vue项目
  • 4-Docker命令之docker kill
  • 45. 跳跃游戏 II
  • SCI一区级 | Matlab实现GWO-CNN-LSTM-selfAttention多变量多步时间序列预测
  • C语言:写一个函数,输入一个十六进制数,输出相应的十进制数
  • 手敲单链表,简单了解其运行逻辑
  • 用户反馈组件实现(Vue3+ElementPlus)含图片拖拽上传
  • Mybatis-Plus实现分页查询
  • Jquery动画特效
  • 【详解】Spark数据倾斜问题由基础到深入详解-完美理解-费元星
  • ➹使用webpack配置多页面应用(MPA)
  • 2019年如何成为全栈工程师?
  • Docker: 容器互访的三种方式
  • interface和setter,getter
  • LeetCode18.四数之和 JavaScript
  • nginx 配置多 域名 + 多 https
  • Python 反序列化安全问题(二)
  • Rancher-k8s加速安装文档
  • Vue2.x学习三:事件处理生命周期钩子
  • WinRAR存在严重的安全漏洞影响5亿用户
  • 案例分享〡三拾众筹持续交付开发流程支撑创新业务
  • 闭包--闭包作用之保存(一)
  • 官方新出的 Kotlin 扩展库 KTX,到底帮你干了什么?
  • 前端路由实现-history
  • 前端面试题总结
  • 让你的分享飞起来——极光推出社会化分享组件
  • 算法之不定期更新(一)(2018-04-12)
  • 运行时添加log4j2的appender
  • postgresql行列转换函数
  • 阿里云API、SDK和CLI应用实践方案
  • ​软考-高级-系统架构设计师教程(清华第2版)【第1章-绪论-思维导图】​
  • #if #elif #endif
  • (+4)2.2UML建模图
  • (第8天)保姆级 PL/SQL Developer 安装与配置
  • (顶刊)一个基于分类代理模型的超多目标优化算法
  • (蓝桥杯每日一题)平方末尾及补充(常用的字符串函数功能)
  • (一)eclipse Dynamic web project 工程目录以及文件路径问题
  • (一)硬件制作--从零开始自制linux掌上电脑(F1C200S) <嵌入式项目>
  • (转)jdk与jre的区别
  • (转)Sublime Text3配置Lua运行环境
  • (轉貼) 寄發紅帖基本原則(教育部禮儀司頒布) (雜項)
  • **登录+JWT+异常处理+拦截器+ThreadLocal-开发思想与代码实现**
  • .NET 6 Mysql Canal (CDC 增量同步,捕获变更数据) 案例版
  • .NET Standard 的管理策略
  • .NET6实现破解Modbus poll点表配置文件
  • .NET程序员迈向卓越的必由之路
  • .Net组件程序设计之线程、并发管理(一)
  • .pings勒索病毒的威胁:如何应对.pings勒索病毒的突袭?
  • ::什么意思
  • [20161214]如何确定dbid.txt