JohnBaracuda / com.baracuda.runtime-monitoring

Runtime Monitoring is an easy way for you to monitor the value or state of custom C# members during runtime. Just add the 'Monitor' attribute to a field, property, event, method or even class and get its value or state displayed automatically in a customizable and extendable debug UI.
MIT License
419 stars 23 forks source link

monitored field appears twice in runtime window #4

Closed androvisuals closed 2 years ago

androvisuals commented 2 years ago

using Baracuda.Monitoring; using Baracuda.Monitoring.API;
[Monitor] [SerializeField] int aggroCounter = 0; [Monitor] [SerializeField] float decisionScoreForCover = 0;

in Start I have MonitoringManager.RegisterTarget(this);

this results in the fields appearing twice. Shouldn't they only appear once? I removed the SerializeField attribute but this didn't change anything. Any and all help appreciated.

image

JohnBaracuda commented 2 years ago

Hey, I was unable to reproduce this using the same code. Some suggestrions I have:

If it's still not working I would need a little bit more information about version, what you class is inheriting from etc. Hope that this may help :)

androvisuals commented 2 years ago

Hi there, So it was my mistake. I have a class where I use override behavior. So it was getting called twice on start, even though I "only" had it inside the start function of the class ;-)

I now moved the MonitoringManager code to the class the rest inherit from and it all appears only once, and now works perfectly across all the scripts that use it. The code below is to show what now works correctly for me. An amazing asset, glad you've shared it with the world <3 Thanks for the speedy reply and help!


using Baracuda.Monitoring.API;
public class StateAI : MonoBehaviour
{
    public Soldier soldier;
    protected virtual void Start()
    {
        MonitoringManager.RegisterTarget(this);
    }

    public virtual void AwakeSoldierAI() { }
    public virtual void StartSoldierAI() { }
    public virtual void UpdateSoldierAI() { }
    public virtual void LateUpdateSoldierAI() { }
}```