dwelling act 4 (live motion cap w/ kinect azure)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.7 KiB

1 year ago
using System;
using UnityEditor;
using UnityEngine;
namespace FullscreenEditor {
[InitializeOnLoad]
public class RestoreCursorState {
static RestoreCursorState() {
var cursorVisible = Cursor.visible;
// this is where the magic happens
Action<FullscreenContainer> magic = (fs) => {
if (!FullscreenPreferences.RestoreCursorLockAndHideState) return;
// frame count doesn't seem to make much of a difference,
// but I think it's best to do this after the view is
// focused by the "FixGameViewMouseInput" class
After.Frames(55, () => {
var gameView = fs.m_dst.Window && fs.m_dst.Window.IsOfType(Types.GameView) ? fs.m_dst.Window :
fs.m_src.Window && fs.m_src.Window.IsOfType(Types.GameView) ? fs.m_src.Window : null;
if (!EditorApplication.isPaused && gameView && gameView.IsOfType(Types.GameView) && gameView.HasMethod("AllowCursorLockAndHide")) {
gameView.InvokeMethod("AllowCursorLockAndHide", true);
Unsupported.SetAllowCursorHide(true);
Cursor.visible = cursorVisible;
}
});
};
Action<FullscreenContainer> storeCursorVisible = (fs) => {
cursorVisible = Cursor.visible;
};
FullscreenCallbacks.afterFullscreenOpen += magic;
FullscreenCallbacks.afterFullscreenClose += magic;
FullscreenCallbacks.beforeFullscreenOpen += storeCursorVisible;
FullscreenCallbacks.beforeFullscreenClose += storeCursorVisible;
}
}
}