123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- //using CCS.App;
- using DG.Tweening;
- using SC.XR.Unity;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Timers;
- using TMPro;
- using UnityEngine;
- public class Scenes_YiLiao : MonoBehaviour
- {
- // Start is called before the first frame update
- public string SeverString;
- public GameObject bodyRol;
- public GameObject muscle;
- /// <summary>
- /// 初始效果出现隐藏变量
- /// </summary>
- public MeshRenderer startRentiRenderer;
- private float initStartRentiRendererFloat;
- private float maxStartRentiRendererFloat;
- private float minStartRentiRendererFloat;
- private bool _isStartShow;
- public GameObject[] topTextsList;
- public GameObject[] topSlidesList;
- private float initTopTxtsTxtColorA;
- private float maxTopTxtsTxtColorA;
- private float minTopTxtsTxtColorA;
- private float inittopSlidesColorRGB;
- private float maxtopSlidesColorRGB;
- private float mintopSlidesColorRGB;
- /// <summary>
- /// 头部变量
- /// </summary>
- public MeshRenderer babyTopRenderer;
- public SCSlider3D babyTopSlider;
- //头部滑块变量
- public MeshRenderer babyTopSaoMaoFXRenderer;
- private Color initBabyTopSaoMaoFXRendererColor;
- private Animator anim_babyTopSaoMaoFX;
- private bool isbabyTopSaoMaoFXShowOrHeid;
- private bool IsOneOpenBabyTopSaoMaoFXShowOrHeid;
- /// <summary>
- /// 身体躯干变量
- /// </summary>
- public MeshRenderer babyTrunkRenderer;
- public SCSlider3D babyTrunkSlider;
- //头部ct变量
- public MeshRenderer ct1Renderer;
- private float initBabyTrunRongjie;
- private float MaxBabyTrunRongjie;
- private float minBabyTrunRongjie;
- private bool isUserDownBabyTrunkSlider;
- public GameObject[] babyTrunkGamesUIList;
- //private FunctionInfo _headFunction;
- //private FunctionInfo _bodyFunction;
- private float _waitTime = 3;
- public bool IsStartShow
- {
- set
- {
- _isStartShow = value;
- StartCoroutine(Ro3Show(_isStartShow));
- if (value)
- {
- }
- else
- {
- //// ShowOrHeidBbabyTrunkUI(-1, babyTrunkGamesUIList, "r1");
- //babyTopSlider.value = _headFunction == null ? 0 : _headFunction.defaultValue / 1.0f;
- //babyTrunkSlider.value = _bodyFunction == null ? 0 : _bodyFunction.defaultValue / 1.0f;
- //scannerSlider.value=
- babyTopRenderer.material.SetFloat("_Ani", 0);
- }
- }
- }
- #region 新的整体滑动条逻辑
- /// <summary>
- /// 新的整体滑动条
- /// </summary>
- public SCSlider3D scannerSlider;
- public GameObject hintHandGo; //小手
- public GameObject hintHandFX;//扫描特效
- public float fixedpoint_startvalue;//固定的头和身体的中间值开始变量
- public float fixedpoint_endvalue;//固定的头和身体的中间值结束变量
- private float now_value; //当前value
- private float top_value; //滑到头部时value
- private float baby_value;//滑到身体时的value
- public GameObject RayLiget;
- /// <summary>
- /// 扫描仪拖动事件
- /// </summary>
- public void ScannerSliderValueChaged()
- {
- now_value = scannerSlider.value;
- if (now_value <= fixedpoint_startvalue)
- {
- isTop = true;
- babyTrunkGamesUIList[0].SetActive(false);
- babyTrunkRenderer.material.SetFloat("_rongjie", 1);
- top_value = now_value / fixedpoint_startvalue;
- babyTopRenderer.material.SetFloat("_Ani", top_value);
- }
- else if (now_value >= fixedpoint_endvalue)
- {
- isTop = false;
- babyTrunkGamesUIList[0].SetActive(true);
- baby_value = (now_value - fixedpoint_endvalue) / (1 - fixedpoint_endvalue);
- if (baby_value >= 1)
- {
- baby_value = 1;
- }
- babyTrunkRenderer.material.SetFloat("_rongjie", 0);
- babyTrunkRenderer.material.SetFloat("_Ani", baby_value);
- if (baby_value <= 0.1f)
- {
- ShowOrHeidBbabyTrunkUI(0, babyTrunkGamesUIList, "r4");
- }
- else if (baby_value >= 0.1f && baby_value < 0.3f)
- {
- ShowOrHeidBbabyTrunkUI(1, babyTrunkGamesUIList, "r3");
- }
- else if (baby_value >= 0.3f && baby_value < 0.5f)
- {
- ShowOrHeidBbabyTrunkUI(2, babyTrunkGamesUIList, "r2");
- }
- else if (baby_value >= 0.5f && baby_value < 1f)
- {
- ShowOrHeidBbabyTrunkUI(3, babyTrunkGamesUIList, "r1");
- }
- }
- hintHandFX.SetActive(true);
- }
- public bool isTop = true; //是否扫描的头部
- /// <summary>
- /// 进入或者滑出滑动条进行的操作
- /// </summary>
- /// <param name="str"></param>
- public void Show_ScannerSliderFX(string str)
- {
- if (str == "Down")
- {
- RayLiget.SetActive(true);
- if (isTop)
- {
- babyTopSaoMaoFXRenderer.gameObject.SetActive(true);
- anim_babyTopSaoMaoFX.Play("startSaoMiao");
- //SendTopFenctionInfo2S(top_value);
- }
- else
- {
- isUserDownBabyTrunkSlider = true;
- //SendBabyFenctionInfo2S(baby_value);
- }
- muscle.SetActive(true);
- }
- if (str == "Up")
- {
- RayLiget.SetActive(false);
- if (isTop)
- {
- anim_babyTopSaoMaoFX.Play("retrunSaoMiao");
- //SendTopFenctionInfo2S(top_value);
- }
- else
- {
- isUserDownBabyTrunkSlider = false;
- //SendBabyFenctionInfo2S(baby_value);
- }
- }
- ShowOrHeidTextsColorA("ChangeTextMeshPro", topTextsList, initTopTxtsTxtColorA, true);
- }
- /// <summary>
- /// 焦点进入事件
- /// </summary>
- public void PointEnterEvent()
- {
- Debug.Log("PointEnterEvent");
- hintHandGo.SetActive(true);
- // hintHandFX.SetActive(true);
- }
- /// <summary>
- /// 焦点移出事件
- /// </summary>
- public void PointExitEvent()
- {
- Debug.Log("PointExitEvent");
- hintHandFX.SetActive(false);
- hintHandGo.SetActive(false);
- }
- /// <summary>
- /// 发送头当前数据给中控
- /// </summary>
- /// <param name="value">当前value</param>
- //private void SendTopFenctionInfo2S(float value)
- //{
- // _headFunction.functionValues[0].value = (int)(value * 100);
- // //GameManager.Instance.SendFunctionInfo2S(_headFunction);
- //}
- /// <summary>
- /// 发送身体当前数据给中控
- /// </summary>
- /// <param name="value">当前value</param>
- //private void SendBabyFenctionInfo2S(float value)
- //{
- // _bodyFunction.functionValues[0].value = (int)(value * 100);
- // //GameManager.Instance.SendFunctionInfo2S(_bodyFunction);
- //}
- ///// <summary>
- /// 获取头或者身体当前滑动条的值
- /// </summary>
- /// <param name="value">中控发送的值</param>
- /// <param name="type">0 为头部, 1为身体</param>
- /// <returns>换算后的滑动条值</returns>
- private float ConvertsTheurrentSliderPosition(float value, int type)
- {
- if (type == 0)//扫描的头部
- {
- return (value * fixedpoint_startvalue);
- }
- else if (type == 1) //扫描的身体
- {
- return (value * (1 - fixedpoint_endvalue) + fixedpoint_endvalue);
- }
- return 0;
- }
- #endregion
- private void Awake()
- {
- //GameManager.Instance.functionChangleAction += MedicalFunctionChangleHandler;
- //_headFunction = AppManager.Instance.functionInfos.FirstOrDefault(f => f.moduleID == 2 && f.functionID == 3);
- //_bodyFunction = AppManager.Instance.functionInfos.FirstOrDefault(f => f.moduleID == 2 && f.functionID == 4);
- }
- private void OnDestroy()
- {
- //GameManager.Instance.functionChangleAction -= MedicalFunctionChangleHandler;
- }
- /*
- private void MedicalFunctionChangleHandler(int moduleID, int functionID, FunctionType functionType, List<FunctionValue> functionValues)
- {
- //当前是医疗
- if (moduleID == 2 && functionID == 1 && functionType == FunctionType.Switch)
- {
- switch ((FunctionState)functionValues[0].value)
- {
- case FunctionState.None:
- break;
- case FunctionState.Open:
- StartOrOpenRenTiObj(true);
- break;
- case FunctionState.Close:
- StartOrOpenRenTiObj(false);
- break;
- case FunctionState.Wait:
- break;
- default:
- break;
- }
- }
- else if (moduleID == 2 && functionID == 3 && functionType == FunctionType.RangeValue)
- {
- babyTopSlider.value = functionValues[0].value / 100.0f;
- //metoo
- ; scannerSlider.value = ConvertsTheurrentSliderPosition(functionValues[0].value / 100.0f,0);
- }
- else if (moduleID == 2 && functionID == 4 && functionType == FunctionType.RangeValue)
- {
- if (!muscle.activeSelf)
- {
- muscle.SetActive(true);
- isUserDownBabyTrunkSlider = true;
- }
- babyTrunkSlider.value = functionValues[0].value / 100.0f;
- //metoo
- scannerSlider.value = ConvertsTheurrentSliderPosition(functionValues[0].value / 100.0f, 1);
- ScannerSliderValueChaged();
- BabyTrunkSliderValueChaged();
- _waitTime = 0;
- }
- }
- */
- void Start()
- {
- Init();
- StartOrOpenRenTiObj(true);
- StartCoroutine(DeleEffectsTrue());
- }
- IEnumerator DeleEffectsTrue()
- {
- yield return new WaitForSeconds(0.1f);
- //GameManager.Instance.LoadingGameObj(false);
- }
- WaitForEndOfFrame wfs = new WaitForEndOfFrame();
- IEnumerator Ro3Show(bool isShow)
- {
- startRentiRenderer.gameObject.SetActive(true);
- if (isShow)
- {
- bodyRol.SetActive(true);
- }
- startRentiRenderer.material.SetFloat("_Float1", isShow ? maxStartRentiRendererFloat : minStartRentiRendererFloat);
- bool isStart = true;
- while (isStart)
- {
- yield return wfs;
- if (isShow)
- {
- if (initStartRentiRendererFloat < minStartRentiRendererFloat)
- {
- isStart = false;
- }
- }
- else
- {
- if (initStartRentiRendererFloat > maxStartRentiRendererFloat)
- {
- isStart = false;
- bodyRol.SetActive(false);
- }
- }
- }
- startRentiRenderer.gameObject.SetActive(false);
- }
- private void Init()
- {
- InitStartBabyAll();
- InitBabyTop();
- InitBabyTrunk();
- }
- /// <summary>
- /// 整体效果初始化
- /// </summary>
- private void InitStartBabyAll()
- {
- muscle.SetActive(false);
- initStartRentiRendererFloat = 1.2f;
- maxStartRentiRendererFloat = initStartRentiRendererFloat;
- minStartRentiRendererFloat = 0;
- startRentiRenderer.material.SetFloat("_Float1", initStartRentiRendererFloat);
- IsStartShow = false;
- initTopTxtsTxtColorA = 0;
- maxTopTxtsTxtColorA = 1;
- minTopTxtsTxtColorA = initTopTxtsTxtColorA;
- inittopSlidesColorRGB = 0;
- maxtopSlidesColorRGB = 1;
- mintopSlidesColorRGB = inittopSlidesColorRGB;
- }
- /// <summary>
- /// 脑部初始
- /// </summary>
- private void InitBabyTop()
- {
- babyTopRenderer.material.SetFloat("_Ani", 0);
- ct1Renderer.material.SetFloat("_Ani", 0);
- anim_babyTopSaoMaoFX = babyTopSaoMaoFXRenderer.gameObject.GetComponent<Animator>();
- initBabyTopSaoMaoFXRendererColor = new Color(0, 0, 0);
- babyTopSaoMaoFXRenderer.material.SetColor("_yanse", initBabyTopSaoMaoFXRendererColor);
- babyTopSaoMaoFXRenderer.material.SetColor("_node_2070", initBabyTopSaoMaoFXRendererColor);
- babyTopSaoMaoFXRenderer.material.SetColor("_node_3228", initBabyTopSaoMaoFXRendererColor);
- babyTopSaoMaoFXRenderer.gameObject.SetActive(false);
- IsOneOpenBabyTopSaoMaoFXShowOrHeid = true;
- }
- private void InitBabyTrunk()
- {
- babyTrunkRenderer.material.SetFloat("_Ani", 0);
- initBabyTrunRongjie = 1;
- MaxBabyTrunRongjie = 1;
- minBabyTrunRongjie = 0;
- babyTrunkRenderer.material.SetFloat("_rongjie", 1);
- isUserDownBabyTrunkSlider = false;
- }
- /// <summary>
- /// 滑动头部滑块
- /// </summary>
- public void BabyTopSliderValueChaged()
- {
- babyTopRenderer.material.SetFloat("_Ani", babyTopSlider.value);
- ct1Renderer.material.SetFloat("_Ani", babyTopSlider.value);
- }
- /// <summary>
- /// 滑动身体滑块
- /// </summary>
- public void BabyTrunkSliderValueChaged()
- {
- babyTrunkRenderer.material.SetFloat("_Ani", babyTrunkSlider.value);
- // Debug.Log(babyTrunkSlider.value + "=>babyTrunkSlider.value");
- if (babyTrunkSlider.value <= 0.1f)
- {
- ShowOrHeidBbabyTrunkUI(0, babyTrunkGamesUIList, "r4");
- }
- else if (babyTrunkSlider.value >= 0.1f && babyTrunkSlider.value < 0.3f)
- {
- ShowOrHeidBbabyTrunkUI(1, babyTrunkGamesUIList, "r3");
- }
- else if (babyTrunkSlider.value >= 0.3f && babyTrunkSlider.value < 0.5f)
- {
- ShowOrHeidBbabyTrunkUI(2, babyTrunkGamesUIList, "r2");
- }
- else if (babyTrunkSlider.value >= 0.5f && babyTrunkSlider.value < 1f)
- {
- ShowOrHeidBbabyTrunkUI(3, babyTrunkGamesUIList, "r1");
- }
- }
- // Update is called once per frame
- void Update()
- {
- if (_waitTime <= 2)
- {
- _waitTime += Time.deltaTime;
- if (_waitTime > 2)
- {
- isUserDownBabyTrunkSlider = false;
- }
- }
- //根据bool 显示或关闭 整体模型
- if (_isStartShow)
- {
- // Debug.Log("++++++++++++++++++++++++++++++++++");
- if (initStartRentiRendererFloat >= minStartRentiRendererFloat)
- {
- initStartRentiRendererFloat -= Time.deltaTime * 0.3f;
- startRentiRenderer.material.SetFloat("_Float1", initStartRentiRendererFloat);
- }
- //if (initTopTxtsTxtColorA <= maxTopTxtsTxtColorA)
- //{
- // Debug.Log("22222222222222222222222222");
- // initTopTxtsTxtColorA += Time.deltaTime * 0.3f;
- // ShowOrHeidTextsColorA("ChangeTextMeshPro", topTextsList, initTopTxtsTxtColorA, false);
- //}
- //if (inittopSlidesColorRGB <= maxtopSlidesColorRGB)
- //{
- // Debug.Log("111111111111111111111111111111111");
- // inittopSlidesColorRGB += Time.deltaTime * 0.3f;
- // ShowOrHeidTextsColorA("ChangeMeshRenderer", topSlidesList, inittopSlidesColorRGB, true);
- //}
- if (isUserDownBabyTrunkSlider)
- {
- if (initBabyTrunRongjie >= minBabyTrunRongjie)
- {
- initBabyTrunRongjie -= Time.deltaTime * 1f;
- babyTrunkRenderer.material.SetFloat("_rongjie", initBabyTrunRongjie);
- }
- }
- //else
- //{
- // if (initBabyTrunRongjie <= MaxBabyTrunRongjie)
- // {
- // Debug.Log("444444444444444444444444");
- // initBabyTrunRongjie += Time.deltaTime * 0.04f;
- // babyTrunkRenderer.material.SetFloat("_rongjie", initBabyTrunRongjie);
- // }
- // else
- // {
- // muscle.SetActive(false);
- // }
- //}
- }
- //else
- //{
- // // Debug.Log("-----------------------------------");
- // if (initStartRentiRendererFloat <= maxStartRentiRendererFloat)
- // {
- // initStartRentiRendererFloat += Time.deltaTime * 0.3f;
- // startRentiRenderer.material.SetFloat("_Float1", initStartRentiRendererFloat);
- // }
- // if (initTopTxtsTxtColorA >= minTopTxtsTxtColorA)
- // {
- // initTopTxtsTxtColorA -= Time.deltaTime * 0.3f;
- // ShowOrHeidTextsColorA("ChangeTextMeshPro", topTextsList, initTopTxtsTxtColorA, false);
- // }
- // if (inittopSlidesColorRGB >= mintopSlidesColorRGB)
- // {
- // inittopSlidesColorRGB -= Time.deltaTime * 0.3f;
- // ShowOrHeidTextsColorA("ChangeMeshRenderer", topSlidesList, inittopSlidesColorRGB, false);
- // }
- // if (initBabyTrunRongjie <= MaxBabyTrunRongjie)
- // {
- // initBabyTrunRongjie += Time.deltaTime * 0.3f;
- // babyTrunkRenderer.material.SetFloat("_rongjie", initBabyTrunRongjie);
- // }
- //}
- #if UNITY_EDITOR
- if (Input.GetKey(KeyCode.J))
- {
- StartOrOpenRenTiObj(true);
- }
- else if (Input.GetKey(KeyCode.K))
- {
- StartOrOpenRenTiObj(false);
- }
- #endif
- }
- public void ShowOrHeidTextsColorA(string str, GameObject[] games, float colorA, bool isOpenBoxCollider)
- {
- if (str == "ChangeTextMeshPro")
- {
- if (isOpenBoxCollider)//这里用关闭 “手势捏住下方滑块滑动条”
- {
- games[1].GetComponent<TextMeshPro>().color = new Color(1, 1, 1, 0);
- }
- else
- {
- for (int i = 0; i < games.Length; i++)
- {
- games[i].GetComponent<TextMeshPro>().color = new Color(1, 1, 1, colorA);
- }
- }
- }
- else if (str == "ChangeMeshRenderer")
- {
- for (int i = 0; i < games.Length; i++)
- {
- games[i].GetComponent<BoxCollider>().enabled = isOpenBoxCollider;
- games[i].GetComponent<MeshRenderer>().material.color = new Color(colorA, colorA, colorA);
- }
- }
- }
- /// <summary>
- /// 开启或关闭人体
- /// </summary>
- /// <param name="isOpen"></param>
- public void StartOrOpenRenTiObj(bool isOpen)
- {
- IsStartShow = isOpen;
- }
- /// <summary>
- /// 关闭或显示人体脑部特效
- /// </summary>
- /// <param name="isOpen"></param>
- public void Show_BabyTopSaoMaoFX(string str)
- {
- if (str == "ShowBobyTopSaoMiaoFX")
- {
- babyTopSaoMaoFXRenderer.gameObject.SetActive(true);
- anim_babyTopSaoMaoFX.Play("startSaoMiao");
- }
- else if (str == "HeidBobyTopSaoMiaoFX")
- {
- anim_babyTopSaoMaoFX.Play("retrunSaoMiao");
- }
- //_headFunction.functionValues[0].value = (int)(babyTopSlider.value * 100);
- //GameManager.Instance.SendFunctionInfo2S(_headFunction);
- ShowOrHeidTextsColorA("ChangeTextMeshPro", topTextsList, initTopTxtsTxtColorA, true);
- }
- /// <summary>
- /// 关闭或现实人体躯干特效
- /// </summary>
- /// <param name="str"></param>
- public void Show_BabyTrunkFX(string str)
- {
- if (str == "ShowBobyTrunkFX")
- {
- muscle.SetActive(true);
- isUserDownBabyTrunkSlider = true;
- }
- else if (str == "HeidBobyTrunkFX")
- {
- isUserDownBabyTrunkSlider = false;
- }
- //_bodyFunction.functionValues[0].value = (int)(babyTrunkSlider.value * 100);
- //GameManager.Instance.SendFunctionInfo2S(_bodyFunction);
- // Debug.LogError(str + "=>str");
- ShowOrHeidTextsColorA("ChangeTextMeshPro", topTextsList, initTopTxtsTxtColorA, true);
- }
- // int lastgamesNum=-1;
- private void ShowOrHeidBbabyTrunkUI(int index, GameObject[] games, string animName)
- {
- if (index == -1)
- {
- return;
- }
- // Debug.Log(index + "=>index");
- for (int i = 0; i < games.Length; i++)
- {
- if (i != index)
- {
- // games[i].SetActive(true);
- // Debug.Log(i + "=>+++++back");
- games[i].gameObject.GetComponent<Animator>().SetBool("Open", true);
- games[i].gameObject.transform.localPosition = new Vector3(999f, 999f, 999f);
- }
- else
- {
- switch (index)
- {
- case 0:
- games[i].GetComponent<Animator>().SetBool("Open", false);
- games[0].gameObject.transform.localPosition = new Vector3(-0.0353f, 0.131f, 0.0618f);
- break;
- case 1:
- games[i].GetComponent<Animator>().SetBool("Open", false);
- // games[1].gameObject.GetComponent<Animator>().Play(animName);
- games[1].gameObject.transform.localPosition = new Vector3(-0.0077f, 0.1765f, 0.06325f);
- break;
- case 2:
- games[i].GetComponent<Animator>().SetBool("Open", false);
- // games[2].gameObject.GetComponent<Animator>().Play(animName);
- games[2].gameObject.transform.localPosition = new Vector3(-0.0124f, 0.2897f, 0.0449f);
- break;
- case 3:
- games[i].GetComponent<Animator>().SetBool("Open", false);
- // games[3].gameObject.GetComponent<Animator>().Play(animName);
- games[3].gameObject.transform.localPosition = new Vector3(-0.0206f, 0.3177f, 0.063f);
- break;
- }
- }
- }
- }
- private IEnumerator waitOfAnimEndHeidGameObj(float timer, GameObject obj, bool isB)
- {
- yield return new WaitForSeconds(timer);
- obj.SetActive(isB);
- }
- private IEnumerator waitOfInit(float timer)
- {
- yield return new WaitForSeconds(timer);
- Init();
- }
- }
|