Search Unity

Feedback Best Practices/suggestions For Third Party Input In Editor

Discussion in 'Cinemachine' started by Andrew-Carvalho, Apr 14, 2019.

  1. Andrew-Carvalho

    Andrew-Carvalho

    Joined:
    Apr 22, 2013
    Posts:
    45
    Hey!

    I'm using InControl as a third party input library and it's working with Cinemachine just fine by overriding the delegate provided in CinemachineCore with a simple wrapper.

    My issue is that it seems Cinemachine is polling input in the editor. When I first boot up the project, I get a bunch of error logs complaining about missing input axes. If I play in editor, my code overrides the static delegate and, upon stopping, the errors go away since the static reference sticks past play mode. A solution, but not elegant.

    I'm about to throw a quick [InitializeOnLoad] call on an editor script to override the delegate on editor boot but was wondering if there was a best practice or a better way (short of editing the source) to make this happen.

    I'm also curious as to why the input is being polled at all at edit time. I don't use many of the built in features yet, so I imagine there is good reason for this (live preview?), so this question is mainly for my own curiosity.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    It's not polling unless you're in Play mode.
     
  3. Andrew-Carvalho

    Andrew-Carvalho

    Joined:
    Apr 22, 2013
    Posts:
    45
    I have a stack trace that says otherwise. Though in reality this is probably due to not fully understanding where the AxisState member should belong.

    CinemachineBrain is execute in edit mode which cascades to a mutate camera state call which is where I have the axisstate being updated. I imagine this isn't the intended way to do this (polling input in a CinemachineComponent) and that I should be writing a class that extends the CinemachineVirtualCameraBase and poll input there.

    I get the functionality I want with the simple CinemachineVirtualCamera and my components but I can rebuild the logic a layer higher.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Right. CM is updating the vcams in Edit mode (for preview), but the built-in CM vcams are smart enough to only poll input when in play mode.