浏览代码

Optim: Don't update scenes when Hide is not focused

trethaller 6 年之前
父节点
当前提交
b983270a66
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 5 0
      hide/Ide.hx
  2. 1 1
      hide/comp/Scene.hx

+ 5 - 0
hide/Ide.hx

@@ -14,6 +14,7 @@ class Ide {
 	public var mouseY : Int = 0;
 
 	public var isWindows(get, never) : Bool;
+	public var isFocused(get, never) : Bool;
 
 	public var database : cdb.Database;
 	public var databaseApi : hide.comp.cdb.Editor.EditorApi;
@@ -214,6 +215,10 @@ class Ide {
 		return true;
 	}
 
+	function get_isFocused() {
+		return js.Browser.document.hasFocus();
+	}
+
 	function onWindowChange() {
 		if( hasReloaded )
 			return;

+ 1 - 1
hide/comp/Scene.hx

@@ -172,7 +172,7 @@ class Scene extends Component implements h3d.IDrawable {
 			ide.unregisterUpdate(sync);
 			return;
 		}
-		if( !visible )
+		if( !visible || !Ide.inst.isFocused)
 			return;
 		setCurrent();
 		sevents.checkEvents();