83 lines
1.8 KiB
C#
Raw Normal View History

2024-12-14 18:27:59 +08:00
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<ShowAction> mPool =
new SimpleObjectPool<ShowAction>(() => new ShowAction(), null, 10);
string path;
bool isShow = true;
bool isDevice = false;
public static ShowAction Allocate(string path, string isShow, string isDevice, System.Action onDelayFinish = null)
2024-12-14 18:27:59 +08:00
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.path = path;
bool.TryParse(isShow, out retNode.isShow);
bool.TryParse(isDevice, out retNode.isDevice);
2024-12-14 18:27:59 +08:00
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 (isDevice)
{
obj = DeviceController.Instance.GetDeviceObj(path);
}
else
{
2024-12-14 18:27:59 +08:00
obj = Utility.FindObj(path);
}
2024-12-14 18:27:59 +08:00
if (obj == null)
{
Debug.LogError(<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD> :" + path);
}
else
{
obj.SetActive(isShow);
}
this.Finish();
}
public void Reset()
{
Status = ActionStatus.NotStart;
Paused = false;
}
}