using System.Collections; using System.Collections.Generic; using UnityEngine; using QFramework; using System; using QFramework.Example; using DG.Tweening; using System.ComponentModel.Design; public class ShowAction : IAction { public ulong ActionID { get; set; } public bool Deinited { get; set; } public bool Paused { get; set; } public ActionStatus Status { get; set; } private static readonly SimpleObjectPool mPool = new SimpleObjectPool(() => new ShowAction(), null, 10); string path; string isShow = string.Empty; string deviceName = string.Empty; string isDevice = string.Empty; string isRoot = string.Empty; public static ShowAction Allocate(string path, Dictionary datas, System.Action onDelayFinish = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); retNode.path = path; retNode.isShow = datas.ContainsKey("isShow") ? datas["isShow"] : string.Empty; retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty; retNode.isDevice = datas.ContainsKey("isDevice") ? datas["isDevice"] : string.Empty; retNode.isRoot = datas.ContainsKey("isRoot") ? datas["isRoot"] : null; return retNode; } public void Deinit() { if (!Deinited) { Deinited = true; mPool.Recycle(this); } } public void OnExecute(float dt) { } public void OnFinish() { } public void OnStart() { GameObject obj = null; if (string.IsNullOrEmpty(deviceName) == false) { obj = DeviceController.Instance.GetDeviceObj(deviceName); } else { if (string.IsNullOrEmpty(isDevice) == false && isDevice == "true") { obj = DeviceController.Instance.GetDeviceObj(path); } else { obj = Utility.FindObj(path); } } if (obj == null) { Debug.LogError($"没有找到物体 path:{path} deviceName:{deviceName}"); } else { bool isActive = true; bool.TryParse(isShow, out isActive); if (string.IsNullOrEmpty(isRoot)) { obj.SetActive(isActive); } else if (isRoot == "true") { for (int i = 0; i < obj.transform.childCount; i++) { obj.transform.GetChild(i).gameObject.SetActive(isActive); } } } this.Finish(); } public void Reset() { Status = ActionStatus.NotStart; Paused = false; Debug.Log("显示命令,重置"); } }