Community Made Tools

Have you made any useful utilities with Odin?

Login and submit your creations here

Keep Repainting

Authored by Frantasad
Shared 08-05-2024

Attribute to keep repainting editor Get code on Github.

Info

  • Unity repaints properties only when hovering over editor or when the target object is set dirty.
  • This attribute allows you to manually request repaint for properties.
  • Because unity always repaints the whole editor, only the smallest interval within the editor's property tree will apply.
  • Repaints are scheduled only if the property was not repainted at the specified interval so no worries, the are no redundant calls.

Parameters

  • RepaintInterval - How often should editor repaint, defaults to 0.5s, repaints every frame if set to 0
  • RepaintEditorMode - Repaint in editmode, playmode or both, defaults to both
  • RepaintIf - Optionally you can specify the repaint condition

Usage

[SerializeField]
private bool _DisableRepainting;

[EnableGUI]
[ShowInInspector]
[KeepRepainting(EditorMode.Both, 0.3f, RepaintIf = "@_DisableRepainting == false")]
private float Timer => Time.realtimeSinceStartup;