Closed Kabum80 closed 5 years ago
Showing the script you're using could help
Oh, my bad.
I just test it with example code from the readme file. Doesn't work.*
using UnityEngine; using Gizmos = Popcron.Gizmos; public class GizmoDrawer : MonoBehaviour { public Material material = null;
private void Update()
{
//use custom material, if null it uses a default line material
Gizmos.Material = material;
//toggle gizmo drawing using the same key as in minecraft
if (Input.GetKeyDown(KeyCode.F3))
{
Gizmos.Enabled = !Gizmos.Enabled;
}
//draw a line from the position of the object, to world center
//with the color green, and dashed as well
Gizmos.Line(transform.position, Vector3.one, Color.green, true);
//draw a cube at the position of the object, with the correct rotation and scale
Gizmos.Cube(transform.position, transform.rotation, transform.lossyScale);
}
}`
To be clear, does it show only in play mode, only in edit mode, or neither? @Kabum80
I just tested the example readme script and it worked.
@Kabum80, if you resolved your issue, you could write about it here (what was the problem, how you solved it). It might help others with similar problems. ;)
I might know what it was. With current example it is impossible to render on both Scene and Game views at the same time. If your layout shows both Scene and Game views at the same time, example code will render only on one view - for me it is Scene view, but it can be changed if you will play with windows. But if Game view is active only on Play (which means Scene view is inactive on Play), then everything works alright - example is rendered on both views when they're switched.
BTW, example code is now rendered only in Play mode. If you want to see Gizmos in Edit mode too, following code can be used (this will also render on both Scene and Game views at the same time:
[ExecuteInEditMode] // add this Attribute
public class GizmoDrawer : MonoBehaviour
...
void OnRenderObject() // use this instead of Update
...
Hello, i have the same issue as @Kabum80 (but mine dont show at any moments) , so i tried to follow @RunninglVlan 's solution. But it does not works for me or i followed your idea wrong, but idk why since i tried to add ExecuteInEditMode
and i dont think i have multiple game views at the same time. My code is:
using Gizmos = Popcron.Gizmos; . . . Gizmos.Line(Vector3.one, n.worldPosition);
I also use unity 2019.2.3f1.
TIA
Are you using SRP? This package works in all versions that aren't using SRP, and if you are then only in 2019.3.
No, i do not think I use SRP.At least i do not remember using it or ever heard of it. Looks weird. As you can see here :https://imgur.com/a/bXMhF3l the white thing is drawn by lines (it does a weird effect bc i changes the z pos trough the line so i am sure at least a part is displayed, But on the built version, it doesnt : https://imgur.com/a/yJpgfxQ
The weird effect in game view is because your view is scaled down to below 1x, causing some pixels to not render because there's the resolution was reduced. As for the build, do you know if Gizmos.Enabled is set to true, and that the code for rendering is running?
Oh ok i now changed the OnDrawGizmos function ( i forget that it was obviously not being called if it is run in the built version haha) to just Draw then calling it from the update method, it now works perfectly ! Thanks a lot from your work and your help :)
Hi. Thank you for your work to bring Gizmos to life also in build and play mode. I find it useful. I would just like to say, that it doesn't work in Unity 2019.1.0f2. It shows gizmo for a moment in play mode and then it goes away.