private void DrawCurrentCustomGUI(int theWindowID) { if (itsCurrentSelectedGUI.GetIcon() == null) { KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsDataModuleCustomGUI.itsUnknownIcon); } else { KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsCurrentSelectedGUI.GetIcon()); } GUILayout.FlexibleSpace(); bool aClose = KGFGUIUtility.EndWindowHeader(true); //Draw the content if (!aClose) { // hack to keep the window in min size GUILayout.Space(0); itsCurrentSelectedGUI.Render(); GUI.DragWindow(); //GUI.DragWindow(new Rect(0, 0, itsWindowRectangle.width, KGFGUIUtility.GetWindowStyle().padding.top)); } else { itsCurrentSelectedGUI = null; } }
private void OnKGFIDebugGUIImplementationAdded(object theImplementation) { KGFICustomGUI aImplementation = theImplementation as KGFICustomGUI; if (aImplementation != null) { itsCustomGUIImplementations.Add(aImplementation); } }
public static void Remove(KGFICustomGUI theCustomGUI) { if (itsCustomGUIImplementations.Contains(theCustomGUI)) { itsCustomGUIImplementations.Remove(theCustomGUI); } else { UnityEngine.Debug.Log("this custom gui is not registered"); } }
public static void Add(KGFICustomGUI theCustomGUI) { if (!itsCustomGUIImplementations.Contains(theCustomGUI)) { itsCustomGUIImplementations.Add(theCustomGUI); } else { UnityEngine.Debug.Log("this custom gui is alreay registered"); } }
void OnAddCustomGui(object theSender, EventArgs theArgs) { KGFAccessor.KGFAccessorEventargs anEventArgs = theArgs as KGFAccessor.KGFAccessorEventargs; if (anEventArgs != null) { KGFICustomGUI aCustomGui = anEventArgs.GetObject() as KGFICustomGUI; if (aCustomGui != null) { Add(aCustomGui); } } }
private void DrawCurrentCustomGUI(float aCustomGuiWidth) { if (itsCurrentSelectedGUI == null) { return; } float aHeight = KGFGUIUtility.GetSkinHeight() + KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical; GUILayout.BeginArea(new Rect(aHeight, aHeight, Screen.width - aCustomGuiWidth - aHeight, Screen.height - aHeight * 2.0f)); { KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBox); { if (itsCurrentSelectedGUI.GetIcon() == null) { KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsDataModuleCustomGUI.itsUnknownIcon); } else { KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsCurrentSelectedGUI.GetIcon()); } GUILayout.FlexibleSpace(); bool aClose = KGFGUIUtility.EndWindowHeader(true); //Draw the content if (!aClose) { // hack to keep the window in min size GUILayout.Space(0); itsCurrentSelectedGUI.Render(); } else { itsCurrentSelectedGUI = null; } } KGFGUIUtility.EndVerticalBox(); } GUILayout.EndArea(); }
public static void Render() { if (itsInstance != null && itsInstance.itsDataModuleCustomGUI.itsBarVisible) { if (itsCustomGUIImplementations.Count == 0) { return; } GUIStyle aTogglStyle = KGFGUIUtility.GetStyleToggl(KGFGUIUtility.eStyleToggl.eTogglRadioStreched); GUIStyle aBoxStyle = KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated); int aWidth = (int)(aTogglStyle.contentOffset.x + aTogglStyle.padding.horizontal + (KGFGUIUtility.GetSkinHeight() - aTogglStyle.padding.vertical)); int aHeight = (int)(aBoxStyle.margin.top + aBoxStyle.margin.bottom + aBoxStyle.padding.top + aBoxStyle.padding.bottom + (aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGUIImplementations.Count); //(int)(aTogglStyle.margin.bottom + aBoxStyle.margin.vertical + aBoxStyle.padding.vertical); //(aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGUIImplementations.Count) GUILayout.BeginArea(new Rect(Screen.width - aWidth, (Screen.height - aHeight) / 2, aWidth, aHeight)); { KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); { GUILayout.FlexibleSpace(); foreach (KGFICustomGUI aCustomGUI in itsCustomGUIImplementations) { bool aValue; if (itsCurrentSelectedGUI != null && itsCurrentSelectedGUI == aCustomGUI) { aValue = true; } else { aValue = false; } Texture2D aIcon = aCustomGUI.GetIcon(); if (aIcon == null) { aIcon = itsInstance.itsDataModuleCustomGUI.itsUnknownIcon; } if (aValue != KGFGUIUtility.Toggle(aValue, aIcon, KGFGUIUtility.eStyleToggl.eTogglRadioStreched)) { if (aValue) { itsCurrentSelectedGUI = null; } else { itsCurrentSelectedGUI = aCustomGUI; } } } GUILayout.FlexibleSpace(); } KGFGUIUtility.EndVerticalBox(); //Draw the Custom GUI if (itsCurrentSelectedGUI != null) { itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI, itsCurrentSelectedGUI.GetName(), GUILayout.MinHeight(200), GUILayout.MinWidth(300)); // check if the window is still visible in screen if (itsWindowRectangle.x < -itsWindowRectangle.width + 20) { itsWindowRectangle.x = -itsWindowRectangle.width + 20; } else if (itsWindowRectangle.x > Screen.width - 20) { itsWindowRectangle.x = Screen.width - 20; } if (itsWindowRectangle.y < -itsWindowRectangle.height + 20) { itsWindowRectangle.y = -itsWindowRectangle.height + 20; } else if (itsWindowRectangle.y > Screen.height - 20) { itsWindowRectangle.y = Screen.height - 20; } } } GUILayout.EndArea(); #region old render code /* * * float aButtonSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16); * float aButtonSpaceVertical = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16); * int aBoxSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.horizontal + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.horizontal, 24); * int aBoxSpaceVertical = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical, 24); * * GUILayout.BeginArea(new Rect(Screen.width - (aBoxSpaceHorizontal + aButtonSpaceHorizontal / 2), * Screen.height / 2 - ((itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceHorizontal) / 2, * aButtonSpaceHorizontal + aBoxSpaceHorizontal, * (itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceVertical)); * * { * KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.MinWidth(24)); * { * foreach(KGFICustomGUI aCustomGUI in itsCustomGUIImplementations) * { * bool selected = false; * float aWidth = Mathf.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16); * * if(aCustomGUI.GetIcon() != null) * { * if(KGFGUIUtility.Button(aCustomGUI.GetIcon(), KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth))) * { * selected = true; * } * } * else * { * if(itsUnknownIcon != null) * { * if(KGFGUIUtility.Button(itsUnknownIcon, KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth))) * { * selected = true; * } * } * else * { * if(KGFGUIUtility.Button("?", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth))) * { * selected = true; * } * } * } * * // check if one of the Buttons was clicked * if(selected && aCustomGUI != itsCurrentSelectedGUI) * { * itsCurrentSelectedGUI = aCustomGUI; * } * else if(selected && aCustomGUI == itsCurrentSelectedGUI) * { * itsCurrentSelectedGUI = null; * } * } * } * KGFGUIUtility.EndVerticalBox(); * } * GUILayout.EndArea(); * * //Draw the Custom GUI * if(itsCurrentSelectedGUI != null) * { * itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI,string.Empty, GUILayout.MinHeight(200), GUILayout.MinWidth(300)); * * // check if the window is still visible in screen * if(itsWindowRectangle.x < -itsWindowRectangle.width + 20) * { * itsWindowRectangle.x = -itsWindowRectangle.width + 20; * } * else if(itsWindowRectangle.x > Screen.width - 20) * { * itsWindowRectangle.x = Screen.width - 20; * } * * if(itsWindowRectangle.y < -itsWindowRectangle.height + 20) * { * itsWindowRectangle.y = -itsWindowRectangle.height + 20; * } * else if(itsWindowRectangle.y > Screen.height - 20) * { * itsWindowRectangle.y = Screen.height - 20; * } * } * } */ #endregion } }
private void DrawCurrentCustomGUI(float aCustomGuiWidth) { if(itsCurrentSelectedGUI == null) return; float aHeight = KGFGUIUtility.GetSkinHeight() + KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical; GUILayout.BeginArea(new Rect(aHeight,aHeight,Screen.width-aCustomGuiWidth-aHeight,Screen.height-aHeight*2.0f)); { KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBox); { if(itsCurrentSelectedGUI.GetIcon() == null) { KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsDataModuleCustomGUI.itsUnknownIcon); } else { KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsCurrentSelectedGUI.GetIcon()); } GUILayout.FlexibleSpace(); bool aClose = KGFGUIUtility.EndWindowHeader(true); //Draw the content if(!aClose) { // hack to keep the window in min size GUILayout.Space(0); itsCurrentSelectedGUI.Render(); } else { itsCurrentSelectedGUI = null; } } KGFGUIUtility.EndVerticalBox(); } GUILayout.EndArea(); }
public static void Render() { KGFGUIUtility.SetSkinIndex(0); if(itsInstance != null && itsInstance.itsDataModuleCustomGUI.itsBarVisible) { GUIStyle aTogglStyle = KGFGUIUtility.GetStyleToggl(KGFGUIUtility.eStyleToggl.eTogglRadioStreched); GUIStyle aBoxStyle = KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated); int aWidth = (int)(aTogglStyle.contentOffset.x + aTogglStyle.padding.horizontal + (KGFGUIUtility.GetSkinHeight() - aTogglStyle.padding.vertical)); int aHeight = (int)(aBoxStyle.margin.top + aBoxStyle.margin.bottom + aBoxStyle.padding.top + aBoxStyle.padding.bottom + (aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGuiList.Count); GUILayout.BeginArea(new Rect(Screen.width - aWidth, (Screen.height - aHeight) / 2, aWidth, aHeight)); { KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); { GUILayout.FlexibleSpace(); foreach(KGFICustomGUI aCustomGUI in itsCustomGuiList) { bool aValue; if(itsCurrentSelectedGUI != null && itsCurrentSelectedGUI == aCustomGUI) { aValue = true; } else { aValue = false; } Texture2D aIcon = aCustomGUI.GetIcon(); if(aIcon == null) { aIcon = itsInstance.itsDataModuleCustomGUI.itsUnknownIcon; } if(aValue != KGFGUIUtility.Toggle(aValue, aIcon, KGFGUIUtility.eStyleToggl.eTogglRadioStreched)) { if(aValue) { itsCurrentSelectedGUI = null; } else { itsCurrentSelectedGUI = aCustomGUI; } } } GUILayout.FlexibleSpace(); } KGFGUIUtility.EndVerticalBox(); } GUILayout.EndArea(); itsInstance.DrawCurrentCustomGUI(aWidth); #region old render code /* float aButtonSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16); float aButtonSpaceVertical = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16); int aBoxSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.horizontal + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.horizontal, 24); int aBoxSpaceVertical = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical, 24); GUILayout.BeginArea(new Rect(Screen.width - (aBoxSpaceHorizontal + aButtonSpaceHorizontal / 2), Screen.height / 2 - ((itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceHorizontal) / 2, aButtonSpaceHorizontal + aBoxSpaceHorizontal, (itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceVertical)); { KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.MinWidth(24)); { foreach(KGFICustomGUI aCustomGUI in itsCustomGUIImplementations) { bool selected = false; float aWidth = Mathf.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16); if(aCustomGUI.GetIcon() != null) { if(KGFGUIUtility.Button(aCustomGUI.GetIcon(), KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth))) { selected = true; } } else { if(itsUnknownIcon != null) { if(KGFGUIUtility.Button(itsUnknownIcon, KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth))) { selected = true; } } else { if(KGFGUIUtility.Button("?", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth))) { selected = true; } } } // check if one of the Buttons was clicked if(selected && aCustomGUI != itsCurrentSelectedGUI) { itsCurrentSelectedGUI = aCustomGUI; } else if(selected && aCustomGUI == itsCurrentSelectedGUI) { itsCurrentSelectedGUI = null; } } } KGFGUIUtility.EndVerticalBox(); } GUILayout.EndArea(); //Draw the Custom GUI if(itsCurrentSelectedGUI != null) { itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI,string.Empty, GUILayout.MinHeight(200), GUILayout.MinWidth(300)); // check if the window is still visible in screen if(itsWindowRectangle.x < -itsWindowRectangle.width + 20) { itsWindowRectangle.x = -itsWindowRectangle.width + 20; } else if(itsWindowRectangle.x > Screen.width - 20) { itsWindowRectangle.x = Screen.width - 20; } if(itsWindowRectangle.y < -itsWindowRectangle.height + 20) { itsWindowRectangle.y = -itsWindowRectangle.height + 20; } else if(itsWindowRectangle.y > Screen.height - 20) { itsWindowRectangle.y = Screen.height - 20; } } } */ #endregion } KGFGUIUtility.SetSkinIndex(1); }