2024-12-18 13:16:36 +08:00
|
|
|
using HighlightPlus;
|
|
|
|
|
using System;
|
2024-12-27 14:08:27 +08:00
|
|
|
using System.Collections.Generic;
|
2024-12-18 13:16:36 +08:00
|
|
|
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;
|
2024-12-27 14:08:27 +08:00
|
|
|
string deviceName = string.Empty;
|
2025-01-16 11:42:11 +08:00
|
|
|
string isIndependent;
|
2025-02-07 13:07:29 +08:00
|
|
|
string visibility;
|
2024-12-27 14:08:27 +08:00
|
|
|
public static HighLightAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
|
2024-12-18 13:16:36 +08:00
|
|
|
{
|
|
|
|
|
var retNode = mPool.Allocate();
|
|
|
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
|
|
|
retNode.Deinited = false;
|
|
|
|
|
retNode.Reset();
|
|
|
|
|
retNode.path = path;
|
2024-12-27 14:08:27 +08:00
|
|
|
|
|
|
|
|
if (datas.ContainsKey("color"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
retNode.color = Utility.ToColor(datas["color"]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (datas.ContainsKey("isHigh"))
|
2024-12-18 13:16:36 +08:00
|
|
|
{
|
2024-12-27 14:08:27 +08:00
|
|
|
bool.TryParse(datas["isHigh"], out retNode.isHigh);
|
2024-12-18 13:16:36 +08:00
|
|
|
}
|
2024-12-27 14:08:27 +08:00
|
|
|
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty;
|
2025-01-16 11:42:11 +08:00
|
|
|
retNode.isIndependent = datas.ContainsKey("isIndependent") ? datas["isIndependent"] : string.Empty;
|
2025-02-07 13:07:29 +08:00
|
|
|
retNode.visibility = datas.ContainsKey("visibility") ? datas["visibility"] : string.Empty;
|
2024-12-18 13:16:36 +08:00
|
|
|
retNode.OnFinished = OnFinished;
|
|
|
|
|
return retNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
|
|
|
public ActionStatus Status { get; set; }
|
|
|
|
|
|
|
|
|
|
public void OnStart()
|
|
|
|
|
{
|
2024-12-27 14:08:27 +08:00
|
|
|
GameObject obj = null;
|
|
|
|
|
if (string.IsNullOrEmpty(deviceName) == false)
|
|
|
|
|
{
|
|
|
|
|
obj = DeviceController.Instance.GetDeviceObj(deviceName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
obj = Utility.FindObj(path);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 13:16:36 +08:00
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
if (isHigh)
|
|
|
|
|
{
|
|
|
|
|
var effect = obj.GetOrAddComponent<HighlightEffect>();
|
|
|
|
|
effect.outlineColor = color;
|
|
|
|
|
effect.highlighted = true;
|
2025-02-07 13:07:29 +08:00
|
|
|
Visibility visibility = Visibility.Normal;
|
|
|
|
|
Enum.TryParse(this.visibility, out visibility);
|
|
|
|
|
effect.outlineVisibility = visibility;
|
2025-01-22 10:33:42 +08:00
|
|
|
obj.GetOrAddComponent<HighLightOnStepChanged>();
|
2025-01-16 11:42:11 +08:00
|
|
|
if (string.IsNullOrEmpty(isIndependent) == false)
|
|
|
|
|
{
|
|
|
|
|
switch (isIndependent)
|
|
|
|
|
{
|
|
|
|
|
case "true":
|
|
|
|
|
effect.outlineIndependent = true;
|
|
|
|
|
break;
|
|
|
|
|
case "false":
|
|
|
|
|
effect.outlineIndependent = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-20 13:21:32 +08:00
|
|
|
#if VR
|
|
|
|
|
effect.constantWidth = false;
|
|
|
|
|
#endif
|
2024-12-18 13:16:36 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var effect = obj.GetComponent<HighlightEffect>();
|
|
|
|
|
if (effect)
|
|
|
|
|
{
|
|
|
|
|
effect.highlighted = false;
|
|
|
|
|
}
|
2025-02-06 16:26:44 +08:00
|
|
|
var flash = obj.GetComponent<HighLightFlashItem>();
|
|
|
|
|
if (flash)
|
|
|
|
|
{
|
|
|
|
|
flash.Stop();
|
|
|
|
|
}
|
2024-12-18 13:16:36 +08:00
|
|
|
|
2025-01-16 11:42:11 +08:00
|
|
|
}
|
2024-12-18 13:16:36 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|