diff options
author | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
---|---|---|
committer | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
commit | eb84bb298d2b95aec7b2ae12cbf25ac64f25379a (patch) | |
tree | efd616a157df06ab661c6d56651853431ac6b08b /VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Scripts/GameViewMethods.cs | |
download | unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.gz unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.bz2 unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.zip |
move to self host
Diffstat (limited to 'VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Scripts/GameViewMethods.cs')
-rw-r--r-- | VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Scripts/GameViewMethods.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Scripts/GameViewMethods.cs b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Scripts/GameViewMethods.cs new file mode 100644 index 00000000..50504090 --- /dev/null +++ b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Scripts/GameViewMethods.cs @@ -0,0 +1,49 @@ +using System; +using System.Reflection; + +namespace VRC. SDKBase +{ + public static class GameViewMethods + { + private static readonly Type GameViewType = System.Type.GetType("UnityEditor.GameView,UnityEditor"); + private static readonly Type PlayModeViewType = System.Type.GetType("UnityEditor.PlayModeView, UnityEditor"); + + public static int GetSelectedSizeIndex() + { + return (int) GetSelectedSizeProperty().GetValue(GetPlayModeViewObject()); + } + + public static void SetSelectedSizeIndex(int value) + { + var selectedSizeIndexProp = GetSelectedSizeProperty(); + selectedSizeIndexProp.SetValue(GetPlayModeViewObject(), value, null); + } + + // Set it to something else just to force a refresh + public static void ResizeGameView() + { + int current = GetSelectedSizeIndex(); + SetSelectedSizeIndex(current == 0 ? 1 : 0); + } + + private static PropertyInfo GetSelectedSizeProperty() + { + return GameViewType.GetProperty("selectedSizeIndex", + BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + } + + private static Object GetPlayModeViewObject() + { + MethodInfo GetMainPlayModeView = PlayModeViewType.GetMethod("GetMainPlayModeView", + System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); + return GetMainPlayModeView.Invoke(null, null); + } + + public static void Repaint() + { + MethodInfo RepaintAll = PlayModeViewType.GetMethod("RepaintAll", BindingFlags.NonPublic | BindingFlags.Static); + RepaintAll.Invoke(GetPlayModeViewObject(), null); + } + + } +}
\ No newline at end of file |