123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using ChivaXR;
- using System;
- using System.Text;
- /// <summary>
- /// 动画驱动器-显示隐藏物体
- /// </summary>
- public class AniDriver_ActiveObjs : AnimationDriverBase
- {
- public List<GameObject> objs = new List<GameObject>();
- public bool activeObjs;
- public override void FinishedState()
- {
- foreach (var item in objs)
- {
- if (item != null)
- {
- item.SetActive(activeObjs);
- }
- else
- {
- Debug.LogError("AniDriver_ActiveObjs模型引用丢失");
- }
- }
- }
- public override void InitState()
- {
- foreach (var item in objs)
- {
- if (item != null)
- {
- item.SetActive(!activeObjs);
- }
- else
- {
- Debug.LogError("AniDriver_ActiveObjs模型引用丢失");
- }
- }
- }
- public override void StartPlay(Action finishedCallBack = null)
- {
- foreach (var item in objs)
- {
- item.SetActive(activeObjs);
- }
- finishedCallBack?.Invoke();
- }
- public override string AnimationDescription()
- {
- return animationSequence.ToString() + (activeObjs ? "--显示物体:" : "--隐藏物体:") + GetObjsName();
- }
- public string GetObjsName()
- {
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < objs.Count; i++)
- {
- if (objs[i] == null) continue;
- stringBuilder.Append(objs[i].name);
- if (i < objs.Count - 1)
- {
- stringBuilder.Append("/");
- }
- }
- return stringBuilder.ToString();
- }
- }
|