/// ///******************************************************** /// 作者: DDG /// 日期: 2024/10/21 09:16:34 /// 功能: Main场景UI ///******************************************************** /// using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using ZXKFramework; using RenderHeads.Media.AVProMovieCapture; public class MainWnd : UIBase { GameModel gameModel; /// /// 模型是否炸开 /// bool isBomb; /// /// 控制模型炸开与合并按钮 /// Button boomIO_Btn; Button lzIO_Btn; bool isLu; CaptureFromScreen cap; /// /// 返回首页按钮 /// Button home_Btn; /// /// 退出客户端按钮 /// Button exit_Btn; Button tip_But; Text ShowJieGouText; Image ShowJieGouPic; private Dictionary jiegouList = new(); GameManager gameManager; /// /// 控制透明滑动条 /// Slider touMingSlider; List zhuTi = new List(); /// /// 需要透视的材质球 /// //Material touShiMat; public override string GroupName => "MainWnd"; public override string Name => "MainWnd"; private void Start() { isLu = false; gameManager = GameManager.Instance; } void ChangeCamera() { Camera a = GameObject.Find("Camera").GetComponent(); GetComponentInParent().worldCamera = a; cap = GameObject.Find("LuShiPin").GetComponent(); } public override void Init(IUIManager uictrl) { base.Init(uictrl); Invoke("ChangeCamera", 0.2f); gameModel = MVC.GetModel(); isBomb = false; //touShiMat = GameManager.Instance.transform.FindFirst("石材").material; touMingSlider = transform.FindFirst("touMingSlider"); touMingSlider.onValueChanged.AddListener((c) => { foreach (GameObject it in GameManager.Instance.allAlphaGame) { Renderer renderer = it.GetComponent(); for (int i = 0; i < renderer.materials.Length; i++) { Material touShiMat = renderer.materials[i]; Color col = touShiMat.GetColor("_BaseColor"); col.a = c; touShiMat.SetColor("_BaseColor", col); //渲染模式 //BlendMode.Cutout:打开_ALPHATEST_ON,其他两个关闭。BlendMode.Fade:打开_ALPHABLEND_ON,其他两个关闭。BlendMode.Transparent:打开_ALPHAPREMULTIPLY_ON,其他两个关闭。// if (c == 1) { if (touShiMat.GetFloat("_Surface") != 1.0f) continue; touShiMat.SetFloat("_Surface", 0.0f); touShiMat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); touShiMat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); touShiMat.SetInt("_ZWrite", 1); touShiMat.DisableKeyword("_ALPHATEST_ON"); touShiMat.DisableKeyword("_ALPHABLEND_ON"); touShiMat.DisableKeyword("_ALPHAPREMULTIPLY_ON"); touShiMat.renderQueue = -1; } else { if (touShiMat.GetFloat("_Surface") != 0.0f) continue; touShiMat.SetFloat("_Surface", 1.0f); touShiMat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); touShiMat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); touShiMat.SetInt("_ZWrite", 0); touShiMat.DisableKeyword("_ALPHATEST_ON"); touShiMat.DisableKeyword("_ALPHABLEND_ON"); touShiMat.EnableKeyword("_ALPHAPREMULTIPLY_ON"); touShiMat.renderQueue = 3000; } } } }); boomIO_Btn = transform.FindFirst