public static void DrawSprite(Sprite sprite, Rect rect, float texCoordsScale) { if (sprite != null) { Texture tex = sprite.texture; Rect texRect = sprite.textureRect; Rect texCoordsRect = new Rect(texRect.x / tex.width, texRect.y / tex.height, texRect.width / tex.width, texRect.height / tex.height); texCoordsRect = texCoordsRect.ScaleSizeBy(texCoordsScale); GUI.DrawTextureWithTexCoords(rect, tex, texCoordsRect); } }
public static Rect Begin(float zoomScale, Rect screenCoordsArea) { GUI.EndGroup(); Rect clippedArea = screenCoordsArea.ScaleSizeBy(1.0f / zoomScale, screenCoordsArea.TopLeft()); clippedArea.y += BonWindow.TopOffset; GUI.BeginGroup(clippedArea); _prevGuiMatrix = GUI.matrix; Matrix4x4 translation = Matrix4x4.TRS(clippedArea.TopLeft(), Quaternion.identity, Vector3.one); _tmpScaleVector.Set(zoomScale, zoomScale, 1.0f); Matrix4x4 scale = Matrix4x4.Scale(_tmpScaleVector); GUI.matrix = translation * scale * translation.inverse * GUI.matrix; return clippedArea; }
public static Rect Begin(float zoomScale, Rect screenCoordsArea) { GUI.EndGroup(); // End the group Unity begins automatically for an EditorWindow to clip out the window tab. This allows us to draw outside of the size of the EditorWindow. Rect clippedArea = screenCoordsArea.ScaleSizeBy(1.0f / zoomScale, screenCoordsArea.TopLeft()); clippedArea.y += kEditorWindowTabHeight; GUI.BeginGroup(clippedArea); _prevGuiMatrix = GUI.matrix; Matrix4x4 translation = Matrix4x4.TRS(clippedArea.TopLeft(), Quaternion.identity, Vector3.one); Matrix4x4 scale = Matrix4x4.Scale(new Vector3(zoomScale, zoomScale, 1.0f)); GUI.matrix = translation * scale * translation.inverse * GUI.matrix; return clippedArea; }
public bool ContainsRect(Rect sourceRect) { if (this.zoomDrawer.GetZoom() < 1f) { return true; } var scrollPos = -FlowSystem.GetScrollPosition(); var rect = new Rect(scrollPos.x - this.scrollRect.width * 0.5f + this.scrollRect.x, scrollPos.y + this.scrollRect.y, this.scrollRect.width + FlowSystemEditorWindow.GetSettingsWidth(), this.scrollRect.height); var scaledRect = rect.ScaleSizeBy(this.zoomDrawer.GetZoom()); var scaledWin = sourceRect.ScaleSizeBy(this.zoomDrawer.GetZoom()); return scaledRect.Overlaps(scaledWin); }
public Rect Begin(Rect area, Rect contentSize) { GUI.EndGroup(); // End the group Unity begins automatically for an EditorWindow to clip out the window tab. This allows us to draw outside of the size of the EditorWindow. Rect clippedArea = area.ScaleSizeBy(1f / this.zoomValue, this.screenCoordsArea.MiddleMiddle()); //this.screenCoordsArea.ScaleSizeBy(1f / this.zoomValue, this.screenCoordsArea.TopLeft()); clippedArea.y += EditorZoomArea.EDITOR_TAB_HEIGHT; GUI.BeginGroup(clippedArea); this.prevGuiMatrix = GUI.matrix; Matrix4x4 translation = Matrix4x4.TRS(clippedArea.MiddleMiddle(), Quaternion.identity, Vector3.one); Matrix4x4 scale = Matrix4x4.Scale(new Vector3(this.zoomValue, this.zoomValue, 1f)); GUI.matrix = translation * scale * translation.inverse * GUI.matrix; GUI.BeginGroup(new Rect(this.zoomCoordsOrigin.x, this.zoomCoordsOrigin.y, contentSize.width, contentSize.height)); return clippedArea; }
public static Rect BeginZoomArea(float zoomScale, Rect screenCoordsArea) { GUI.EndGroup(); Rect clippedArea = screenCoordsArea.ScaleSizeBy(1.0f / zoomScale, screenCoordsArea.TopLeft()); clippedArea.y += kEditorWindowTabHeight; GUI.BeginGroup(clippedArea); preZoomGUIMatrix = GUI.matrix; Matrix4x4 translation = Matrix4x4.TRS(clippedArea.TopLeft(), Quaternion.identity, Vector3.one); Matrix4x4 scale = Matrix4x4.Scale(new Vector3(zoomScale, zoomScale, 1.0f)); GUI.matrix = translation * scale * translation.inverse * GUI.matrix; return clippedArea; }
public static Rect Begin(Rect screenCoordsArea, float zoomScale) { GUI.EndGroup(); Rect rect = screenCoordsArea.ScaleSizeBy(1f / zoomScale, screenCoordsArea.TopLeft()); rect.y += 21f; GUI.BeginGroup(rect); EditorZoomArea._prevGuiMatrix = GUI.matrix; Matrix4x4 lhs = Matrix4x4.TRS(rect.TopLeft(), Quaternion.identity, Vector3.one); Vector3 one = Vector3.one; one.y = zoomScale; one.x = zoomScale; Matrix4x4 rhs = Matrix4x4.Scale(one); GUI.matrix = lhs * rhs * lhs.inverse * GUI.matrix; return rect; }
public static Rect ScaleSizeBy(this UnityEngine.Rect rect, float scale, Vector2 pivotPoint) { return(rect.ScaleSizeBy(new Vector2(scale, scale), pivotPoint)); }
public static Rect ScaleSizeBy(this UnityEngine.Rect rect, Vector2 scale) { return(rect.ScaleSizeBy(scale, Vector2.zero)); }
public static Rect ScaleSizeBy(this UnityEngine.Rect rect, float scale) { return(rect.ScaleSizeBy(new Vector2(scale, scale), Vector2.zero)); }
public bool IsVisible(FD.FlowWindow window) { if (this.zoomDrawer.GetZoom() < 1f) { return true; } var scrollPos = -FlowSystem.GetScrollPosition(); var rect = new Rect(scrollPos.x - this.scrollRect.width * 0.5f + this.scrollRect.x, scrollPos.y + this.scrollRect.y, this.scrollRect.width + FlowSystemEditorWindow.GetSettingsWidth(), this.scrollRect.height); var scaledRect = rect.ScaleSizeBy(this.zoomDrawer.GetZoom()); var scaledWin = window.rect.ScaleSizeBy(this.zoomDrawer.GetZoom()); //scaledRect.x += FlowSystemEditorWindow.GetSettingsWidth(); return window.isVisibleState = scaledRect.Overlaps(scaledWin); }