123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- namespace ChivaXR.VR
- {
- using Sirenix.OdinInspector;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// CVR_触发点Value动画抽象类
- /// </summary>
- public abstract class CVR_ValueAniBase
- {
- [PropertyOrder(-1)]
- [LabelText("隐藏模拟工具模型")]
- public bool closeSimulationTool;
- protected CVR_SimulationTool simulationTool;
- protected CVR_SimulationPoint simulationPoint
- {
- get
- {
- if (simulationTool != null)
- {
- if (simulationTool.simulationPoint == null)
- {
- simulationTool.CreatSimulationPoint();
- }
- return simulationTool.simulationPoint;
- }
- return null;
- }
- }
- protected IVR_Interactable Interactable
- {
- get
- {
- if (simulationTool != null)
- {
- return simulationTool.Interactable;
- }
- return null;
- }
- }
- protected GameObject CurrentHand
- {
- get
- {
- if (simulationTool != null)
- {
- return simulationTool.Interactable.CVR_GetInteractableObject();
- }
- return null;
- }
- }
- protected CVR_ValueElement valueElement;
- private float value;
- protected float Value
- {
- get { return value; }
- set
- {
- if (this.value != value)
- {
- this.value = value;
- if (valueElement != null)
- valueElement.Value = this.value;
- }
- }
- }
- public virtual void SetValueState(float value)
- {
- this.Value = value;
- }
- /// <summary>
- /// SimulationAni初始化
- /// </summary>
- /// <param name="tool"></param>
- public virtual void Init(CVR_ValueElement trigger, CVR_SimulationTool tool)
- {
- valueElement = trigger;
- simulationTool = tool;
- SimulationEnter();
- }
- /// <summary>
- /// 开始模拟动画
- /// </summary>
- public virtual void SimulationEnter()
- {
- if (closeSimulationTool) CloseOrOpenSimulationToolMesh(false);
- }
- /// <summary>
- /// 每帧模拟动画
- /// </summary>
- public abstract void SimulationUpdate();
- /// <summary>
- /// 结束模拟动画
- /// </summary>
- public virtual void SimulationExit()
- {
- if (closeSimulationTool) CloseOrOpenSimulationToolMesh(true);
- }
- public virtual void CloseSimulation()
- {
- SimulationExit();
- simulationTool = null;
- }
- private void CloseOrOpenSimulationToolMesh(bool open)
- {
- MeshRenderer[] renders = simulationTool.gameObject.GetComponentsInChildren<MeshRenderer>();
- foreach (var item in renders)
- {
- item.enabled = open;
- }
- }
- }
- }
|