Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question For an editor script, how can I iterate over enabled virtual players?

Discussion in 'Multiplayer Tools' started by Yoraiz0r, Jul 15, 2023.

  1. Yoraiz0r

    Yoraiz0r

    Joined:
    Apr 26, 2015
    Posts:
    78
    I'm trying to make some editor scripts for MPPM 0.2.0 to address quality of life issues, and I'm noticing that almost everything is internal or private, severely handicapping what I feel I can do.

    My current set of issues is these:
    • Every time I enter playmode, the virtual players flash in the taskbar
    • Every time I enter playmode, the virtual players undock and seemingly cap their position/size to fit in screen
    I solved the first problem by making a debug script that calls user32.dll FlashWindowEx to clear the flashing one frame after playing, but this is done per player window, without any involvement from the primary editor.

    For the other problem, I am uncertain on what to do. The primary quality of life would be to just let the players remember where they are / their maximization status, but no matter what I try to do I can't seem to get that rolling. It seems like Unity is pushing the windows around at an undetermined time after creation, because even calling user32.dll's SetWindowPos only partially works (the size I call is being capped somewhere)

    I'd like to make a script that checks how many virtual players they are, and then sets their position / size to fill different portions of my screen, if I can't get the windows to remember their state.

    It seems that any attempt to access anything but CurrentPlayer.Tag is futile, I'm uncertain if I should try using reflection for this... but the tag alone cannot tell me how many players are enabled, just the current one's tag.

    What's the best way to approach this?