- Home /
Always show trigger on Editor
Hello, is there a way to set unity to always show the triggers on editor view?
Answer by ArmarageX · Aug 05, 2012 at 04:51 PM
Perhaps an alternative way would be:
1) Make sure your scene rendering mode is [Tex - Wire] (under the scene tab) 2) Add a MATERIAL to the box you are using as trigger. (You may have to import a package that contains materials) 3) Go to the Material Component to change the colour of the material, and turn down the ALPHA (R G B Alpha) 4) You may also need to change the Shader type (the dropdown option) to a Transparent Shader (ie Transparent Diffuse).
So the trigger would be just a box with a semi transparent material on it., and you can see its wireframe as well due to the Textured / Wireframe rendering mode.
Thanks ArmarageX, I'll try it. I'll let you know if it worked.
Answer by Berenger · May 19, 2012 at 04:12 PM
I don't think so. However, you can create a script that draw a gizmos if a collider is a trigger. You just need to attach it to every colliders. It's more convenient to create a static function with MenuItem that search all the triggers and add your component if there isn't one already.
But then I'd need to have the game running in the editor, right? I'd like to see all my triggers in design time.
you need to research Execute in edit mode and then right a script that will draw lines along the edges of the trigger. easiest way would be to make a single script that you have to attach onto each trigger and have them all deactivate when built.
but if you have been coding for a while then you could probably do something a lot better and less time consu$$anonymous$$g.
Answer by sandbaydev · Sep 05, 2013 at 04:05 PM
Old question but since it was relevant to me, answering. If you have a simple cube as the trigger zone, then you can assign script like this to the trigger zone (once loaded, it will destroy the MeshRenderer component):
using UnityEngine;
using System.Collections;
public class TriggerZone : MonoBehaviour {
void Awake() {
Destroy (GetComponent("MeshRenderer"));
}
void OnTriggerEnter (Collider other) {
Debug.Log ("Object entered the trigger zone", other);
}
void OnTriggerStay (Collider other) {
Debug.Log ("Object staying in the trigger zone", other);
}
void OnTriggerExit (Collider other) {
Debug.Log ("Object exited the trigger zone", other);
}
}