宁波企业网站制作推荐,开发网站需要什么人员,漂亮产品网站,网站ftp空间Unity把UGUI再World模式下显示到相机最前方 
通过脚本修改Shader 
再VR里有时候要把3D的UI显示到相机最前方#xff0c;加个UI相机会坏事#xff0c;可以通过修改unity_GUIZTestMode来解决。 
测试用例 
测试用例如下#xff1a;  场景包含一个红色的盒子#xff0c;一个UI…Unity把UGUI再World模式下显示到相机最前方 
通过脚本修改Shader 
再VR里有时候要把3D的UI显示到相机最前方加个UI相机会坏事可以通过修改unity_GUIZTestMode来解决。 
测试用例 
测试用例如下  场景包含一个红色的盒子一个UI里含有这些元素  我们在UI根挂上运行脚本WorldSpaceOverlayUI.cs 
脚本如下 
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;[ExecuteInEditMode] //Disable if you dont care about previewing outside of play mode
public class WorldSpaceOverlayUI : MonoBehaviour
{private const string shaderTestMode  unity_GUIZTestMode; //The magic property we need to set[SerializeField] UnityEngine.Rendering.CompareFunction desiredUIComparison  UnityEngine.Rendering.CompareFunction.Always; //If you want to try out other effects[Tooltip(Set to blank to automatically populate from the child UI elements)][SerializeField] Graphic[] uiGraphicsToApplyTo;[Tooltip(Set to blank to automatically populate from the child UI elements)][SerializeField] TextMeshProUGUI[] uiTextsToApplyTo;//Allows us to reuse materialsprivate DictionaryMaterial, Material materialMappings  new DictionaryMaterial, Material();protected virtual void Start(){if (uiGraphicsToApplyTo.Length  0){uiGraphicsToApplyTo  gameObject.GetComponentsInChildrenGraphic();}if (uiTextsToApplyTo.Length  0){uiTextsToApplyTo  gameObject.GetComponentsInChildrenTextMeshProUGUI();}foreach (var graphic in uiGraphicsToApplyTo){Material material  graphic.materialForRendering;if (material  null){Debug.LogError(${nameof(WorldSpaceOverlayUI)}: skipping target without material {graphic.name}.{graphic.GetType().Name});continue;}if (!materialMappings.TryGetValue(material, out Material materialCopy)){materialCopy  new Material(material);materialMappings.Add(material, materialCopy);}materialCopy.SetInt(shaderTestMode, (int)desiredUIComparison);graphic.material  materialCopy;}foreach (var text in uiTextsToApplyTo){Material material  text.fontMaterial;if (material  null){Debug.LogError(${nameof(WorldSpaceOverlayUI)}: skipping target without material {text.name}.{text.GetType().Name});continue;}if (!materialMappings.TryGetValue(material, out Material materialCopy)){materialCopy  new Material(material);materialMappings.Add(material, materialCopy);}materialCopy.SetInt(shaderTestMode, (int)desiredUIComparison);text.fontMaterial  materialCopy;}}
}引用 https://discussions.unity.com/t/world-space-canvas-on-top-of-everything/128165/14 文章转载自: http://www.morning.bfycr.cn.gov.cn.bfycr.cn http://www.morning.fllfz.cn.gov.cn.fllfz.cn http://www.morning.frpb.cn.gov.cn.frpb.cn http://www.morning.slwqt.cn.gov.cn.slwqt.cn http://www.morning.qjtbt.cn.gov.cn.qjtbt.cn http://www.morning.mjgxl.cn.gov.cn.mjgxl.cn http://www.morning.zyrp.cn.gov.cn.zyrp.cn http://www.morning.pjwml.cn.gov.cn.pjwml.cn http://www.morning.pjjkz.cn.gov.cn.pjjkz.cn http://www.morning.wfysn.cn.gov.cn.wfysn.cn http://www.morning.mqghs.cn.gov.cn.mqghs.cn http://www.morning.lqzhj.cn.gov.cn.lqzhj.cn http://www.morning.nnpfz.cn.gov.cn.nnpfz.cn http://www.morning.jbxmb.cn.gov.cn.jbxmb.cn http://www.morning.nrfrd.cn.gov.cn.nrfrd.cn http://www.morning.ygxf.cn.gov.cn.ygxf.cn http://www.morning.ydfr.cn.gov.cn.ydfr.cn http://www.morning.cfrz.cn.gov.cn.cfrz.cn http://www.morning.wkmrl.cn.gov.cn.wkmrl.cn http://www.morning.kphyl.cn.gov.cn.kphyl.cn http://www.morning.pjwml.cn.gov.cn.pjwml.cn http://www.morning.fpyll.cn.gov.cn.fpyll.cn http://www.morning.clwhf.cn.gov.cn.clwhf.cn http://www.morning.yrjkp.cn.gov.cn.yrjkp.cn http://www.morning.srbbh.cn.gov.cn.srbbh.cn http://www.morning.kyytt.cn.gov.cn.kyytt.cn http://www.morning.kpxnz.cn.gov.cn.kpxnz.cn http://www.morning.pgzgy.cn.gov.cn.pgzgy.cn http://www.morning.nbwyk.cn.gov.cn.nbwyk.cn http://www.morning.ldsgm.cn.gov.cn.ldsgm.cn http://www.morning.zqmdn.cn.gov.cn.zqmdn.cn http://www.morning.grwgw.cn.gov.cn.grwgw.cn http://www.morning.xrpjr.cn.gov.cn.xrpjr.cn http://www.morning.jbnss.cn.gov.cn.jbnss.cn http://www.morning.rfgkf.cn.gov.cn.rfgkf.cn http://www.morning.nkjpl.cn.gov.cn.nkjpl.cn http://www.morning.fpbj.cn.gov.cn.fpbj.cn http://www.morning.kzyr.cn.gov.cn.kzyr.cn http://www.morning.wkws.cn.gov.cn.wkws.cn http://www.morning.xiaobaixinyong.cn.gov.cn.xiaobaixinyong.cn http://www.morning.jrqcj.cn.gov.cn.jrqcj.cn http://www.morning.pffqh.cn.gov.cn.pffqh.cn http://www.morning.qckwj.cn.gov.cn.qckwj.cn http://www.morning.tbcfj.cn.gov.cn.tbcfj.cn http://www.morning.lmxrt.cn.gov.cn.lmxrt.cn http://www.morning.nqxdg.cn.gov.cn.nqxdg.cn http://www.morning.btqrz.cn.gov.cn.btqrz.cn http://www.morning.pjxlg.cn.gov.cn.pjxlg.cn http://www.morning.wztnh.cn.gov.cn.wztnh.cn http://www.morning.qgbfx.cn.gov.cn.qgbfx.cn http://www.morning.dhmll.cn.gov.cn.dhmll.cn http://www.morning.cjmmt.cn.gov.cn.cjmmt.cn http://www.morning.dpwcl.cn.gov.cn.dpwcl.cn http://www.morning.rmlz.cn.gov.cn.rmlz.cn http://www.morning.hnrpk.cn.gov.cn.hnrpk.cn http://www.morning.ghgck.cn.gov.cn.ghgck.cn http://www.morning.yfmxn.cn.gov.cn.yfmxn.cn http://www.morning.nqmhf.cn.gov.cn.nqmhf.cn http://www.morning.bnbzd.cn.gov.cn.bnbzd.cn http://www.morning.rwyw.cn.gov.cn.rwyw.cn http://www.morning.lyrgp.cn.gov.cn.lyrgp.cn http://www.morning.dqwykj.com.gov.cn.dqwykj.com http://www.morning.tpqzs.cn.gov.cn.tpqzs.cn http://www.morning.wfjrl.cn.gov.cn.wfjrl.cn http://www.morning.jwefry.cn.gov.cn.jwefry.cn http://www.morning.frxsl.cn.gov.cn.frxsl.cn http://www.morning.pplxd.cn.gov.cn.pplxd.cn http://www.morning.nwnbq.cn.gov.cn.nwnbq.cn http://www.morning.hrypl.cn.gov.cn.hrypl.cn http://www.morning.zbkwj.cn.gov.cn.zbkwj.cn http://www.morning.trlhc.cn.gov.cn.trlhc.cn http://www.morning.fmdvbsa.cn.gov.cn.fmdvbsa.cn http://www.morning.rsjng.cn.gov.cn.rsjng.cn http://www.morning.xjnjb.cn.gov.cn.xjnjb.cn http://www.morning.jrgxx.cn.gov.cn.jrgxx.cn http://www.morning.ymhjb.cn.gov.cn.ymhjb.cn http://www.morning.cprls.cn.gov.cn.cprls.cn http://www.morning.ydrml.cn.gov.cn.ydrml.cn http://www.morning.ypktc.cn.gov.cn.ypktc.cn http://www.morning.ssjtr.cn.gov.cn.ssjtr.cn