Can I Detect Input in Scene View for my Running Game?

Hi,

I’m working on a hitbox editor for my game - see my comment here for more details. As a summary for this post, here’s the context:

  • A Hit is a game object with a collider, and updates are applied to applicable game objects that come into contact with the collider (e.g. if a hitbox collides with a character, the character takes damage, has their velocity updated, etc.)
  • Hitboxes are generated by a Cast, which statically defines, on a per-frame basis while it is active, what Hit prefabs to instantiate and where to place them in space

As a matter of application, here’s what I’m trying to do with them:

  • View
    • Stop real-time physics updating for the game, and allow for walking through the game phyics on a frame-by-frame basis
    • Instantiate a Cast and the Hits contained within; step through the frames to enable/disable the Hits
  • Modify
    • Modify the transform of a selected Hit for the given active frame
    • Propagate changes of an active Hit to the prefab that it comes from

The above functionalities are currently in place, so here’s my issue: As far as I know, I can only step through the frame-by-frame logic of my Cast by running the game, so I play the game with the considerations mentioned above. I can do everything that I want to do in the running Game view except for modifying the GameObject Transforms, so I have to switch between tabs to Scene. Then , after changing the transform, I can only step through frames again, run the command to save my changes, etc. in the Game view.

This might be a bit of an XY problem, so if the above is my Y, here’s my X: For the sake of ease of editing, I’d like to do both from the same view.

In order to meet this condition, here are the gaps in my Editor’s capabilities that I’d need to satisfy:

  • For Scene view: I’d need to be able to collect user input that I could then apply to my running game’s state. I don’t really understand how Unity processes the Game and Scene views differently, so I don’t know how feasible this is.
  • For Game view: I’d need to add functionality to select game objects and modify their transforms from within the running game. Using the implementation refrenced in this video, I actually started with this route, but I think it’ll take me a lot more work to achieve that, because I’d need to add the previously mentioned functionality as well as camera controls, which effectively reinvents what’s already available to me in the Scene view.

In summary, I think the answer to my X problem involves fleshing out the mentioned functionalities in the editor views. The Y problem I initially mentioned would solve my X problem by enabling me to build the functionality I could use for the Scene view. If that’s impossible/infeasible, then I’d have to do all of the work involved for the Game view functionality.

Here is what may help you. Unlock the input from Game View so you don’t need to constantly focus it to proceed with gameplay part of your process.

1 Like

Hmm, interesting. Based on what’s described, I would expect that changing this configuration would have worked. I also did set the game to Play Unfocused. However, the game still isn’t detecting my inputs. I also tested inputs that are programmed in using UnityEngine.InputSystem as well as UnityEngine.Input, and inputs to be handled through neither system were detected.

I’m not sure why the configuration isn’t working as I’d expect, but I’ll keep digging around, because it does seem that this would give me the functionality I want.

Unity version: 2022.3.2f1
Platform: Windows 11

1 Like

I assume you are using direct input rather than Actions (when using UnityEngine.InputSystem). This document has some details and highlights that “Actions” don’t work in edit mode
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.11/manual/UseInEditor.html

You may also be looking for code like this to run in EditMode