static void SelectSettingsGO() { UnityEditor.Selection.activeObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath("Assets/Resources/" + "Settings" + ".asset"); // Lock settings window { Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditor.InspectorWindow"); UnityEngine.Object [] findObjectsOfTypeAll = Resources.FindObjectsOfTypeAll(type); if (findObjectsOfTypeAll.Length == 0) { return; } foreach (var window in findObjectsOfTypeAll) { UnityEditor.EditorWindow settingsWindow = (UnityEditor.EditorWindow)window; // Lock the taller settings window if (settingsWindow.position.height > 600) { PropertyInfo propertyInfo = type.GetProperty("isLocked"); propertyInfo.SetValue(settingsWindow, true, null); settingsWindow.Repaint(); } } } }
private void Initialize() { _gameWindow = GetMainGameView(); _windowParentBoundsAccessor = GetWindowParentBoundsAccessor(_gameWindow); _toolbarHeight = GetToolbarHeight(); _initialized = true; }
private void Start() { sw = FileManager.GetStreamWriter((FileManager.GetFilePath("Input.rec"))); if (sw == null) { return; } Debug.Log("luckyhigh Input Record start"); #if UNITY_EDITOR // 获得gameView窗口 System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); gameView = UnityEditor.EditorWindow.GetWindow(T, true, "Game") as UnityEditor.EditorWindow; // 获得gameView中渲染窗口的分辨率 var prop = gameView.GetType().GetProperty("currentGameViewSize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var gvsize = prop.GetValue(gameView, new object[0] { }); var gvSizeType = gvsize.GetType(); height = (int)gvSizeType.GetProperty("height", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0] { }); width = (int)gvSizeType.GetProperty("width", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0] { }); #elif UNITY_ANDROID height = Screen.currentResolution.height; width = Screen.currentResolution.width; #endif StreamWriter ssww = FileManager.GetStreamWriter((FileManager.GetFilePath("Resolution.rec"))); ssww.WriteLine(height + " x " + width); ssww.Close(); }
public void RemoveTab(UnityEditor.EditorWindow pane, bool killIfEmpty, bool sendEvents = true) { if (__RemoveTab_1_3 == null) { __RemoveTab_1_3 = (Action <UnityEditor.EditorWindow, bool, bool>)Delegate.CreateDelegate(typeof(Action <UnityEditor.EditorWindow, bool, bool>), m_instance, UnityTypes.UnityEditor_DockArea.GetMethod("RemoveTab", R.InstanceMembers, null, new Type[] { typeof(UnityEditor.EditorWindow), typeof(bool), typeof(bool) }, null)); } __RemoveTab_1_3(pane, killIfEmpty, sendEvents); }
public void AddTab(int idx, UnityEditor.EditorWindow pane, bool sendPaneEvents = true) { if (__AddTab_1_3 == null) { __AddTab_1_3 = (Action <int, UnityEditor.EditorWindow, bool>)Delegate.CreateDelegate(typeof(Action <int, UnityEditor.EditorWindow, bool>), m_instance, UnityTypes.UnityEditor_DockArea.GetMethod("AddTab", R.InstanceMembers, null, new Type[] { typeof(int), typeof(UnityEditor.EditorWindow), typeof(bool) }, null)); } __AddTab_1_3(idx, pane, sendPaneEvents); }
public void RemoveTab(UnityEditor.EditorWindow pane) { if (__RemoveTab_0_1 == null) { __RemoveTab_0_1 = (Action <UnityEditor.EditorWindow>)Delegate.CreateDelegate(typeof(Action <UnityEditor.EditorWindow>), m_instance, UnityTypes.UnityEditor_DockArea.GetMethod("RemoveTab", R.InstanceMembers, null, new Type[] { typeof(UnityEditor.EditorWindow) }, null)); } __RemoveTab_0_1(pane); }
public static void ShowNotification(UnityEditor.EditorWindow editor, GUIContent content, float time = 2) { #if UNITY_2019_1_OR_NEWER editor.ShowNotification(content, time); #else editor.ShowNotification(content); #endif }
public void LoadAndStartRenderDocCapture(out UnityEditor.EditorWindow gameView) { UnityEditorInternal.RenderDoc.Load(); System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly; Type type = assembly.GetType("UnityEditor.GameView"); gameView = UnityEditor.EditorWindow.GetWindow(type); UnityEditorInternal.RenderDoc.BeginCaptureRenderDoc(gameView); }
static void Init() { UnityEditor.EditorWindow window = GetWindow(typeof(BrokenSubEmitterSetup), false, "SubEmitter"); window.minSize = new Vector2(400, 100); window.maxSize = new Vector2(400, 100); window.position = new Rect(300, 300, 400, 100); window.Show(); }
public static void CenterOnMainWin(this UnityEditor.EditorWindow aWin) { var main = GetEditorMainWindowPos(); var pos = aWin.position; float w = (main.width - pos.width) * 0.5f; float h = (main.height - pos.height) * 0.5f; pos.x = main.x + w; pos.y = main.y + h; aWin.position = pos; }
static void Init() { UnityEditor.EditorWindow window = GetWindow(typeof(PaletteGenerator)); const int width = 500; const int height = 500; Vector2 size = new Vector2(width, height); window.minSize = size; window.position = new Rect(0, 0, width, height); window.Show(); }
private void SetGameviewScale(float scale) { System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly; System.Type type = assembly.GetType("UnityEditor.GameView"); UnityEditor.EditorWindow v = UnityEditor.EditorWindow.GetWindow(type); var areaField = type.GetField("m_ZoomArea", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var areaObj = areaField.GetValue(v); var scaleField = areaObj.GetType().GetField("m_Scale", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); scaleField.SetValue(areaObj, new Vector2(scale, scale)); }
public static void CenterOnApplicationWindow(this UnityEditor.EditorWindow window, Vector2?size = null) { var main = GetApplicationScreenRect(); var pos = window.position; pos.size = size.GetValueOrDefault(pos.size); float w = (main.width - pos.width) * 0.5f; float h = (main.height - pos.height) * 0.5f; pos.x = main.x + w; pos.y = main.y + h; window.position = pos; }
static void Init() { // Get existing open window or if none, make a new one: UnityEditor.EditorWindow window = GetWindow(typeof(ShirtStandalone)); //Show the window when it is called on window.minSize = new Vector2(360, 1100); window.Show(); /*if (!(AssetDatabase.IsValidFolder ("UMC_Assets"))) { * WebClient client = new WebClient(); * client.DownloadFile (url, Application.persistentDataPath + "/" + "Shirt.unitypackage"); * }*/ }
public static bool SetGizmosVisible(bool bVisible) { System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.Editor)); System.Type type = asm.GetType("UnityEditor.GameView"); if (type != null) { UnityEditor.EditorWindow window = UnityEditor.EditorWindow.GetWindow(type); FieldInfo gizmosField = type.GetField("m_Gizmos", BindingFlags.NonPublic | BindingFlags.Instance); if (gizmosField != null) { gizmosField.SetValue(window, bVisible); } } return(false); }
/// <summary> /// Ares the gizmos visible. /// /// Author: Edwin /// Source: http://answers.unity3d.com/questions/41591/how-can-i-tell-if-the-gizmos-button-has-been-check.html /// </summary> /// <returns><c>true</c>, if gizmos visible was ared, <c>false</c> otherwise.</returns> bool AreGizmosVisible() { Assembly asm = Assembly.GetAssembly(typeof(UnityEditor.Editor)); Type type = asm.GetType("UnityEditor.GameView"); if (type != null) { UnityEditor.EditorWindow window = UnityEditor.EditorWindow.GetWindow(type); FieldInfo gizmosField = type.GetField("m_Gizmos", BindingFlags.NonPublic | BindingFlags.Instance); if (gizmosField != null) { return((bool)gizmosField.GetValue(window)); } } return(false); }
void SetGameViewScale() { System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly; System.Type type = assembly.GetType("UnityEditor.GameView"); UnityEditor.EditorWindow v = UnityEditor.EditorWindow.GetWindow(type); var defScaleField = type.GetField("m_defaultScale", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); //whatever scale you want when you click on play float defaultScale = 0.1f; var areaField = type.GetField("m_ZoomArea", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var areaObj = areaField.GetValue(v); var scaleField = areaObj.GetType().GetField("m_Scale", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); scaleField.SetValue(areaObj, new Vector2(defaultScale, defaultScale)); }
void InstantiatePrimitive(TipoObjetivo op) { switch (op) { case TipoObjetivo.uniTargetEnemy: GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = Vector3.zero; break; case TipoObjetivo.uniTargetAlly: GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.position = Vector3.zero; break; case TipoObjetivo.allEnemies: GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane); plane.transform.position = Vector3.zero; break; case TipoObjetivo.allAllies: GameObject plane2 = GameObject.CreatePrimitive(PrimitiveType.Plane); plane2.transform.position = Vector3.zero; break; case TipoObjetivo.allMap: GameObject plane3 = GameObject.CreatePrimitive(PrimitiveType.Plane); plane3.transform.position = Vector3.zero; break; case TipoObjetivo.area: if (!ventanaAbierta) { ventanaAbierta = true; UnityEditor.EditorWindow window = new UnityEditor.EditorWindow(); window.Show(); } break; default: Debug.LogError("Unrecognized Option"); break; } }
public static void MaximizeWindow(UnityEditor.EditorWindow window) { if (TestUtility.windowLayout == null) { TestUtility.windowLayout = typeof(UnityEditor.EditorWindow).Assembly.GetType(TestUtility.WindowLayoutType); if (TestUtility.windowLayout == null) { Debug.LogError("Type \"" + TestUtility.WindowLayoutType + "\" was not found in assembly. It may happens in newer version of Unity. Please contact NG Tools."); } } if (TestUtility.windowLayout != null && TestUtility.maximize == null) { TestUtility.maximize = TestUtility.windowLayout.GetMethod(TestUtility.MaximizeMethod, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (TestUtility.maximize == null) { Debug.LogError("Method \"" + TestUtility.MaximizeMethod + "\" was not found in type \"" + TestUtility.WindowLayoutType + "\". It may happens in newer version of Unity. Please contact NG Tools."); } } TestUtility.maximize.Invoke(null, new object[] { window }); }
// Use this for initialization void Start() { Debug.Log("lucky start play keyboard"); sr = FileManager.GetStreamReader((FileManager.GetFilePath("KeyBoard.rec"))); if (sr == null) { return; } System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); gameView = UnityEditor.EditorWindow.GetWindow(T, true, "Game") as UnityEditor.EditorWindow; if ((line = sr.ReadLine()) != null) { string[] ss = line.Split(' '); time = Convert.ToSingle(ss[0]); key = ss[1]; type = Convert.ToInt32(ss[2]); } }
public static bool IsMaximized(UnityEditor.EditorWindow window) { if (TestUtility.windowLayout == null) { TestUtility.windowLayout = typeof(UnityEditor.EditorWindow).Assembly.GetType(TestUtility.WindowLayoutType); if (TestUtility.windowLayout == null) { Debug.LogError("Type \"" + TestUtility.WindowLayoutType + "\" was not found in assembly. It may happens in newer version of Unity. Please contact " + Constants.PackageTitle + "."); } } if (TestUtility.windowLayout != null && TestUtility.isMaximized == null) { TestUtility.isMaximized = TestUtility.windowLayout.GetMethod(TestUtility.IsMaximizedMethod, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (TestUtility.isMaximized == null) { Debug.LogError("Method \"" + TestUtility.IsMaximizedMethod + "\" was not found in type \"" + TestUtility.WindowLayoutType + "\". It may happens in newer version of Unity. Please contact " + Constants.PackageTitle + "."); } } return((bool)TestUtility.isMaximized.Invoke(null, new object[] { window })); }
/// <summary> /// Gets an accessor to the parent panel's bounds accessor. /// </summary> /// <param name="gameView">The game view.</param> /// <returns>An accessor to the parent panel's bounds accessor</returns> protected virtual Func <Rect> GetWindowParentBoundsAccessor(UnityEditor.EditorWindow gameView) { System.Diagnostics.Debug.Assert(gameView != null); var parentHostField = gameView.GetType().GetField("m_Parent", BindingFlags.NonPublic | BindingFlags.Instance); if (parentHostField != null) { var parentHost = parentHostField.GetValue(gameView); if (parentHost != null) { var windowPositionProperty = parentHost.GetType().GetProperty("windowPosition", BindingFlags.Public | BindingFlags.Instance); if (windowPositionProperty != null) { // Create a delegate to get the parent host bounds. return((Func <Rect>) Delegate.CreateDelegate(typeof(Func <Rect>), parentHost, windowPositionProperty.GetGetMethod())); } } } throw new InvalidOperationException("Could not resolve window parent position accessor."); }
private void Start() { // 文件读写 sr = FileManager.GetStreamReader((FileManager.GetFilePath("Input.rec"))); Debug.Log("lucky start play input"); if (sr == null) { return; } cursor = DebugControl.instance.cursor; // 获得gameView窗口 System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); gameView = UnityEditor.EditorWindow.GetWindow(T, true, "Game") as UnityEditor.EditorWindow; // 获得gameView中渲染窗口的分辨率 var prop = gameView.GetType().GetProperty("currentGameViewSize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var gvsize = prop.GetValue(gameView, new object[0] { }); var gvSizeType = gvsize.GetType(); resh = (int)gvSizeType.GetProperty("height", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0] { }); resw = (int)gvSizeType.GetProperty("width", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0] { }); if ((line = sr.ReadLine()) != null) { string[] ss = line.Split(' '); time = Convert.ToSingle(ss[0]); type = (MouseType)Convert.ToInt32(ss[1]); xpre = Convert.ToSingle(ss[2]); ypre = Convert.ToSingle(ss[3]); } }
/// <summary> /// Obsolete. Use editorWindow.IsFullscreenOnDisplay(display) method. /// </summary> public static bool EditorWindowIsFullscreenOnDisplay(UnityEditor.EditorWindow editorWin, SystemDisplay display) { string windowTitle = editorWin.GetWindowTitle(); MethodInfo windowIsFullscreenOnDisplay = null; try { windowIsFullscreenOnDisplay = typeof(NativeDisplay).BaseType.GetMethod("WindowIsFullscreenOnDisplay", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new[] { typeof(string), typeof(SystemDisplay) }, null); } catch { } bool winIsFullscreen = false; //If the OS Native Display class has the method, call that, otherwise use a fallback. if (windowIsFullscreenOnDisplay != null) { winIsFullscreen = (bool)windowIsFullscreenOnDisplay.Invoke(null, new object[] { windowTitle, display }); } else { winIsFullscreen = editorWin.position.Contains(display.Bounds) && editorWin.position.width == display.Bounds.width; } return(winIsFullscreen); }
static void Init() { UnityEditor.EditorWindow window = GetWindow(typeof(GetTransformWindow)); window.Show(); }
static void Init() { UnityEditor.EditorWindow window = GetWindow(typeof(mapSceneGenerator)); window.position = new Rect(0, 0, 250, 80); window.Show(); }
public static void EndCaptureRenderDoc(UnityEditor.EditorWindow window) => window.m_Parent.EndCaptureRenderDoc();
static void Init() { UnityEditor.EditorWindow window = GetWindow(typeof(Terrainoise)); window.Show(); }
static void Init() { UnityEditor.EditorWindow window = GetWindow(typeof(EnumPopTest)); window.Show(); }
static void init() { UnityEditor.EditorWindow window = GetWindow(typeof(WindowsEditorBullet)); window.Show(); }