2025-09-08 14:51:28 +08:00
|
|
|
|
using LitJson;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using ZXKFramework;
|
|
|
|
|
|
public class HighLightManager : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
Outline outLine;
|
|
|
|
|
|
private Dictionary<string, Outline> allOutLineDict = new Dictionary<string, Outline>();
|
|
|
|
|
|
Transform root;
|
|
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
outLine = GetComponent<Outline>();
|
|
|
|
|
|
root = GameObject.Find("Root").transform;
|
2025-09-08 17:37:12 +08:00
|
|
|
|
Game.Instance.res.Load<TextAsset>(MVC.GetModel<DongWuYiXue.Main.GameModel>().mainData.folder + "/ExcelData/ExcelToJson/BaseData.json", args => {
|
2025-09-08 14:51:28 +08:00
|
|
|
|
string interactionObjs = "";
|
|
|
|
|
|
List<JsonData> data = JsonMapper.ToObject<List<JsonData>>(args.text);
|
|
|
|
|
|
for (int i = 0; i < data.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
interactionObjs += data[i]["obj"].ToString() + "|";
|
|
|
|
|
|
}
|
|
|
|
|
|
string[] strs = interactionObjs.Split('|');
|
|
|
|
|
|
for (int i = 0; i < strs.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!allOutLineDict.ContainsKey(strs[i]) && !string.IsNullOrEmpty(strs[i]))
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject go = root.FindFirst(strs[i]);
|
|
|
|
|
|
if (go != null && go.TryGetComponent(out Collider col))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (go.TryGetComponent(out Outline light))
|
|
|
|
|
|
{
|
|
|
|
|
|
allOutLineDict.Add(strs[i], light);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Outline outli = go.AddComponent<Outline>();
|
|
|
|
|
|
outli.OutlineColor = outLine.OutlineColor;
|
|
|
|
|
|
outli.enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
Game.Instance.eventManager.AddListener<HighLightEvent>(VisiableLight);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void VisiableLight(HighLightEvent e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.visiable)
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowHighLight(e.name);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
HideHighLight(e.name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><EFBFBD><F2BFAAB8><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void ShowHighLight(string name, Action callBack = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (allOutLineDict.ContainsKey(name))
|
|
|
|
|
|
{
|
|
|
|
|
|
allOutLineDict[name].enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
callBack?.Invoke();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject go = GameObject.Find("Root").FindFirst(name);
|
|
|
|
|
|
if (go != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
allOutLineDict.Add(go.name, go.GetOrAddComponent<Outline>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
allOutLineDict[name].enabled = true;
|
|
|
|
|
|
allOutLineDict[name].OutlineColor = outLine.OutlineColor;
|
|
|
|
|
|
allOutLineDict[name].OutlineWidth = outLine.OutlineWidth;
|
|
|
|
|
|
callBack?.Invoke();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool IsHighLight(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (allOutLineDict.ContainsKey(name))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (allOutLineDict[name].enabled && allOutLineDict[name].enabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>رո<D8B1><D5B8><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
public void HideHighLight(string name, Action callBack = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (allOutLineDict.TryGetValue(name, out Outline outli))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (outli != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
outli.enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
callBack?.Invoke();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>ر<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void HideAllHighLight()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in allOutLineDict)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.Value.enabled) item.Value.enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveHighLight(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (allOutLineDict.ContainsKey(name))
|
|
|
|
|
|
{
|
|
|
|
|
|
Destroy(allOutLineDict[name]);
|
|
|
|
|
|
allOutLineDict.Remove(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveAllHighLight()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in allOutLineDict)
|
|
|
|
|
|
{
|
|
|
|
|
|
Destroy(item.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
allOutLineDict.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
Game.Instance.eventManager.RemoveListener<HighLightEvent>(VisiableLight);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|