101 lines
2.4 KiB
C#
101 lines
2.4 KiB
C#
using HighlightPlus;
|
|
using System;
|
|
using Unity.VisualScripting;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace QFramework
|
|
{
|
|
internal class HighLightAction : IAction
|
|
{
|
|
|
|
|
|
public System.Action OnFinished { get; set; }
|
|
|
|
|
|
private HighLightAction()
|
|
{
|
|
}
|
|
|
|
private static readonly SimpleObjectPool<HighLightAction> mPool =
|
|
new SimpleObjectPool<HighLightAction>(() => new HighLightAction(), null, 10);
|
|
|
|
string path;
|
|
Color color = Color.green;
|
|
bool isHigh = true;
|
|
public static HighLightAction Allocate(string path, string isHigh, string color, System.Action OnFinished = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.path = path;
|
|
if (string.IsNullOrEmpty(color) == false)
|
|
{
|
|
retNode.color = Utility.ToColor(color);
|
|
}
|
|
bool.TryParse(isHigh, out retNode.isHigh);
|
|
retNode.OnFinished = OnFinished;
|
|
return retNode;
|
|
}
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
public ActionStatus Status { get; set; }
|
|
|
|
public void OnStart()
|
|
{
|
|
GameObject obj = Utility.FindObj(path);
|
|
if (obj != null)
|
|
{
|
|
if (isHigh)
|
|
{
|
|
var effect = obj.GetOrAddComponent<HighlightEffect>();
|
|
effect.outlineColor = color;
|
|
effect.highlighted = true;
|
|
}
|
|
else
|
|
{
|
|
var effect = obj.GetComponent<HighlightEffect>();
|
|
if (effect)
|
|
{
|
|
effect.highlighted = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public void OnExecute(float dt)
|
|
{
|
|
this.Finish();
|
|
OnFinished?.Invoke();
|
|
}
|
|
|
|
public void OnFinish()
|
|
{
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Status = ActionStatus.NotStart;
|
|
Paused = false;
|
|
}
|
|
|
|
public bool Paused { get; set; }
|
|
|
|
public void Deinit()
|
|
{
|
|
if (!Deinited)
|
|
{
|
|
OnFinished = null;
|
|
Deinited = true;
|
|
mPool.Recycle(this);
|
|
}
|
|
}
|
|
|
|
public bool Deinited { get; set; }
|
|
}
|
|
|
|
|
|
} |