using UnityEngine; using UnityEngine.Pool; using XED.Interfaces; using static XED.Wall; namespace XED { public class BoxHighLighter : MonoBehaviour, IPooledObject { private Material material; private MeshRenderer meshRenderer; public IObjectPool Pool { get; set; } void OnDisable() { Pool.Release(this); } //TODO:: public override void AfterAwake() { material = Resources.Load("Materials/Mat_BoxHighLight"); meshRenderer = GetComponent(); meshRenderer.material = material; } private void WallBoxSize(Wall wall) { var ySize = wall.meshfilter.mesh.bounds.size.y; var start = wall.n_GonPoints[(int)VertexPoint.LeftCenter]; var end = wall.n_GonPoints[(int)VertexPoint.RightCenter]; var zSize = Vector3.Distance(start, end); //zfighting¶§¹®¿¡ 0.01¾¿ ´õÇØÁÜ transform.localPosition = Vector3.up * (ySize * 0.5f); transform.localRotation = Quaternion.Euler(0f, 0f, 0f); transform.localScale = new Vector3(0.11f, ySize + 0.01f, zSize + 0.01f); } public void TwinObjectBoxSize(TwinObject twinObject) { if(twinObject is Wall) { WallBoxSize((Wall)twinObject); return; } var collider = twinObject.GetComponent(); transform.localScale = collider.size; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.Euler(0f, 0f, 0f); } } }