├── .gitignore ├── Assets ├── GUIWindows.meta └── GUIWindows │ ├── Cursors.meta │ ├── Cursors │ ├── cursor_diag_a.png │ ├── cursor_diag_a.png.meta │ ├── cursor_diag_b.png │ ├── cursor_diag_b.png.meta │ ├── cursor_horizontal.png │ ├── cursor_horizontal.png.meta │ ├── cursor_vertical.png │ └── cursor_vertical.png.meta │ ├── Examples.meta │ ├── Examples │ ├── ExampleScene.unity │ ├── ExampleScene.unity.meta │ ├── Windows.meta │ └── Windows │ │ ├── Console Window.prefab │ │ ├── Console Window.prefab.meta │ │ ├── Icons.meta │ │ ├── Icons │ │ ├── notepad.png │ │ └── notepad.png.meta │ │ ├── MacOS Themed Window.prefab │ │ ├── MacOS Themed Window.prefab.meta │ │ ├── Minimalist Window.prefab │ │ ├── Minimalist Window.prefab.meta │ │ ├── Scripts.meta │ │ ├── Scripts │ │ ├── ConsoleVisualiser.cs │ │ └── ConsoleVisualiser.cs.meta │ │ ├── Touch Window.prefab │ │ ├── Touch Window.prefab.meta │ │ ├── Windows 10 Notepad Theme.prefab │ │ └── Windows 10 Notepad Theme.prefab.meta │ ├── Resources.meta │ ├── Resources │ ├── WindowUIComponent.prefab │ └── WindowUIComponent.prefab.meta │ ├── Scripts.meta │ └── Scripts │ ├── Editor.meta │ ├── Editor │ ├── GUIPointerObjectEditor.cs │ └── GUIPointerObjectEditor.cs.meta │ ├── GUIBorderParent.cs │ ├── GUIBorderParent.cs.meta │ ├── GUIPointerObject.cs │ ├── GUIPointerObject.cs.meta │ ├── GUIWindow.cs │ ├── GUIWindow.cs.meta │ ├── GUIWindowExpander.cs │ ├── GUIWindowExpander.cs.meta │ ├── GUIWindowHandle.cs │ ├── GUIWindowHandle.cs.meta │ ├── GUIWindowMover.cs │ ├── GUIWindowMover.cs.meta │ ├── GUIWindowUtils.cs │ └── GUIWindowUtils.cs.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset ├── README.md └── gif_demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /Assets/GUIWindows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bb55061b7125984d9966aa3423a5e40 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acc4b1e5f93cd4a4aa6d3bd4079f0edd 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_diag_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Cursors/cursor_diag_a.png -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_diag_a.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b69212126b91114ea8f0a926d77c519 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 1 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -3 25 | maxTextureSize: 2048 26 | textureSettings: 27 | filterMode: 0 28 | aniso: 1 29 | mipBias: -100 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 7 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_diag_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Cursors/cursor_diag_b.png -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_diag_b.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b62059c6b03f004db5a180b61188820 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 1 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -3 25 | maxTextureSize: 2048 26 | textureSettings: 27 | filterMode: 0 28 | aniso: 1 29 | mipBias: -100 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 7 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Cursors/cursor_horizontal.png -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_horizontal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5704ce039ab9a4d41bce815832591a2f 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 1 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -3 25 | maxTextureSize: 2048 26 | textureSettings: 27 | filterMode: 0 28 | aniso: 1 29 | mipBias: -100 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 7 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Cursors/cursor_vertical.png -------------------------------------------------------------------------------- /Assets/GUIWindows/Cursors/cursor_vertical.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40a8ef17dc9780c4085eb2001e1c9ac1 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 1 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -3 25 | maxTextureSize: 2048 26 | textureSettings: 27 | filterMode: 0 28 | aniso: 1 29 | mipBias: -100 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 7 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66c7758ab2f0484419f2a3b61c0d9ed3 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/ExampleScene.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Examples/ExampleScene.unity -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/ExampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc98cf77a4a9aa94b87fa4b2d5a6f466 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 111055fbbc2621f4f9c0d3e303f60089 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Console Window.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Examples/Windows/Console Window.prefab -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Console Window.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8335a7bdd82a9c74bb6bf8c6d4c78ec2 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Icons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2622330da49c3b54594f4d4522d2bdde 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Icons/notepad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Examples/Windows/Icons/notepad.png -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Icons/notepad.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 243ab7c222473b74e9b2761515f7cc66 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: 0 28 | aniso: 16 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 1 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 8 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/MacOS Themed Window.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Examples/Windows/MacOS Themed Window.prefab -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/MacOS Themed Window.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8eb6f1548bb262443a52374fdc8b1136 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Minimalist Window.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Examples/Windows/Minimalist Window.prefab -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Minimalist Window.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 039a4f40162bed6418688efc345e8ad1 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f5a39896f982ec4f8449fda9a1a6ce1 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Scripts/ConsoleVisualiser.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | using UnityEngine.Events; 6 | public class ConsoleVisualiser : MonoBehaviour 7 | { 8 | [SerializeField] private Transform textParent = null; 9 | [SerializeField] private int textSize = 20; 10 | [SerializeField] private int maxMessages = 10; 11 | 12 | public UnityEvent onMessageRecieved; 13 | 14 | private Font messageFont; 15 | private int currentNumMessages; 16 | 17 | static readonly Dictionary logTypeColors = new Dictionary() { 18 | { LogType.Assert, Color.white }, 19 | { LogType.Error, Color.red }, 20 | { LogType.Exception, Color.red }, 21 | { LogType.Log, Color.white }, 22 | { LogType.Warning, Color.yellow }, 23 | }; 24 | 25 | void Awake() { 26 | messageFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; 27 | } 28 | 29 | void OnEnable () { 30 | #if UNITY_5_3_OR_NEWER 31 | Application.logMessageReceived += HandleLog; 32 | #else 33 | Application.RegisterLogCallback(HandleLog); 34 | #endif 35 | } 36 | 37 | void OnDisable () { 38 | #if UNITY_5_3_OR_NEWER 39 | Application.logMessageReceived -= HandleLog; 40 | #else 41 | Application.RegisterLogCallback(null); 42 | #endif 43 | } 44 | 45 | void HandleLog (string message, string stackTrace, LogType type) { 46 | StartCoroutine(SendMessageToText(message, type)); 47 | } 48 | 49 | private IEnumerator SendMessageToText(string message, LogType type) { 50 | yield return new WaitForEndOfFrame(); 51 | 52 | GameObject go = new GameObject(message); 53 | go.transform.SetParent(textParent); 54 | go.transform.SetSiblingIndex(0); 55 | go.transform.localScale = Vector3.one; 56 | 57 | Text txt = go.AddComponent(); 58 | txt.color = logTypeColors[type]; 59 | txt.text = message; 60 | txt.font = messageFont; 61 | txt.fontSize = textSize; 62 | 63 | RectTransform rt = (RectTransform)go.transform; 64 | Vector2 size = rt.sizeDelta; 65 | size.y = textSize; 66 | rt.sizeDelta = size; 67 | 68 | currentNumMessages++; 69 | if (currentNumMessages > maxMessages) { 70 | Destroy(textParent.GetChild(textParent.childCount-1).gameObject); 71 | currentNumMessages--; 72 | } 73 | 74 | onMessageRecieved.Invoke (); 75 | 76 | yield return null; 77 | } 78 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Scripts/ConsoleVisualiser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50205579a744e624b89d236cb0b569e8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Touch Window.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Examples/Windows/Touch Window.prefab -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Touch Window.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 111310e075e576b46a5cbab167bf91c6 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Windows 10 Notepad Theme.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Examples/Windows/Windows 10 Notepad Theme.prefab -------------------------------------------------------------------------------- /Assets/GUIWindows/Examples/Windows/Windows 10 Notepad Theme.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09cf65e4c7968f7448c823d7ae162dfd 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a04cf1cd7d21f9d4fa8a64a89c687327 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Resources/WindowUIComponent.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/Assets/GUIWindows/Resources/WindowUIComponent.prefab -------------------------------------------------------------------------------- /Assets/GUIWindows/Resources/WindowUIComponent.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e35aeb23d52d724cb7fe53502b35ed6 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 911f937900b45f446bcdfbe1bdd27bd0 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4052862acd23cd644afbdebcc6dd5769 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/Editor/GUIPointerObjectEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEditor; 4 | 5 | namespace Rellac.Windows 6 | { 7 | [CustomEditor(typeof(GUIPointerObject))] 8 | [CanEditMultipleObjects] 9 | public class GUIPointerObjectEditor : Editor 10 | { 11 | 12 | SerializedProperty onPointerUp; 13 | SerializedProperty onPointerDown; 14 | SerializedProperty onPointerEnter; 15 | SerializedProperty onPointerExit; 16 | 17 | void OnEnable() 18 | { 19 | onPointerUp = serializedObject.FindProperty("onPointerUp"); 20 | onPointerDown = serializedObject.FindProperty("onPointerDown"); 21 | onPointerEnter = serializedObject.FindProperty("onPointerEnter"); 22 | onPointerExit = serializedObject.FindProperty("onPointerExit"); 23 | } 24 | 25 | public override void OnInspectorGUI() 26 | { 27 | serializedObject.Update(); 28 | EditorGUILayout.PropertyField(onPointerUp); 29 | EditorGUILayout.PropertyField(onPointerDown); 30 | EditorGUILayout.PropertyField(onPointerEnter); 31 | EditorGUILayout.PropertyField(onPointerExit); 32 | serializedObject.ApplyModifiedProperties(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/Editor/GUIPointerObjectEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e208f13f49d1a4c42b716cbde5c0ba97 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIBorderParent.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Rellac.Windows 4 | { 5 | /// 6 | /// Contains a reference to all GUIWindowHandle objects below this Transform for ease of referencing 7 | /// 8 | public class GUIBorderParent : MonoBehaviour 9 | { 10 | private GUIWindowHandle[] handles; 11 | // Use this for initialization 12 | void Start() 13 | { 14 | handles = GetComponentsInChildren(); 15 | } 16 | 17 | /// 18 | /// Toggle interactivity of handles 19 | /// 20 | /// is interactive 21 | public void SetIsLocked(bool input) 22 | { 23 | for (int i = 0; i < handles.Length; i++) 24 | { 25 | handles[i].SetIsLocked(input); 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIBorderParent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7522e6e31c695a24eab781c580d37a59 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIPointerObject.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | using UnityEngine.EventSystems; 4 | 5 | namespace Rellac.Windows 6 | { 7 | /// 8 | /// Contains events referencing IPointerHandlers 9 | /// 10 | public class GUIPointerObject : MonoBehaviour, IPointerUpHandler, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler 11 | { 12 | /// 13 | /// Fires when a pointer up is detected 14 | /// 15 | [HideInInspector] 16 | [Tooltip("Fires when a pointer up is detected")] 17 | public UnityEvent onPointerUp = null; 18 | /// 19 | /// Fires when a pointer down is detected 20 | /// 21 | [HideInInspector] 22 | [Tooltip("Fires when a pointer down is detected")] 23 | public UnityEvent onPointerDown = null; 24 | /// 25 | /// Fires when a pointer enter is detected 26 | /// 27 | [HideInInspector] 28 | [Tooltip("Fires when a pointer enter is detected")] 29 | public UnityEvent onPointerEnter = null; 30 | /// 31 | /// Fires when a pointer exit is detected 32 | /// 33 | [HideInInspector] 34 | [Tooltip("Fires when a pointer exit is detected")] 35 | public UnityEvent onPointerExit = null; 36 | 37 | public void OnPointerUp(PointerEventData eventData) 38 | { 39 | if (onPointerUp != null) 40 | { 41 | onPointerUp.Invoke(); 42 | } 43 | } 44 | public void OnPointerDown(PointerEventData eventData) 45 | { 46 | if (onPointerDown != null) 47 | { 48 | onPointerDown.Invoke(); 49 | } 50 | } 51 | public void OnPointerEnter(PointerEventData eventData) 52 | { 53 | if (onPointerEnter != null) 54 | { 55 | onPointerEnter.Invoke(); 56 | } 57 | } 58 | public void OnPointerExit(PointerEventData eventData) 59 | { 60 | if (onPointerExit != null) 61 | { 62 | onPointerExit.Invoke(); 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIPointerObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4817080b0d03dd846b5ee72dfd97c993 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Rellac.Windows 4 | { 5 | /// 6 | /// Simple script to destroy the target GameObject when window is closed 7 | /// 8 | public class GUIWindow : MonoBehaviour 9 | { 10 | /// 11 | /// Close window by destroying this GameObject 12 | /// 13 | public void CloseWindow() 14 | { 15 | Destroy(gameObject); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53f10846845fcf9489fc69eccfbd24c9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowExpander.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | 4 | namespace Rellac.Windows 5 | { 6 | /// 7 | /// Script to handle expanding and restoring a window to/from screen size 8 | /// 9 | public class GUIWindowExpander : GUIPointerObject 10 | { 11 | 12 | private const float MaxTimeForDoubleClick = 0.5f; 13 | /// 14 | /// Window to apply expand effect to 15 | /// 16 | [Tooltip("")] 17 | [SerializeField] private RectTransform parentWindow = null; 18 | /// 19 | /// Expander is locked and unusable 20 | /// 21 | [Tooltip("")] 22 | [SerializeField] private bool isLocked = false; 23 | /// 24 | /// Allows you to double click this target image to minimise/maximise 25 | /// 26 | [Tooltip("Allows you to double click this target image to minimise/maximise")] 27 | [SerializeField] private bool doubleClick = true; 28 | /// 29 | /// Fires when window starts restoring to a smaller size 30 | /// 31 | public UnityEvent onMinimised = null; 32 | /// 33 | /// Fires when window starts expanding 34 | /// 35 | public UnityEvent onMaximised = null; 36 | 37 | private bool isMaximised = false; 38 | private bool doAction = false; 39 | 40 | private Vector2 initialPosition; 41 | private Vector2 initialMinAnchor; 42 | private Vector2 initialMaxAnchor; 43 | private Vector2 initialSize; 44 | private Vector2 initialPivot = Vector2.one * -1; 45 | 46 | private Vector2 targetPosition; 47 | private Vector2 targetSize; 48 | 49 | private int numClicks; 50 | 51 | void Start() 52 | { 53 | onPointerDown.AddListener(parentWindow.SetAsLastSibling); 54 | onPointerDown.AddListener(TryDoubleClick); 55 | } 56 | 57 | // Update is called once per frame 58 | void Update() 59 | { 60 | if (doAction) 61 | { 62 | // Lerp to position & size 63 | parentWindow.sizeDelta = Vector2.MoveTowards(parentWindow.sizeDelta, targetSize, Time.deltaTime * 10000); 64 | parentWindow.anchoredPosition = Vector2.MoveTowards(parentWindow.anchoredPosition, targetPosition, Time.deltaTime * 5000); 65 | // reached target 66 | if (parentWindow.sizeDelta == targetSize && parentWindow.anchoredPosition == targetPosition) 67 | { 68 | doAction = false; 69 | if (isMaximised) 70 | { // set to a full stretched rect 71 | parentWindow.anchorMin = Vector2.zero; 72 | parentWindow.anchorMax = Vector2.one; 73 | parentWindow.sizeDelta = Vector2.zero; 74 | parentWindow.anchoredPosition = Vector2.zero; 75 | if (onMaximised != null) 76 | { 77 | onMaximised.Invoke(); 78 | } 79 | } 80 | else 81 | { // just invoke the event for a minimised window 82 | if (onMinimised != null) 83 | { 84 | onMinimised.Invoke(); 85 | } 86 | } 87 | } 88 | } 89 | } 90 | 91 | /// 92 | /// Toggle interactivity of expander 93 | /// 94 | /// is interactive 95 | public void SetIsLocked(bool input) 96 | { 97 | isLocked = input; 98 | parentWindow.SetAsLastSibling(); 99 | } 100 | 101 | /// 102 | /// Set window to fill screen 103 | /// 104 | public void MaximiseWindow() 105 | { 106 | if (isLocked) return; 107 | 108 | initialPosition = parentWindow.anchoredPosition; 109 | initialMinAnchor = parentWindow.anchorMin; 110 | initialMaxAnchor = parentWindow.anchorMax; 111 | initialSize = parentWindow.sizeDelta; 112 | initialPivot = parentWindow.pivot; 113 | 114 | parentWindow.SetPivot(Vector2.one * 0.5f); 115 | 116 | targetPosition = Vector2.zero; 117 | targetSize = new Vector2(Screen.width, Screen.height); 118 | 119 | isMaximised = true; 120 | doAction = true; 121 | parentWindow.SetAsLastSibling(); 122 | } 123 | 124 | /// 125 | /// Set window to small size 126 | /// 127 | public void MinimiseWindow() 128 | { 129 | if (isLocked) return; 130 | parentWindow.anchorMin = initialMinAnchor; 131 | parentWindow.anchorMax = initialMaxAnchor; 132 | 133 | parentWindow.sizeDelta = new Vector2(Screen.width, Screen.height); 134 | 135 | if (initialPivot != Vector2.one * -1) 136 | { 137 | parentWindow.SetPivot(initialPivot); 138 | } 139 | 140 | targetPosition = initialPosition; 141 | targetSize = initialSize; 142 | 143 | isMaximised = false; 144 | doAction = true; 145 | parentWindow.SetAsLastSibling(); 146 | } 147 | 148 | /// 149 | /// Do a click for attempting to expand by double click 150 | /// 151 | public void TryDoubleClick() 152 | { 153 | parentWindow.SetAsLastSibling(); 154 | if (isLocked || !doubleClick) return; 155 | numClicks++; 156 | if (numClicks == 1) 157 | { 158 | Invoke("ResetDoubleClick", MaxTimeForDoubleClick); 159 | } 160 | else if (numClicks >= 2) 161 | { 162 | Invoke("Swap", 0.1f); // wait in case we're interrupting a mover 163 | } 164 | } 165 | 166 | /// 167 | /// Swap between minimised and maximised 168 | /// 169 | public void Swap() 170 | { 171 | if (isMaximised) 172 | { 173 | MinimiseWindow(); 174 | } 175 | else 176 | { 177 | MaximiseWindow(); 178 | } 179 | } 180 | 181 | private void ResetDoubleClick() 182 | { 183 | numClicks = 0; 184 | } 185 | } 186 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowExpander.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14001084fe201b84d9804ee3eafd2b7a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowHandle.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | 4 | namespace Rellac.Windows 5 | { 6 | /// 7 | /// Script to handle pull handles to expand the windows 8 | /// 9 | public class GUIWindowHandle : GUIPointerObject 10 | { 11 | /// 12 | /// Window to apply pull effect to 13 | /// 14 | [Tooltip("Window to apply pull effect to")] 15 | [SerializeField] private RectTransform parentWindow = null; 16 | /// 17 | /// Handle is locked and unusable 18 | /// 19 | [Tooltip("Handle is locked and unusable")] 20 | [SerializeField] private bool isLocked = false; 21 | /// 22 | /// Minimum width parent window can be set to 23 | /// 24 | [Tooltip("Minimum width parent window can be set to")] 25 | [SerializeField] private float minWidth = 50; 26 | /// 27 | /// Minimum height parent window can be set to 28 | /// 29 | [Tooltip("Minimum height parent window can be set to")] 30 | [SerializeField] private float minHeight = 50; 31 | /// 32 | /// Sprite to show for cursor when this handle is highlighted 33 | /// 34 | [Tooltip("Sprite to show for cursor when this handle is highlighted")] 35 | [SerializeField] private Texture2D cursor = null; 36 | /// 37 | /// Directional axis to pull window with this handle 38 | /// 39 | [Tooltip("Directional axis to pull window with this handle")] 40 | [SerializeField] private Axis axis = Axis.Horizontal; 41 | /// 42 | /// Fired when user pulls on the handle 43 | /// 44 | public UnityEvent onWindowPulled = null; 45 | 46 | Direction direction; 47 | private bool isGrabbed = false; 48 | 49 | 50 | private Vector2 initialMousePos; 51 | private Vector2 initialSize; 52 | private Vector2 initialPivot; 53 | 54 | void Start() 55 | { 56 | //register to pointer events 57 | onPointerDown.AddListener(SetIsGrabbed); 58 | onPointerDown.AddListener(parentWindow.SetAsLastSibling); 59 | onPointerEnter.AddListener(ShowCursor); 60 | onPointerExit.AddListener(ResetCursor); 61 | 62 | // find what direction we're pulling with this handle 63 | switch (axis) 64 | { 65 | 66 | case Axis.Horizontal: 67 | if (transform.position.x > parentWindow.position.x) 68 | { 69 | direction = Direction.Right; 70 | } 71 | else 72 | { 73 | direction = Direction.Left; 74 | } 75 | break; 76 | 77 | case Axis.Vertical: 78 | if (transform.position.y > parentWindow.position.y) 79 | { 80 | direction = Direction.Up; 81 | } 82 | else 83 | { 84 | direction = Direction.Down; 85 | } 86 | break; 87 | 88 | case Axis.Diagonal: 89 | if (transform.position.y > parentWindow.position.y) 90 | { 91 | if (transform.position.x > parentWindow.position.x) 92 | { 93 | direction = Direction.UpRight; 94 | } 95 | else 96 | { 97 | direction = Direction.UpLeft; 98 | } 99 | } 100 | else 101 | { 102 | if (transform.position.x > parentWindow.position.x) 103 | { 104 | direction = Direction.DownRight; 105 | } 106 | else 107 | { 108 | direction = Direction.DownLeft; 109 | } 110 | } 111 | break; 112 | } 113 | } 114 | 115 | void Update() 116 | { 117 | if (!isGrabbed) 118 | return; 119 | 120 | if (Input.GetMouseButtonUp(0)) 121 | { 122 | isGrabbed = false; 123 | parentWindow.SetPivot(initialPivot); 124 | if (onWindowPulled != null) 125 | { 126 | onWindowPulled.Invoke(); 127 | } 128 | return; 129 | } 130 | 131 | Vector2 scaleOffset = (Vector2.one - (Vector2)transform.lossyScale) + Vector2.one; 132 | Vector2 mouseDelta = Vector2.Scale((Vector2)Input.mousePosition - initialMousePos, scaleOffset); 133 | Vector2 size = initialSize; 134 | 135 | switch (direction) 136 | { 137 | case Direction.Up: 138 | size += new Vector2(0, mouseDelta.y); 139 | break; 140 | case Direction.Down: 141 | size -= new Vector2(0, mouseDelta.y); 142 | break; 143 | case Direction.Left: 144 | size -= new Vector2(mouseDelta.x, 0); 145 | break; 146 | case Direction.Right: 147 | size += new Vector2(mouseDelta.x, 0); 148 | break; 149 | case Direction.UpRight: 150 | size += new Vector2(mouseDelta.x, mouseDelta.y); 151 | break; 152 | case Direction.UpLeft: 153 | size += new Vector2(-mouseDelta.x, mouseDelta.y); 154 | break; 155 | case Direction.DownRight: 156 | size += new Vector2(mouseDelta.x, -mouseDelta.y); 157 | break; 158 | case Direction.DownLeft: 159 | size += new Vector2(-mouseDelta.x, -mouseDelta.y); 160 | break; 161 | } 162 | 163 | // Keep Window within minimum size 164 | if (size.x < minWidth || size.y < minHeight) 165 | { 166 | Vector2 newsize = size; 167 | if (size.x < minWidth) 168 | { 169 | newsize.x = minWidth; 170 | } 171 | if (size.y < minHeight) 172 | { 173 | newsize.y = minHeight; 174 | } 175 | parentWindow.sizeDelta = newsize; 176 | return; 177 | } 178 | 179 | // set position & size 180 | parentWindow.sizeDelta = size; 181 | } 182 | 183 | /// 184 | /// Toggle interactivity of handle 185 | /// 186 | /// is interactive 187 | public void SetIsLocked(bool input) 188 | { 189 | isLocked = input; 190 | parentWindow.SetAsLastSibling(); 191 | } 192 | 193 | /// 194 | /// Trigger that this handle has been grabbed 195 | /// 196 | public void SetIsGrabbed() 197 | { 198 | if (isLocked) return; 199 | isGrabbed = true; 200 | 201 | initialMousePos = Input.mousePosition; 202 | initialSize = parentWindow.sizeDelta; 203 | initialPivot = parentWindow.pivot; 204 | 205 | // Set Pivot to correct value based on direction so we don't need to offset movement 206 | switch (direction) 207 | { 208 | case Direction.Up: 209 | parentWindow.SetPivot(new Vector2(0.5f, 0)); 210 | break; 211 | case Direction.Down: 212 | parentWindow.SetPivot(new Vector2(0.5f, 1)); 213 | break; 214 | case Direction.Left: 215 | parentWindow.SetPivot(new Vector2(1, 0.5f)); 216 | break; 217 | case Direction.Right: 218 | parentWindow.SetPivot(new Vector2(0, 0.5f)); 219 | break; 220 | case Direction.UpRight: 221 | parentWindow.SetPivot(new Vector2(0, 0)); 222 | break; 223 | case Direction.UpLeft: 224 | parentWindow.SetPivot(new Vector2(1, 0)); 225 | break; 226 | case Direction.DownRight: 227 | parentWindow.SetPivot(new Vector2(0, 1)); 228 | break; 229 | case Direction.DownLeft: 230 | parentWindow.SetPivot(new Vector2(1, 1)); 231 | break; 232 | } 233 | parentWindow.SetAsLastSibling(); 234 | } 235 | 236 | /// 237 | /// Show the changed cursor when this handle is highlighted 238 | /// 239 | public void ShowCursor() 240 | { 241 | if (!isLocked && cursor != null) 242 | { 243 | Cursor.SetCursor(cursor, new Vector2(16, 16), CursorMode.Auto); 244 | } 245 | } 246 | 247 | /// 248 | /// Return the cursor to the default state 249 | /// 250 | public void ResetCursor() 251 | { 252 | if (cursor != null) 253 | { 254 | Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); 255 | } 256 | } 257 | 258 | private enum Axis 259 | { 260 | Horizontal, 261 | Vertical, 262 | Diagonal 263 | } 264 | 265 | private enum Direction 266 | { 267 | Up, 268 | Down, 269 | Left, 270 | Right, 271 | UpLeft, 272 | UpRight, 273 | DownLeft, 274 | DownRight 275 | } 276 | } 277 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff5cd5446e2fdea43a48057e3e0e0b8b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowMover.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | 4 | namespace Rellac.Windows 5 | { 6 | /// 7 | /// Script to handle moving windows 8 | /// 9 | public class GUIWindowMover : GUIPointerObject 10 | { 11 | /// 12 | /// Window to move 13 | /// 14 | [Tooltip("Window to move")] 15 | [SerializeField] private RectTransform parentWindow = null; 16 | /// 17 | /// Mover is locked and unusable 18 | /// 19 | [Tooltip("Mover is locked and unusable")] 20 | [SerializeField] private bool isLocked = false; 21 | /// 22 | /// Fires when a window has been moved 23 | /// 24 | [Tooltip("Fires when a window has been moved")] 25 | [SerializeField] private UnityEvent onWindowMoved = null; 26 | 27 | private Vector2 mouseOffset; 28 | private bool isGrabbed = false; 29 | 30 | void Start() 31 | { 32 | onPointerDown.AddListener(SetIsGrabbed); 33 | } 34 | 35 | void Update() 36 | { 37 | if (!isGrabbed || isLocked) return; 38 | 39 | parentWindow.position = (Vector2)Input.mousePosition + mouseOffset; 40 | if (Input.GetMouseButtonUp(0)) 41 | { 42 | isGrabbed = false; 43 | if (onWindowMoved != null) 44 | { 45 | onWindowMoved.Invoke(); 46 | } 47 | } 48 | } 49 | 50 | /// 51 | /// Toggle interactivity of handle 52 | /// 53 | /// is interactive 54 | public void SetIsLocked(bool input) 55 | { 56 | isLocked = input; 57 | isGrabbed = false; 58 | } 59 | 60 | /// 61 | /// Trigger that window has started to be moved 62 | /// 63 | public void SetIsGrabbed() 64 | { 65 | mouseOffset = parentWindow.position - Input.mousePosition; 66 | isGrabbed = true; 67 | parentWindow.SetAsLastSibling(); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowMover.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afc20c44b0e31b64193a5ccaa228b5f8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowUtils.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.EventSystems; 3 | using UnityEngine.UI; 4 | #if UNITY_EDITOR 5 | using UnityEditor; 6 | #endif 7 | namespace Rellac.Windows 8 | { 9 | public static class GUIWindowUtils 10 | { 11 | #if UNITY_EDITOR 12 | [MenuItem("GameObject/UI/Window")] 13 | public static void InstantiateWindow() 14 | { 15 | NewWindow(); 16 | } 17 | #endif 18 | 19 | public static GameObject NewWindow() 20 | { 21 | Object prefab = Resources.Load("WindowUIComponent"); 22 | Canvas canvas = GameObject.FindObjectOfType(); 23 | if (canvas == null) 24 | { 25 | // Create default canvas 26 | GameObject newCanvas = new GameObject("Canvas"); 27 | canvas = newCanvas.AddComponent(); 28 | canvas.renderMode = RenderMode.ScreenSpaceOverlay; 29 | newCanvas.AddComponent(); 30 | newCanvas.AddComponent(); 31 | if (GameObject.FindObjectOfType() == null) 32 | { 33 | // Create defalut EventSystem 34 | new GameObject("EventSystem").AddComponent(). // create new GameObject with EventSystem 35 | gameObject.AddComponent() // add Input Module 36 | #if UNITY_5_3_OR_NEWER 37 | ; // we don't need the Touch Input Module at 5.3+ 38 | #else 39 | .gameObject.AddComponent(); 40 | #endif 41 | } 42 | } 43 | GameObject go = (GameObject)GameObject.Instantiate(prefab); 44 | go.transform.SetParent(canvas.transform); 45 | go.transform.localPosition = Vector2.zero; 46 | go.name = "Window"; 47 | return go; 48 | } 49 | 50 | public static void SetPivot(this RectTransform rectTransform, Vector2 pivot) 51 | { 52 | if (rectTransform == null) return; 53 | 54 | Vector2 size = rectTransform.rect.size; 55 | Vector2 deltaPivot = rectTransform.pivot - pivot; 56 | Vector3 deltaPosition = new Vector3(deltaPivot.x * size.x, deltaPivot.y * size.y); 57 | rectTransform.pivot = pivot; 58 | rectTransform.localPosition -= deltaPosition; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Assets/GUIWindows/Scripts/GUIWindowUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f1db78fc458ea44ebcab0c6ce456cfe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unity-gui-windows 2 | Draggable and scalable modular Canvas based GUI windows 3 | 4 | ![](gif_demo.gif) 5 | 6 | To quickly create a window from hierarchy panel: Create > UI > Window 7 | 8 | Draggable GUI Windows has been designed in a very modular way with ease of access for modifying both form and function. 9 | 10 | We achieve this with 5 scripts: 11 | 12 | GUIWindowUtils.cs: 13 | ------------------ 14 | This is a static class used for referencing mechanics outside of basic function. From here we have two functions: 15 | 16 | GUIWindowUtils.InstantiateWindow() : This is the Create Menu hook to allow us to generate quickly 17 | GUIWindowUtils.NewWindow() : This will create a new window, trying to find a Canvas - can be called at runtime or from editor - previous function calls this 18 | 19 | 20 | GUIWindow.cs: 21 | ------------- 22 | This class exists simply to close a window. The nly function is CloseWindow() which called a Destroy() 23 | 24 | GUIWindowExpander.cs: 25 | --------------------- 26 | This is the class that we use to handle maximising the window. There are three public functions that you may want to reference here: 27 | 28 | SetIsLocked() : Make it so we can't use the expander at all 29 | MaximiseWindow() : Expand window to full size of canvas 30 | Minimisewindow() : Shrink window own to original size before expanding 31 | 32 | This script needs to reference a RectTransform to enact the expand on 33 | This script can be double clicked to invoke when "doubleClick" is set to true 34 | 35 | There are two events you can use to avoid making direct script changes: 36 | 37 | OnMinimised : Called once minimise has been finished 38 | OnMaximised : Called once maximise has been finished 39 | 40 | 41 | GUIWindowHandle.cs: 42 | ------------------- 43 | This is the class we use to be able to drag the windows around form the edges. Each window generally has 8 of these for; top, bottom, left, right, top-right, top-left, bottom-right, bottom-left 44 | You can assign a cursor here to display whenever this handle is hovered over. You will need to define if this is a horizontal, vertical or diagonal handle and calculations will be done from there based on positions 45 | 46 | There one public function for reference here: 47 | 48 | SetIsLocked() : Make it so we can't use this handle at all 49 | 50 | There is one event you can use to avoid making direct script changes: 51 | 52 | OnWindowPulled : Called once pointer is up after dragging handle about 53 | 54 | 55 | GUIWindowMover.cs: 56 | ------------------ 57 | This is the class that handles moving a window across the screen without any size changes. This script is relatively simple in function and has one public function for reference: 58 | 59 | SetIsLocked() : Make it so we can't use this mover at all 60 | 61 | There is one event you can use to avoid making direct script changes: 62 | 63 | OnWindowMoved : Called once pointer is up after moving window about 64 | 65 | GUIPointerObject.cs: 66 | -------------------- 67 | This class handles all pointer functions and can be extended for use in any other GUI script. 68 | 69 | There are four events you can use to avoid making direct script change: 70 | 71 | OnPointerUp : Called once mouse is over target and button is up 72 | OnPointerDown : Called once mouse is over target and button is down 73 | OnPointerEnter : Called when pointer intersects target 74 | OnPointerExit : Called when pointer leaves target 75 | 76 | This script will require a UI component on the same object (Image, Text, etc) to raycast against 77 | 78 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 79 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 80 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 81 | 82 | The windows are designed in such a way that the majority of the functionality is implemented via the buttons found in the UI menu rather than via script. Buttons call most events. 83 | 84 | Each Example window contains the following buttons: 85 | 86 | Close: Destroy the Window 87 | Min/Maximise: Toggle full screen 88 | Lock: Stop interaction with all window deformations to lock it in place 89 | 90 | These buttons can be deleted if you don't want this content, along with the MenuBar and any other script you don't feel your project needs. You can keep these windows as simple as you like. 91 | 92 | Mono scripts will all use various Pointer events to detect mouse inputs because buttons are "Mouse Down and Mouse Up", which isn't always ideal. 93 | 94 | Enjoy! (: 95 | -------------------------------------------------------------------------------- /gif_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellac-Rellac/unity-gui-windows/98c6783edb1bb4b2413b73785d0b44f050dfa07d/gif_demo.gif --------------------------------------------------------------------------------