implementation of drecon in unity 2022 lts forked from: https://github.com/joanllobera/marathon-envs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.3 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
[ExecuteInEditMode]
public class GizmoManager : MonoBehaviour
{
public GameObject m_VFX;
private LineRenderer lineRenderer;
void Start(){
lineRenderer = this.GetComponent<LineRenderer>();
lineRenderer.startWidth = 0.2f;
lineRenderer.endWidth = 0.2f;
//lineRenderer.material = new Material(Shader.Find("Sprites/Default"));
//lineRenderer.material.color = Color.yellow;
}
void Update(){
DrawWireframe(m_VFX);
}
void DrawWireframe(GameObject m_Smoke){
Bounds m_SmokeBounds = m_Smoke.GetComponent<Renderer>().bounds;
Vector3[] vertices = new Vector3[16];
// Calculate the vertices of the box
vertices[0] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.min.y, m_SmokeBounds.min.z);
vertices[1] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.min.y, m_SmokeBounds.min.z);
vertices[2] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.min.y, m_SmokeBounds.max.z);
vertices[3] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.min.y, m_SmokeBounds.max.z);
vertices[4] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.min.y, m_SmokeBounds.min.z);
vertices[5] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.max.y, m_SmokeBounds.min.z);
vertices[6] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.max.y, m_SmokeBounds.min.z);
vertices[7] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.min.y, m_SmokeBounds.min.z);
vertices[8] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.max.y, m_SmokeBounds.min.z);
vertices[9] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.max.y, m_SmokeBounds.max.z);
vertices[10] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.min.y, m_SmokeBounds.max.z);
vertices[11] = new Vector3(m_SmokeBounds.max.x, m_SmokeBounds.max.y, m_SmokeBounds.max.z);
vertices[12] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.max.y, m_SmokeBounds.max.z);
vertices[13] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.min.y, m_SmokeBounds.max.z);
vertices[14] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.max.y, m_SmokeBounds.max.z);
vertices[15] = new Vector3(m_SmokeBounds.min.x, m_SmokeBounds.max.y, m_SmokeBounds.min.z);
lineRenderer.positionCount = vertices.Length;
lineRenderer.SetPositions(vertices);
}
}