From 569c6447233c7cf8864c74a4df851015340a1f0f Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Tue, 27 May 2014 11:16:55 +0100 Subject: [PATCH] Added AnchorGUITexture component and prefab. AnchorGUITexture draws a texture on the screen at a consistent size and position regardless of the screen resolution & aspect ratio. --- Assets/Fungus/Prefabs/AnchorGUITexture.prefab | Bin 0 -> 4136 bytes .../Prefabs/AnchorGUITexture.prefab.meta | 4 + Assets/Fungus/Scripts/AnchorGUITexture.cs | 71 ++++++++++++++++++ .../Fungus/Scripts/AnchorGUITexture.cs.meta | 8 ++ 4 files changed, 83 insertions(+) create mode 100644 Assets/Fungus/Prefabs/AnchorGUITexture.prefab create mode 100644 Assets/Fungus/Prefabs/AnchorGUITexture.prefab.meta create mode 100644 Assets/Fungus/Scripts/AnchorGUITexture.cs create mode 100644 Assets/Fungus/Scripts/AnchorGUITexture.cs.meta diff --git a/Assets/Fungus/Prefabs/AnchorGUITexture.prefab b/Assets/Fungus/Prefabs/AnchorGUITexture.prefab new file mode 100644 index 0000000000000000000000000000000000000000..0c9fd8f70da9a72e7f131e38be50392cb36c730c GIT binary patch literal 4136 zcmeHJ$!^;)5FK|(_kCZJZa_`}iso1Z>6SK!wt~^SL0hz-@IxP~IRdh*7W_YQIU4(_Xj2Kt*V0Xo=7UoJbNVT3E2n{R*x!Tjb3PYfZ(p+SR z_8?!YT%B4p`%Suzd&hFQ(F{_p+gxr25Ur*tep`leD)Hb>B%j<{o>Q=PAn|)%vRalEIQ*4JfsWNI*AWG z5Sg7?9|b_1(_S=mP1xI^y3;88W6vj;ecc0**~z{U0CDz@BA4zB%tu3|%xZ_b{lxPO za(L>2$n0=<766Tv%CPeN(pFvFkJP;9$Du#`m}M%KF}L|e6S-R%I8l^e$sfKRH*rlr f81(5!uRyOruRyOruRyOruRyQBf2qI#|KI%s Screen.width - padding.x) + { + x2 = Screen.width - padding.x; + x1 = x2 - width; + } + if (y1 < padding.y) + { + y1 = padding.y; + y2 = y1 + height; + } + if (y2 > Screen.height - padding.y) + { + y2 = Screen.height - padding.y; + y1 = y2 - height; + } + + // Draw the texture + Rect textureRect = new Rect(x1, y1, x2 - x1, y2 - y1); + GUI.DrawTexture(textureRect, texture); + } +} diff --git a/Assets/Fungus/Scripts/AnchorGUITexture.cs.meta b/Assets/Fungus/Scripts/AnchorGUITexture.cs.meta new file mode 100644 index 00000000..a44847b1 --- /dev/null +++ b/Assets/Fungus/Scripts/AnchorGUITexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8ea93591566a948c1bb46ec405d87bb5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: