2023-08-22 19:08:45 +08:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
[ExecuteInEditMode]
|
|
|
|
|
public class OutlineManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static OutlineManager instance;
|
|
|
|
|
|
|
|
|
|
public bool m_EnableOutline = true;
|
|
|
|
|
|
|
|
|
|
public float m_SampleDistance = 0.01f;
|
|
|
|
|
|
|
|
|
|
public Color m_OutlineColor = Color.white;
|
|
|
|
|
|
|
|
|
|
public List<Renderer> m_RenderList = new List<Renderer>();
|
|
|
|
|
|
|
|
|
|
public Color m_OutlineColorEnemy = Color.red;
|
|
|
|
|
public List<Renderer> m_RenderListEnemy = new List<Renderer>();
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AutoAddFromObj(GameObject obj, bool isEnemy)
|
|
|
|
|
{
|
|
|
|
|
var renders = obj.GetComponentsInChildren<Renderer>();
|
|
|
|
|
if (isEnemy)
|
|
|
|
|
{
|
|
|
|
|
m_RenderListEnemy.AddRange(renders);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_RenderList.AddRange(renders);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveRenderer(Renderer r, bool isEnemy)
|
|
|
|
|
{
|
|
|
|
|
if (isEnemy)
|
|
|
|
|
{
|
|
|
|
|
m_RenderListEnemy.Remove(r);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_RenderList.Remove(r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddRenderer(Renderer r, bool isEnemy)
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
if (r.sharedMaterials.Length > 1) return;
|
2023-08-22 19:08:45 +08:00
|
|
|
if (isEnemy)
|
|
|
|
|
{
|
|
|
|
|
m_RenderListEnemy.Add(r);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_RenderList.Add(r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|