protected override void UI(int id)
        {
            GUILayout.BeginVertical();

            GUILayoutExtensions.LabelWithSpace("Device Type: " + SI.deviceType, -8);
            GUILayoutExtensions.LabelWithSpace("Operation System: " + SI.operatingSystem, -8);
            GUILayoutExtensions.LabelWithSpace("Unity Version: " + SI.unityVersion, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Device: " + SI.graphicsDeviceName, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Device API: " + SI.graphicsDeviceVersion, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Device ID: " + SI.graphicsDeviceID, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Memory Size: " + SI.graphicsMemorySize, -8);
            GUILayoutExtensions.LabelWithSpace("Supported Shader Level: " + SI.graphicsShaderLevel, -8);

            GUILayoutExtensions.LabelWithSpace("CPU: " + SI.processorType, -8);
            GUILayoutExtensions.LabelWithSpace("CPU Cores Count (Threads Count): " + SI.processorCount, -8);
            GUILayoutExtensions.LabelWithSpace("CPU Current Frequency: " + SI.processorFrequency + "Hz", -8);

            GUILayoutExtensions.LabelWithSpace("RAM: " + SI.systemMemorySize, -8);

            GUILayoutExtensions.LabelWithSpace("Maximum Texture Size: " + SI.maxTextureSize, -8);
            GUILayoutExtensions.LabelWithSpace("Non-Power-Of-Two Texture Support: " + SI.npotSupport, -8);

            GUILayoutExtensions.LabelWithSpace("ComputeShaders: " + SI.supportsComputeShaders, -8);
            GUILayoutExtensions.LabelWithSpace("RenderTextures: " + true, -8);
            GUILayoutExtensions.LabelWithSpace("3DTextures: " + SI.supports3DTextures, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Multithreading: " + SI.graphicsMultiThreaded, -8);
            GUILayoutExtensions.LabelWithSpace("ARGB4444: " + SI.supportsARGB4444TextureFormat, -8);
            GUILayoutExtensions.LabelWithSpace("ARGB32: " + SI.supportsARGB32TextureFormat, -8);
            GUILayoutExtensions.LabelWithSpace("Depth Textures: " + SI.supportsDepthRenderTextureFormat, -8);

            GUILayout.EndVertical();
        }
Beispiel #2
0
        protected override void UI(int id)
        {
            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            GUILayoutExtensions.VerticalBoxed("Input info: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    DrawLabelLines(InputInfo);
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            GUILayoutExtensions.VerticalBoxed("Additional info: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    DrawLabelLines(InfoAdditional);
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            GUILayout.EndScrollView();
        }
Beispiel #3
0
        protected void DrawStorageInfo <T>(string prefix = "Storage") where T : TileStorage
        {
            var body = GodManager.Instance.ActiveBody;

            if (body == null)
            {
                GUILayoutExtensions.DrawBadHolder(prefix, "No Body!?", GUISkin); return;
            }
            if (body.Storages == null)
            {
                GUILayoutExtensions.DrawBadHolder(prefix, "No Storages!?", GUISkin); return;
            }

            var tileStorages = body.Storages.Where(storage => storage is T).ToList();

            GUILayoutExtensions.VerticalBoxed(prefix, GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    if (tileStorages.Count == 0)
                    {
                        GUILayoutExtensions.LabelWithSpace(string.Format("Active body doesn't have any storages of provided type {0}", typeof(T).Name));
                    }
                    else
                    {
                        GUILayoutExtensions.LabelWithSpace(string.Format("{0} Count: {1}", prefix, tileStorages.Count));
                        GUILayoutExtensions.LabelWithSpace(string.Format("{0} Total Capacity: {1}", prefix, tileStorages.Sum((storage) => storage.Capacity)));
                        GUILayoutExtensions.LabelWithSpace(string.Format("{0} Total Free: {1}", prefix, tileStorages.Sum((storage) => storage.FreeSlotsCount)));
                    }

                    GUILayoutExtensions.SpacingSeparator();
                }, GUILayout.Width(debugInfoBounds.width - 45));
            }, GUILayout.Width(debugInfoBounds.width - 40));
        }
Beispiel #4
0
        protected void DrawStorageInfo <T>(string prefix = "Storage") where T : TileStorage
        {
            GUILayout.BeginVertical(prefix, GUISkin.box, GUILayout.Width(debugInfoBounds.width - 40));
            {
                var storages = GodManager.Instance.ActiveBody.transform.GetComponentsInChildren <T>().ToList();

                GUILayout.Space(20);

                GUILayout.BeginVertical("", GUISkin.box, GUILayout.Width(debugInfoBounds.width - 45));
                {
                    if (storages.Count == 0)
                    {
                        GUILayoutExtensions.LabelWithSpace(string.Format("Active body doesn't have any storages of provided type {0}", typeof(T).Name));
                    }
                    else
                    {
                        GUILayoutExtensions.LabelWithSpace(string.Format("{0} Count: {1}", prefix, storages.Count));
                        GUILayoutExtensions.LabelWithSpace(string.Format("{0} Total Capacity: {1}", prefix, storages.Sum((storage) => storage.Capacity)));
                        GUILayoutExtensions.LabelWithSpace(string.Format("{0} Total Free: {1}", prefix, storages.Sum((storage) => storage.FreeSlotsCount)));
                    }

                    GUILayout.Space(5);
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
        }
Beispiel #5
0
        protected override void UI(int id)
        {
            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            GUILayoutExtensions.VerticalBoxed("Rendering parameters: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    GUILayoutExtensions.VerticalBoxed("Fragment HDR Mode: ", GUISkin, () =>
                    {
                        GodManager.Instance.HDRMode = (FragmentHDR)GUILayout.SelectionGrid((int)GodManager.Instance.HDRMode, System.Enum.GetNames(typeof(FragmentHDR)), 2);
                    });

                    GUILayoutExtensions.SpacingSeparator();

                    GUILayoutExtensions.VerticalBoxed("Features: ", GUISkin, () =>
                    {
                        GodManager.Instance.Eclipses            = GUILayout.Toggle(GodManager.Instance.Eclipses, " - Eclipses?");
                        GodManager.Instance.Planetshadows       = GUILayout.Toggle(GodManager.Instance.Planetshadows, " - Planetshadows?");
                        GodManager.Instance.Planetshine         = GUILayout.Toggle(GodManager.Instance.Planetshine, " - Planetshine?");
                        GodManager.Instance.OceanSkyReflections = GUILayout.Toggle(GodManager.Instance.OceanSkyReflections, " - Ocean Sky Reflections?");
                    });
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            GUILayout.EndScrollView();
        }
Beispiel #6
0
        protected override void UI(int id)
        {
            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            if (Body != null && Helper.Enabled(Body))
            {
                GUILayoutExtensions.VerticalBoxed("Body parameters: ", GUISkin, () =>
                {
                    GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                    {
                        if (Body.TCCPS != null)
                        {
                            var materialTable = Body.TCCPS.MaterialTable;

                            if (materialTable != null && materialTable.Lut != null)
                            {
                                GUILayout.Label("Material Table: ");
                                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                                {
                                    GUILayoutExtensions.Horizontal(() =>
                                    {
                                        GUILayout.Label(materialTable.Lut);
                                    });
                                });
                            }
                        }
                    });
                });

                GUILayoutExtensions.SpacingSeparator();

                if (Body.Ocean != null && Body.OceanEnabled && Helper.Enabled(Body.Ocean))
                {
                    GUILayoutExtensions.VerticalBoxed("Ocean parameters: ", GUISkin, () =>
                    {
                        GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                        {
                            GUILayoutExtensions.SliderWithField("Level: ", 0.0f, 5.0f, ref Body.Ocean.OceanLevel);
                            GUILayoutExtensions.SliderWithField("Z Min: ", 0.0f, 50000.0f, ref Body.Ocean.ZMin);
                        });
                    });

                    GUILayoutExtensions.SpacingSeparator();
                }
                else
                {
                    GUILayoutExtensions.DrawBadHolder("Ocean parameters: ", "No Ocean!?", GUISkin);
                }
            }
            else
            {
                GUILayoutExtensions.DrawBadHolder("Body parameters: ", "No Body!?", GUISkin);
            }

            GUILayout.EndScrollView();
        }
Beispiel #7
0
 private void OnGUI()
 {
     if (ShowAdditionalInfo && !AtLeastOneEnabled)
     {
         GUILayoutExtensions.Vertical(() =>
         {
             GUILayoutExtensions.LabelWithSpace(string.Format("Press {0} key to switch between debug GUI's...", SwitchKey.ToString()));
         });
     }
 }
Beispiel #8
0
 private void DrawLabelLines(string[] lines)
 {
     GUILayoutExtensions.Vertical(() =>
     {
         for (byte i = 0; i < lines.Length; i++)
         {
             GUILayoutExtensions.LabelWithSpace(lines[i]);
         }
     });
 }
 protected override void UI(int id)
 {
     GUILayoutExtensions.VerticalBoxed("Actions: ", GUISkin, () =>
     {
         if (GUILayout.Button("Quit"))
         {
             Quit();
         }
     });
 }
Beispiel #10
0
        private void DrawLabelLines(params string[] lines)
        {
            GUILayoutExtensions.Vertical(() =>
            {
                for (var i = 0; i < lines.Length; i++)
                {
                    GUILayoutExtensions.LabelWithSpace(lines[i]);
                }
            });

            GUILayout.Space(8);
        }
Beispiel #11
0
        protected override void UI(int id)
        {
            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true, GUILayout.Width(debugInfoBounds.width), GUILayout.Height(debugInfoBounds.height));
            {
                #region Do Magic

                if (Objects == null)
                {
                    return;
                }

                var dictionary = new Dictionary <Type, int>();

                for (var i = 0; i < Objects.Length; i++)
                {
                    var obj = Objects[i];
                    var key = obj.GetType();

                    if (dictionary.ContainsKey(key))
                    {
                        dictionary[key]++;
                    }
                    else
                    {
                        dictionary[key] = 1;
                    }
                }

                #endregion

                var entryies = new List <KeyValuePair <Type, int> >(dictionary);

                entryies.Sort((firstPair, nextPair) => nextPair.Value.CompareTo((firstPair.Value)));

                GUILayout.BeginVertical();

                for (int i = 0; i < entryies.Count; i++)
                {
                    var entry = entryies[i];

                    GUILayoutExtensions.HorizontalBoxed("", GUISkin, () =>
                    {
                        GUILayoutExtensions.LabelWithFlexibleSpace(entry.Key.FullName, entry.Value.ToString());
                    });
                }

                GUILayout.Space(10);

                GUILayout.EndVertical();
            }

            GUILayout.EndScrollView();
        }
Beispiel #12
0
    private void OnGUI()
    {
        if (chunk == null)
        {
            return;
        }

        GUILayoutExtensions.Vertical(() =>
        {
            GUILayoutExtensions.LabelWithSpace(string.Format("Blocks count: {0}", 0));
        });
    }
Beispiel #13
0
        void InitUI()
        {
            // Layout extensions
            GUILayoutExtensions.Init(gameObject);

            // Disconnect client dialog
            clientDisconnectDialog = gameObject.AddComponent <ClientDisconnectDialog> ();

            // Info window
            infoWindow          = gameObject.AddComponent <InfoWindow> ();
            infoWindow.Closable = true;
            infoWindow.Visible  = config.InfoWindowVisible;
            infoWindow.Position = config.InfoWindowPosition;

            // Main window
            mainWindow          = gameObject.AddComponent <MainWindow> ();
            mainWindow.Config   = config;
            mainWindow.Server   = server;
            mainWindow.Visible  = config.MainWindowVisible;
            mainWindow.Position = config.MainWindowPosition;
            mainWindow.ClientDisconnectDialog = clientDisconnectDialog;
            mainWindow.InfoWindow             = infoWindow;

            // New connection dialog
            clientConnectingDialog = gameObject.AddComponent <ClientConnectingDialog> ();

            // Set up events
            InitEvents();

            // Add button to the applauncher
            mainWindow.Closable = true;
            textureOnline       = GameDatabase.Instance.GetTexture("kRPC/icons/applauncher-online", false);
            textureOffline      = GameDatabase.Instance.GetTexture("kRPC/icons/applauncher-offline", false);
            GameEvents.onGUIApplicationLauncherReady.Add(OnGUIApplicationLauncherReady);
            GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGUIApplicationLauncherDestroyed);
            server.OnStarted += (s, e) => {
                if (applauncherButton != null)
                {
                    applauncherButton.SetTexture(textureOnline);
                }
            };
            server.OnStopped += (s, e) => {
                if (applauncherButton != null)
                {
                    applauncherButton.SetTexture(textureOffline);
                }
            };
        }
Beispiel #14
0
 /// <summary>
 /// Destroy the UI.
 /// </summary>
 public void OnDestroy()
 {
     if (!ServicesChecker.OK)
     {
         return;
     }
     if (applauncherButton != null)
     {
         OnGUIApplicationLauncherDestroyed();
     }
     GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIApplicationLauncherReady);
     GameEvents.onGUIApplicationLauncherDestroyed.Remove(OnGUIApplicationLauncherDestroyed);
     Object.Destroy(mainWindow);
     Object.Destroy(clientConnectingDialog);
     GUILayoutExtensions.Destroy(gameObject);
 }
Beispiel #15
0
        private void UI(int id)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Width(debugInfoBounds.width), GUILayout.Height(debugInfoBounds.height));
            {
                #region Do Magic

                var objects    = FindObjectsOfType(typeof(Object));
                var dictionary = new Dictionary <string, int>();

                foreach (var obj in objects)
                {
                    string key = obj.GetType().FullName;

                    if (dictionary.ContainsKey(key))
                    {
                        dictionary[key]++;
                    }
                    else
                    {
                        dictionary[key] = 1;
                    }
                }

                #endregion

                var entryies = new List <KeyValuePair <string, int> >(dictionary);

                entryies.Sort((firstPair, nextPair) => nextPair.Value.CompareTo((firstPair.Value)));

                GUILayout.BeginVertical();

                for (int i = 0; i < entryies.Count; i++)
                {
                    var entry = entryies[i];

                    GUILayout.BeginHorizontal("box");
                    GUILayoutExtensions.LabelWithFlexibleSpace(entry.Key, entry.Value.ToString());
                    GUILayout.EndHorizontal();
                }

                GUILayout.Space(10);

                GUILayout.EndVertical();
            }

            GUILayout.EndScrollView();
        }
        protected override void UI(int id)
        {
            if (GUILayout.Button("Update"))
            {
                HardwareInfo.Get();
            }

            GUILayout.Space(5);

            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            GUILayout.BeginVertical();

            GUILayoutExtensions.LabelWithSpace("Device Type: " + HardwareInfo.deviceType, -8);
            GUILayoutExtensions.LabelWithSpace("Operation System: " + HardwareInfo.operatingSystem, -8);
            GUILayoutExtensions.LabelWithSpace("Unity Version: " + HardwareInfo.unityVersion, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Device: " + HardwareInfo.graphicsDeviceName, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Device API: " + HardwareInfo.graphicsDeviceVersion, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Device ID: " + HardwareInfo.graphicsDeviceID, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Memory Size: " + HardwareInfo.graphicsMemorySize, -8);
            GUILayoutExtensions.LabelWithSpace("Supported Shader Level: " + HardwareInfo.graphicsShaderLevel, -8);

            GUILayoutExtensions.LabelWithSpace("CPU: " + HardwareInfo.processorType, -8);
            GUILayoutExtensions.LabelWithSpace("CPU Cores Count (Threads Count): " + HardwareInfo.processorCount, -8);
            GUILayoutExtensions.LabelWithSpace("CPU Current Frequency: " + HardwareInfo.processorFrequency + "Hz", -8);

            GUILayoutExtensions.LabelWithSpace("RAM: " + HardwareInfo.systemMemorySize, -8);

            GUILayoutExtensions.LabelWithSpace("Maximum Texture Size: " + HardwareInfo.maxTextureSize, -8);
            GUILayoutExtensions.LabelWithSpace("Non-Power-Of-Two Texture Support: " + HardwareInfo.npotSupport, -8);

            GUILayoutExtensions.LabelWithSpace("ComputeShaders: " + HardwareInfo.supportsComputeShaders, -8);
            GUILayoutExtensions.LabelWithSpace("RenderTextures: " + true, -8);
            GUILayoutExtensions.LabelWithSpace("3DTextures: " + HardwareInfo.supports3DTextures, -8);
            GUILayoutExtensions.LabelWithSpace("Graphics Multithreading: " + HardwareInfo.graphicsMultiThreaded, -8);

            DrawSupportedFormats <RenderTextureFormat>(HardwareInfo.RenderTextureFormats, "RenderTexture");
            DrawSupportedFormats <TextureFormat>(HardwareInfo.TextureFormats, "Texture");

            GUILayout.Space(10);

            GUILayout.EndVertical();

            GUILayout.EndScrollView();
        }
        private void UI(int id)
        {
            var counters = PerformanceMonitor.Counters;

            debugInfoBounds.width = Screen.width - 20;

            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);
            {
                GUILayout.BeginVertical();

                for (int i = 0; i < counters.Count; i++)
                {
                    var counter = counters[i];

                    GUILayout.BeginVertical(string.Format("{0}", counter.Name), skin.box, GUILayout.Width(debugInfoBounds.width - 40));
                    {
                        GUILayout.Space(20);

                        if (true)
                        {
                            GUILayout.BeginVertical("", skin.box, GUILayout.Width(debugInfoBounds.width - 45));
                            {
                                GUILayout.BeginHorizontal();
                                GUILayoutExtensions.LabelWithSpace(string.Format("Total: {0}", counter.Time / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Average: {0}", counter.Average / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Last: {0}", counter.Last / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Max: {0}", counter.Max / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Count: {0}", counter.Count), -8);
                                GUILayout.EndHorizontal();
                            }
                            GUILayout.EndVertical();
                        }
                    }
                    GUILayout.EndVertical();
                }

                GUILayout.Space(10);

                GUILayout.EndVertical();
            }

            GUILayout.EndScrollView();
        }
        private void DrawSupportedFormats <T>(List <T> formats, string prefix = "null") where T : struct, IConvertible
        {
            if (!typeof(T).IsEnum)
            {
                throw new ArgumentException("Only 'enum' types as T allowed!");
            }

            foreach (var format in formats)
            {
                var supports     = false;
                var supportState = "NULL";

                try
                {
                    // NOTE : So, that's why i hate "bruteforce" solutions...
                    if (typeof(T) == typeof(RenderTextureFormat))
                    {
                        var f = (RenderTextureFormat)Enum.ToObject(typeof(RenderTextureFormat), format);

                        supports = SystemInfo.SupportsRenderTextureFormat(f);
                    }
                    else if (typeof(T) == typeof(TextureFormat))
                    {
                        var f = (TextureFormat)Enum.ToObject(typeof(TextureFormat), format);

                        supports = SystemInfo.SupportsTextureFormat(f);
                    }
                    else
                    {
                        throw new NotImplementedException("Unsupported format!");
                    }

                    supportState = HardwareInfo.Supports(supports);
                }
                catch (Exception ex)
                {
                    supports     = false;
                    supportState = ex.GetType().Name;
                }

                GUILayoutExtensions.LabelWithSpace(string.Format("{0}.{1}: {2}", prefix, format, supportState), -8);
            }
        }
        protected override void UI(int id)
        {
            var counters = PerformanceMonitor.Counters;

            if (counters == null || counters.Count == 0)
            {
                GUILayoutExtensions.DrawBadHolder("Perfomance stats: ", "No Data!?", GUISkin); return;
            }

            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);
            {
                GUILayout.BeginVertical();

                for (int i = 0; i < counters.Count; i++)
                {
                    var counter = counters[i];

                    GUILayoutExtensions.VerticalBoxed(string.Format("{0}", counter.Name), GUISkin, () =>
                    {
                        GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                        {
                            GUILayoutExtensions.Horizontal(() =>
                            {
                                GUILayoutExtensions.LabelWithSpace(string.Format("Total: {0}", counter.Time / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Average: {0}", counter.Average / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Last: {0}", counter.Last / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Max: {0}", counter.Max / 1000.0f), -8);
                                GUILayoutExtensions.LabelWithSpace(string.Format("Count: {0}", counter.Count), -8);
                            });
                        }, GUILayout.Width(debugInfoDrawBounds.width - 45));
                    }, GUILayout.Width(debugInfoDrawBounds.width - 40));
                }

                GUILayoutExtensions.SpacingSeparator();

                GUILayout.EndVertical();
            }

            GUILayoutExtensions.SpacingSeparator();

            GUILayout.EndScrollView();
        }
Beispiel #20
0
        protected override void UI(int id)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);

            GUILayout.BeginVertical();

            GUILayout.Label("Misc: ", boldLabel);

            GUILayoutExtensions.LabelWithSpace("Quads culling method: " + GodManager.Instance.CullingMethod, 0);
            GodManager.Instance.CullingMethod = (QuadCullingMethod)GUILayout.SelectionGrid((int)GodManager.Instance.CullingMethod, System.Enum.GetNames(typeof(QuadCullingMethod)), 3);

            GUILayoutExtensions.LabelWithSpace("Quads LOD distance method: " + GodManager.Instance.LODDistanceMethod.ToString(), 0);
            GodManager.Instance.LODDistanceMethod = (QuadLODDistanceMethod)GUILayout.SelectionGrid((int)GodManager.Instance.LODDistanceMethod, System.Enum.GetNames(typeof(QuadLODDistanceMethod)), 3);

            GUILayout.Space(10);

            GUILayout.Label("LOD Distance Multiplier: " + GodManager.Instance.LODDistanceMultiplier);
            GUILayout.BeginHorizontal();
            GodManager.Instance.LODDistanceMultiplier = GUILayout.HorizontalSlider(GodManager.Instance.LODDistanceMultiplier, 0.75f, 3.25f);
            if (GUILayout.Button("Reset"))
            {
                GodManager.Instance.LODDistanceMultiplier = 1.0f;
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            GUILayout.Label("HDR: ");
            GodManager.Instance.HDRMode = (AtmosphereHDR)GUILayout.SelectionGrid((int)GodManager.Instance.HDRMode, System.Enum.GetNames(typeof(AtmosphereHDR)), 2);

            GUILayout.Space(10);

            GodManager.Instance.Eclipses    = GUILayout.Toggle(GodManager.Instance.Eclipses, " - Eclipses?");
            GodManager.Instance.Planetshine = GUILayout.Toggle(GodManager.Instance.Planetshine, " - Planetshine?");

            GUILayout.EndVertical();

            GUILayout.EndScrollView();
        }
Beispiel #21
0
        protected override void UI(int id)
        {
            GUILayoutExtensions.VerticalBoxed("Controls: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    ShowContents = GUILayout.Toggle(ShowContents, " Show Storage Contents?");
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            DrawStorageInfo <GPUTileStorage>("GPU Storage");
            DrawStorageInfo <CBTileStorage>("CB Storage");
            DrawStorageInfo <CPUTileStorage>("CPU Storage");

            GUILayoutExtensions.SpacingSeparator();

            GUILayout.EndScrollView();
        }
Beispiel #22
0
        private void OnGUI()
        {
            if (GUISkin != null)
            {
                var labelBoldStyle = GUI.skin.FindStyle("label_bold");
                var labelStyle     = GUI.skin.FindStyle("label");
                var labelImage     = GUI.skin.FindStyle("label_image");

                if (labelBoldStyle != null)
                {
                    BoldLabelStyle = labelBoldStyle;
                }
                else if (labelStyle != null)
                {
                    BoldLabelStyle = labelStyle;
                }

                if (labelImage != null)
                {
                    ImageLabelStyle = labelImage;
                }
                else if (labelStyle != null)
                {
                    ImageLabelStyle = labelStyle;
                }
            }

            if (ShowAdditionalInfo && !AtLeastOneEnabled)
            {
                GUILayoutExtensions.Vertical(() =>
                {
                    GUILayoutExtensions.LabelWithSpace(string.Format("Press {0} key to switch between debug GUI's...", SwitchKey.ToString()));
                    GUILayoutExtensions.LabelWithSpace(string.Format("Mouse Position: {0}", Input.mousePosition));
                });
            }
        }
Beispiel #23
0
        private void DrawSupportedFormats <TFormatType>(Dictionary <TFormatType, HardwareInfo.SupportState> formats, string prefix = "null") where TFormatType : struct, IConvertible
        {
            if (!typeof(TFormatType).IsEnum)
            {
                throw new ArgumentException("Only 'enum' types as T allowed!");
            }
            if (formats == null || formats.Count == 0)
            {
                GUILayoutExtensions.HorizontalBoxed("", GUISkin, () =>
                {
                    GUILayoutExtensions.LabelWithFlexibleSpace("No Data!", "No Info!");
                });

                return;
            }

            foreach (var kvp in formats)
            {
                var format       = kvp.Key;
                var supportState = kvp.Value;

                var tempColor   = GUI.color;
                var actualColor = HardwareInfo.SupportStateToColor(supportState);

                GUILayoutExtensions.DrawWithColor(() =>
                {
                    GUILayoutExtensions.HorizontalBoxed("", GUISkin, () =>
                    {
                        GUILayoutExtensions.DrawWithColor(() =>
                        {
                            GUILayoutExtensions.LabelWithFlexibleSpace(string.Format("{0}.{1}", prefix, format), supportState.ToString());
                        }, tempColor);
                    });
                }, actualColor);
            }
        }
Beispiel #24
0
        protected override void UI(int id)
        {
            if (DebugSequenceManager.Instance == null)
            {
                return;
            }

            var sequence = DebugSequenceManager.Instance.Sequence;

            if (sequence == null)
            {
                return;
            }

            if (sequence.Count != 0)
            {
                ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);
                {
                    GUILayout.BeginVertical();

                    for (int i = 0; i < sequence.Count; i++)
                    {
                        var entry = sequence[i];

                        GUILayout.BeginVertical(string.Format("{0}", entry.Name), GUISkin.box, GUILayout.Width(debugInfoBounds.width - 40));
                        {
                            GUILayout.Space(20);

                            if (true)
                            {
                                GUILayout.BeginVertical("", GUISkin.box, GUILayout.Width(debugInfoBounds.width - 45));
                                {
                                    GUILayoutExtensions.Vertical(() =>
                                    {
                                        GUILayoutExtensions.Horizontal(() =>
                                        {
                                            GUILayoutExtensions.LabelWithFlexibleSpace("Time: ", entry.Time);
                                        });

                                        GUILayoutExtensions.Horizontal(() =>
                                        {
                                            GUILayoutExtensions.LabelWithFlexibleSpace("Time Since Startup: ", entry.TimeSinceStartup);
                                        });

                                        GUILayoutExtensions.Horizontal(() =>
                                        {
                                            GUILayoutExtensions.LabelWithFlexibleSpace("Frame: ", entry.Frame);
                                        });
                                    });
                                }
                                GUILayout.EndVertical();
                            }
                        }
                        GUILayout.EndVertical();
                    }

                    GUILayout.Space(10);

                    GUILayout.EndVertical();
                }

                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Label("No sequence!", BoldLabelStyle);
            }
        }
        protected override void UI(int id)
        {
            GUILayoutExtensions.VerticalBoxed("Controls: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    DrawApplyButton(() => { if (Body != null && Atmosphere != null)
                                            {
                                                Atmosphere.Bake();
                                            }
                                    });
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            if (Body != null && Helper.Enabled(Body))
            {
                if (Atmosphere != null && Helper.Enabled(Body.Atmosphere) && Body.AtmosphereEnabled)
                {
                    GUILayoutExtensions.VerticalBoxed("Realtime parameters: ", GUISkin, () =>
                    {
                        GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                        {
                            GUILayoutExtensions.VerticalBoxed("Preset: ", GUISkin, () =>
                            {
                                Atmosphere.AtmosphereBase = (AtmosphereBase)GUILayout.SelectionGrid((int)Atmosphere.AtmosphereBase, Enum.GetNames(typeof(AtmosphereBase)), 2);
                            });

                            GUILayoutExtensions.SpacingSeparator();

                            GUILayoutExtensions.VerticalBoxed("Artifact fixers: ", GUISkin, () =>
                            {
                                GUILayoutExtensions.SliderWithField("Radius Hold (Terrain Radius)", 0.0f, 2048.0f, ref Atmosphere.RadiusHold, "0.00", 75);
                                GUILayoutExtensions.SliderWithField("Aerial Radius (Perspective Offset)", 0.0f, 4096.0f, ref Atmosphere.AerialPerspectiveOffset, "0.00", 75);
                                GUILayoutExtensions.SliderWithFieldAndControls("Horizon Fix Eps", 0.0f, 1.0f, ref Atmosphere.HorizonFixEps, "0.00000", 75, 0.00025f);
                                GUILayoutExtensions.SliderWithFieldAndControls("Mie Fade Fix", 0.0f, 1.0f, ref Atmosphere.MieFadeFix, "0.0000", 75, 0.0025f);
                            });

                            GUILayoutExtensions.SpacingSeparator();

                            GUILayoutExtensions.SliderWithField("Density: ", 0.0f, 1.0f, ref Atmosphere.Density);
                            GUILayoutExtensions.SliderWithField("Scale", 0.01f, 16.0f, ref Atmosphere.Scale, "0.000");
                            GUILayoutExtensions.SliderWithField("Height: ", 0.0f, Body.Size, ref Atmosphere.Height);
                            GUILayoutExtensions.SliderWithField("Extinction Ground Fade", 0.000025f, 0.1f, ref Atmosphere.ExtinctionGroundFade, "0.000000");
                            GUILayoutExtensions.SliderWithField("HDR Exposure", 0.0f, 1.0f, ref Atmosphere.HDRExposure, "0.00");
                        });
                    });

                    GUILayoutExtensions.SpacingSeparator();

                    if (Atmosphere.AtmosphereBase == AtmosphereBase.Custom)
                    {
                        GUILayoutExtensions.VerticalBoxed("Bake parameters: ", GUISkin, () =>
                        {
                            GUILayoutExtensions.VerticalBoxed("Copy from preset: ", GUISkin, () =>
                            {
                                AtmosphereBase = (AtmosphereBase)GUILayout.SelectionGrid((int)AtmosphereBase, Enum.GetNames(typeof(AtmosphereBase)), 2);
                            });

                            GUILayoutExtensions.SpacingSeparator();

                            var parameters = PresetChanged ? AtmosphereParameters.Get(AtmosphereBase) : new AtmosphereParameters(AtmosphereParameters);

                            var mieG  = parameters.MIE_G;
                            var hr    = parameters.HR;
                            var hm    = parameters.HM;
                            var agr   = parameters.AVERAGE_GROUND_REFLECTANCE;
                            var betaR = parameters.BETA_R;
                            var betaM = parameters.BETA_MSca;
                            var betaE = parameters.BETA_MEx;
                            var rg    = parameters.Rg;
                            var rt    = parameters.Rt;
                            var rl    = parameters.Rl;

                            PresetChanged = false;

                            GUILayoutExtensions.SliderWithField("Mie G: ", 0.0f, 1.0f, ref mieG, "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithFieldAndControls("Air density (HR At half-height in KM): ", 0.0f, 256.0f, ref hr, "0.00", textFieldWidth: 100, controlStep: 1.0f);
                            GUILayoutExtensions.SliderWithFieldAndControls("Particle density (HM At half-height in KM): ", 0.0f, 256.0f, ref hm, "0.00", textFieldWidth: 100, controlStep: 1.0f);
                            GUILayoutExtensions.SliderWithField("Average Ground Reflectance: ", 0.0f, 1.0f, ref agr, "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithField("Rg (Planet Radius in KM): ", 0.0f, 63600.0f, ref rg, "0.00000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithField("Rt (Atmosphere Top Radius in KM): ", rg, 63600.0f, ref rt, "0.00000", textFieldWidth: 100);
                            GUILayoutExtensions.SliderWithField("Rl (Planet Bottom Radius in KM): ", rt, 63600.0f, ref rl, "0.00000", textFieldWidth: 100);

                            GUILayoutExtensions.DrawVectorWithSlidersAndFields(ref betaR, 0.0f, 1.0f, GUISkin, "Beta R (Rayliegh Scattering)", "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.DrawVectorWithSlidersAndFields(ref betaM, 0.0f, 1.0f, GUISkin, "Beta M (Mie Scattering)", "0.0000", textFieldWidth: 100);
                            GUILayoutExtensions.DrawVectorWithSlidersAndFields(ref betaE, 0.0f, 1.0f, GUISkin, "Beta E (Extinction Scattering)", "0.0000", textFieldWidth: 100);

                            parameters = new AtmosphereParameters(mieG, hr, hm, agr, betaR, betaM, betaE, rg, rt, rl, rg, rt, rl, SCALE: 1.0f);

                            AtmosphereParameters = new AtmosphereParameters(parameters);
                            Atmosphere.PushPreset(parameters);
                        });
                    }
                    else
                    {
                        GUILayoutExtensions.DrawBadHolder("Atmosphere Bake parameters: ", "Use 'Custom' preset please...", GUISkin);
                    }
                }
                else
                {
                    GUILayoutExtensions.DrawBadHolder("Atmosphere parameters: ", "No Atmosphere!?", GUISkin);
                }
            }
            else
            {
                GUILayoutExtensions.DrawBadHolder("Atmosphere parameters: ", "No Body!?", GUISkin);
            }

            GUILayout.EndScrollView();
        }
Beispiel #26
0
 public void OnGUI()
 {
     GUILayoutExtensions.OnGUI();
 }
Beispiel #27
0
        protected override void UI(int id)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);

            if (Planetoid != null)
            {
                GUILayout.BeginVertical();

                GUILayout.Label("Planetoid stats: ", boldLabel);

                var highestLODLevel = Planetoid.Quads.Max((quad => quad.LODLevel)) + 1;

                GUILayoutExtensions.LabelWithSpace((Planetoid.gameObject.name + ": " + (Planetoid.Working ? "Generating..." : "Idle...")), -8);
                GUILayoutExtensions.LabelWithSpace("Highest LOD level: " + highestLODLevel, -8);

                if (Planetoid.CullingMethod == QuadCullingMethod.Custom)
                {
                    var quadsCount       = Planetoid.Quads.Count;
                    var quadsCulledCount = Planetoid.GetCulledQuadsCount();
                    var vertsRendered    = (quadsCount - quadsCulledCount) * QuadSettings.Vertices;

                    var quadsTexturesVideoMemoryUsage = CalculateTexturesVMU(quadsCount);

                    GUILayoutExtensions.LabelWithSpace("Quads count: " + quadsCount, -8);
                    GUILayoutExtensions.LabelWithSpace("Quads culled count: " + quadsCulledCount, -8);
                    GUILayoutExtensions.LabelWithSpace("Quads textures VMU (MB): " + quadsTexturesVideoMemoryUsage.ToString("0.00"), -8);
                    GUILayoutExtensions.LabelWithSpace("Verts rendered per frame (Only Quads): " + vertsRendered, -8);
                }

                GUILayout.EndVertical();

                GUILayout.BeginVertical();

                GUILayout.Space(10);

                GUILayout.Label("Planetoid parameters: ", boldLabel);

                if (GUILayout.Button("Resetup"))
                {
                    Planetoid.ReSetupQuads();
                }

                GUILayout.EndVertical();

                if (Planetoid.Atmosphere != null)
                {
                    GUILayout.Space(10);

                    GUILayout.BeginVertical();

                    GUILayout.Label("Atmosphere parameters: ", boldLabel);

                    GUILayout.Label("Preset: ");
                    Planetoid.Atmosphere.AtmosphereBase = (AtmosphereBase)GUILayout.SelectionGrid((int)Planetoid.Atmosphere.AtmosphereBase, System.Enum.GetNames(typeof(AtmosphereBase)), 2);

                    GUILayout.Space(10);

                    GUILayout.Label("Density: ");
                    float.TryParse(GUILayout.TextField(Planetoid.Atmosphere.Density.ToString("0.0")), out Planetoid.Atmosphere.Density);

                    GUILayout.Label("Height: ");
                    float.TryParse(GUILayout.TextField(Planetoid.Atmosphere.Height.ToString("0.0")), out Planetoid.Atmosphere.Height);

                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.BeginVertical();

                    GUILayoutExtensions.LabelWithSpace("No Atmosphere!?", -8);

                    GUILayout.EndVertical();
                }
            }
            else
            {
                GUILayout.BeginVertical();

                GUILayoutExtensions.LabelWithSpace("No Planetoid!?", -8);

                GUILayout.EndVertical();
            }

            GUILayout.EndScrollView();
        }
Beispiel #28
0
        protected override void UI(int id)
        {
            GUILayoutExtensions.VerticalBoxed("Controls: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    if (GUILayout.Button("Update"))
                    {
                        HardwareInfo.Get();
                    }
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            GUILayoutExtensions.VerticalBoxed("Overall summary: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    GUILayoutExtensions.LabelWithSpace("Device Type: " + HardwareInfo.deviceType, -8);
                    GUILayoutExtensions.LabelWithSpace("Operation System: " + HardwareInfo.operatingSystem, -8);
                    GUILayoutExtensions.LabelWithSpace("Unity Version: " + HardwareInfo.unityVersion, -8);
                    GUILayoutExtensions.LabelWithSpace("Graphics Device: " + HardwareInfo.graphicsDeviceName, -8);
                    GUILayoutExtensions.LabelWithSpace("Graphics Device API: " + HardwareInfo.graphicsDeviceVersion, -8);
                    GUILayoutExtensions.LabelWithSpace("Graphics Device ID: " + HardwareInfo.graphicsDeviceID, -8);
                    GUILayoutExtensions.LabelWithSpace("Graphics Memory Size: " + HardwareInfo.graphicsMemorySize, -8);
                    GUILayoutExtensions.LabelWithSpace("Supported Shader Level: " + HardwareInfo.graphicsShaderLevel, -8);

                    GUILayoutExtensions.LabelWithSpace("CPU: " + HardwareInfo.processorType, -8);
                    GUILayoutExtensions.LabelWithSpace("CPU Cores Count (Threads Count): " + HardwareInfo.processorCount, -8);
                    GUILayoutExtensions.LabelWithSpace("CPU Current Frequency: " + HardwareInfo.processorFrequency + "Hz", -8);

                    GUILayoutExtensions.LabelWithSpace("RAM: " + HardwareInfo.systemMemorySize, -8);

                    GUILayoutExtensions.LabelWithSpace("Maximum Texture Size: " + HardwareInfo.maxTextureSize, -8);
                    GUILayoutExtensions.LabelWithSpace("Non-Power-Of-Two Texture Support: " + HardwareInfo.npotSupport, -8);

                    GUILayoutExtensions.LabelWithSpace("RenderTextures: " + true, -8);
                    GUILayoutExtensions.LabelWithSpace("Graphics Multithreading: " + HardwareInfo.graphicsMultiThreaded, -8);

                    GUILayoutExtensions.LabelWithSpace("Supports ComputeShaders: " + HardwareInfo.supportsComputeShaders, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports 3DTextures: " + HardwareInfo.supports3DTextures, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports 2DArrayTextures: " + HardwareInfo.supports2DArrayTextures, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports 3DRenderTextures: " + HardwareInfo.supports3DRenderTextures, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports CubemapArrayTextures: " + HardwareInfo.supportsCubemapArrayTextures, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports RawShadowDepthSampling: " + HardwareInfo.supportsRawShadowDepthSampling, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports MotionVectors: " + HardwareInfo.supportsMotionVectors, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports RenderToCubemap: " + HardwareInfo.supportsRenderToCubemap, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports ImageEffects: " + HardwareInfo.supportsImageEffects, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports HardwareQuadTopology: " + HardwareInfo.supportsHardwareQuadTopology, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports 32bitsIndexBuffer: " + HardwareInfo.supports32bitsIndexBuffer, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports SparseTextures: " + HardwareInfo.supportsSparseTextures, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports AsyncCompute: " + HardwareInfo.supportsAsyncCompute, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports GPUFence: " + HardwareInfo.supportsGPUFence, -8);
                    GUILayoutExtensions.LabelWithSpace("Supports AsyncGPUReadback: " + HardwareInfo.supportsAsyncGPUReadback, -8);

                    GUILayoutExtensions.SpacingSeparator();
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            GUILayoutExtensions.VerticalBoxed("Render Texture support summary: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    DrawSupportedFormats <RenderTextureFormat>(HardwareInfo.RenderTextureFormats, "RenderTexture");

                    GUILayoutExtensions.SpacingSeparator();
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            GUILayoutExtensions.VerticalBoxed("Texture support summary: ", GUISkin, () =>
            {
                GUILayoutExtensions.VerticalBoxed("", GUISkin, () =>
                {
                    DrawSupportedFormats <TextureFormat>(HardwareInfo.TextureFormats, "Texture");

                    GUILayoutExtensions.SpacingSeparator();
                });
            });

            GUILayoutExtensions.SpacingSeparator();

            GUILayout.EndScrollView();
        }
Beispiel #29
0
        protected override void UI(int id)
        {
            ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true);

            if (Body != null && Helper.Enabled(Body))
            {
                GUILayout.BeginVertical();

                GUILayout.Label("Body parameters: ", BoldLabelStyle);

                if (Body.MaterialTable != null && Body.MaterialTable.Lut != null)
                {
                    GUILayout.Label("Material Table: ");
                    GUILayout.BeginVertical("", GUISkin.box);
                    {
                        GUILayoutExtensions.Horizontal(() =>
                        {
                            GUILayout.Label(Body.MaterialTable.Lut);
                        });
                    }
                    GUILayout.EndVertical();
                }

                GUILayout.EndVertical();

                if (Body.Atmosphere != null && Helper.Enabled(Body.Atmosphere))
                {
                    GUILayout.BeginVertical();

                    GUILayout.Label("Atmosphere parameters: ", BoldLabelStyle);

                    GUILayout.Label("Preset: ");
                    Body.Atmosphere.AtmosphereBase = (AtmosphereBase)GUILayout.SelectionGrid((int)Body.Atmosphere.AtmosphereBase, System.Enum.GetNames(typeof(AtmosphereBase)), 2);

                    GUILayout.Space(10);

                    GUILayoutExtensions.SliderWithField("Density: ", 0.0f, 1.0f, ref Body.Atmosphere.Density);
                    GUILayoutExtensions.SliderWithField("Height: ", 0.0f, Body.Size / 1000.0f, ref Body.Atmosphere.Height);

                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.BeginVertical();

                    GUILayoutExtensions.LabelWithSpace("No Atmosphere!?", -8);

                    GUILayout.EndVertical();
                }

                if (Body.Ocean != null && Helper.Enabled(Body.Ocean))
                {
                    GUILayout.BeginVertical();

                    GUILayout.Label("Ocean parameters: ", BoldLabelStyle);

                    GUILayoutExtensions.SliderWithField("Level: ", 0.0f, 5.0f, ref Body.Ocean.OceanLevel);
                    GUILayoutExtensions.SliderWithField("Z Min: ", 0.0f, 50000.0f, ref Body.Ocean.ZMin);

                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.BeginVertical();

                    GUILayoutExtensions.LabelWithSpace("No Ocean!?", -8);

                    GUILayout.EndVertical();
                }
            }
            else
            {
                GUILayout.BeginVertical();

                GUILayoutExtensions.LabelWithSpace("No Body!?", -8);

                GUILayout.EndVertical();
            }

            GUILayout.EndScrollView();
        }
Beispiel #30
0
        /// <summary>
        /// Wake the addon. Creates the server instance and UI.
        /// </summary>
        public void Awake()
        {
            if (!ServicesChecker.OK)
            {
                return;
            }

            Init();

            KRPCServer.Context.SetGameScene(KSPAddonImproved.CurrentGameScene.ToGameScene());
            Logger.WriteLine("Game scene switched to " + KRPCServer.Context.GameScene);

            GUILayoutExtensions.Init(gameObject);

            server.GetUniversalTime = Planetarium.GetUniversalTime;

            // Disconnect client dialog
            clientDisconnectDialog = gameObject.AddComponent <ClientDisconnectDialog> ();

            // Create info window
            infoWindow          = gameObject.AddComponent <InfoWindow> ();
            infoWindow.Server   = server;
            infoWindow.Closable = true;
            infoWindow.Visible  = config.InfoWindowVisible;
            infoWindow.Position = config.InfoWindowPosition;

            // Create main window
            mainWindow          = gameObject.AddComponent <MainWindow> ();
            mainWindow.Config   = config;
            mainWindow.Server   = server;
            mainWindow.Visible  = config.MainWindowVisible;
            mainWindow.Position = config.MainWindowPosition;
            mainWindow.ClientDisconnectDialog = clientDisconnectDialog;
            mainWindow.InfoWindow             = infoWindow;

            // Create new connection dialog
            clientConnectingDialog = gameObject.AddComponent <ClientConnectingDialog> ();

            // Main window events
            mainWindow.OnStartServerPressed += (s, e) => StartServer();
            mainWindow.OnStopServerPressed  += (s, e) => {
                server.Stop();
                clientConnectingDialog.Close();
            };
            mainWindow.OnHide += (s, e) => {
                config.Load();
                config.MainWindowVisible = false;
                config.Save();
            };
            mainWindow.OnShow += (s, e) => {
                config.Load();
                config.MainWindowVisible = true;
                config.Save();
            };
            mainWindow.OnMoved += (s, e) => {
                config.Load();
                var window = s as MainWindow;
                config.MainWindowPosition = window.Position;
                config.Save();
            };

            // Info window events
            infoWindow.OnHide += (s, e) => {
                config.Load();
                config.InfoWindowVisible = false;
                config.Save();
            };
            infoWindow.OnShow += (s, e) => {
                config.Load();
                config.InfoWindowVisible = true;
                config.Save();
            };
            infoWindow.OnMoved += (s, e) => {
                config.Load();
                var window = s as InfoWindow;
                config.InfoWindowPosition = window.Position;
                config.Save();
            };

            // Server events
            server.OnClientRequestingConnection += (s, e) => {
                if (config.AutoAcceptConnections)
                {
                    e.Request.Allow();
                }
                else
                {
                    clientConnectingDialog.OnClientRequestingConnection(s, e);
                }
            };


            // Add a button to the applauncher
            mainWindow.Closable = true;
            textureOnline       = GameDatabase.Instance.GetTexture("kRPC/icons/applauncher-online", false);
            textureOffline      = GameDatabase.Instance.GetTexture("kRPC/icons/applauncher-offline", false);
            GameEvents.onGUIApplicationLauncherReady.Add(OnGUIApplicationLauncherReady);
            GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGUIApplicationLauncherDestroyed);
            server.OnStarted += (s, e) => {
                if (applauncherButton != null)
                {
                    applauncherButton.SetTexture(textureOnline);
                }
            };
            server.OnStopped += (s, e) => {
                if (applauncherButton != null)
                {
                    applauncherButton.SetTexture(textureOffline);
                }
            };
        }