public override void OnInspectorGUI() { base.OnInspectorGUI(); Collider_Vis _t = target as Collider_Vis; if (_t == null) { return; } var coll = _t.GetComponent <Collider>(); GUILayout.Label("CollType:" + coll); if (GUILayout.Button("UpdateColl")) { LineRenderer lr = _t.GetComponent <LineRenderer>(); if (lr != null) { lr.enabled = true; } _t.updateColl(); } if (GUILayout.Button("CloseColl")) { LineRenderer lr = _t.GetComponent <LineRenderer>(); if (lr != null) { lr.enabled = false; } } }
public void SetBoxColor(GameObject _curBox) { if (IsShowBoxLine) { //颜色 Collider_Vis collider_Vis = null; LineRenderer lineRenderer = null; MeshRenderer meshRenderer = null; if (_curBox.GetComponent <MeshRenderer>() && _curBox.GetComponent <Collider_Vis>()) { collider_Vis = _curBox.GetComponent <Collider_Vis>(); meshRenderer = _curBox.GetComponent <MeshRenderer>(); collider_Vis.linewidth = 0.2f; collider_Vis.updateColl(); } lineRenderer = _curBox.GetComponent <LineRenderer>(); var material = new Material(Shader.Find("Legacy Shaders/Transparent/Diffuse")); if (boxcolor.ContainsKey(LayerMask.LayerToName(_curBox.layer))) //Attck { if (collider_Vis != null) { collider_Vis.lineColor = boxcolor[LayerMask.LayerToName(_curBox.layer)].linecolor; } material.color = boxcolor[LayerMask.LayerToName(_curBox.layer)].boxcolor; } meshRenderer.enabled = true; lineRenderer.enabled = true; meshRenderer.material = material; collider_Vis.updateColl(); } }