123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System.Collections;
- using System.Collections.Generic;
- using DG.Tweening;
- using UnityEngine;
- public class ModelXuHua : MonoBehaviour
- {
- public GameObject teshu;
- public GameObject teshuXs;
- public bool isXS=false;
- public List<Material> mats;
- public GameObject TabGo;
- public GameObject baimo;
- public GameObject texiao;
-
- void Start()
- {
- }
-
- public void showModel(bool isshow=true)
- {
- baimo.SetActive(false);
- this.gameObject.SetActive(true);
- if(this.texiao)
- this.texiao.SetActive(true);
- Debug.Log("showModel===>"+isshow);
- if(teshu)
- teshu.SetActive(isshow);
- if(teshuXs&&isshow)
- {
- teshuXs.SetActive(false);
- }
- }
- public void showBaiMo()
- {
- if(teshuXs)
- teshuXs.SetActive(true);
- if(teshu)
- teshu.SetActive(false);
- if(this.texiao)
- this.texiao.SetActive(false);
- if(isXS)
- {
- baimo.SetActive(false);
- this.gameObject.SetActive(false);
- return;
- }
- baimo.SetActive(true);
- this.gameObject.SetActive(false);
- for (int i = 0;i<mats.Count;i++)
- {
- Color c = mats[i].GetColor("_Color");
- mats[i].SetColor("_Color",new Color(c.r,c.g,c.b,1f));
- mats[i].DOColor(new Color(c.r,c.g,c.b,0.3f),0.5f).OnComplete(()=>{ });
- }
- }
- public void show()
- {
- this.gameObject.SetActive(true);
- }
- public void changemode()
- {
- }
- public void hide()
- {
- if(!baimo.activeSelf)
- {
- baimo.SetActive(true);
- this.gameObject.SetActive(false);
- for (int i = 0;i<mats.Count;i++)
- {
- Color c = mats[i].GetColor("_Color");
- mats[i].SetColor("_Color",new Color(c.r,c.g,c.b,1f));
- mats[i].DOColor(new Color(c.r,c.g,c.b,0f),0.5f).OnComplete(()=>{ baimo.SetActive(false);});
- }
- }
- }
-
-
-
-
-
- public static void SetAlbedoColor(Material material, Color color)
- {
- if (material != null)
- {
-
- material.SetColor("_Color", color);
- }
- else
- {
- Debug.LogError("Material is null!");
- }
- }
- public enum RenderingMode
- {
- Opaque,
- Cutout,
- Fade,
- Transparent
- }
- public static void SetMaterialRenderingMode(Material material, RenderingMode mode)
- {
- switch (mode)
- {
- case RenderingMode.Opaque:
- material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
- material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
- material.SetInt("_ZWrite", 1);
- material.DisableKeyword("_ALPHATEST_ON");
- material.DisableKeyword("_ALPHABLEND_ON");
- material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
- material.renderQueue = -1;
- break;
- case RenderingMode.Cutout:
- material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
- material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
- material.SetInt("_ZWrite", 1);
- material.EnableKeyword("_ALPHATEST_ON");
- material.DisableKeyword("_ALPHABLEND_ON");
- material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
- material.renderQueue = 2450;
- break;
- case RenderingMode.Fade:
- material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
- material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
- material.SetInt("_ZWrite", 0);
- material.DisableKeyword("_ALPHATEST_ON");
- material.EnableKeyword("_ALPHABLEND_ON");
- material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
- material.renderQueue = 3000;
- break;
- case RenderingMode.Transparent:
- material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
- material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
- material.SetInt("_ZWrite", 0);
- material.DisableKeyword("_ALPHATEST_ON");
- material.DisableKeyword("_ALPHABLEND_ON");
- material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
- material.renderQueue = 3000;
- break;
- }
- }
- }
|