Here are the examples of the csharp api UnityEngine.GUI.Window(int, UnityEngine.Rect, UnityEngine.GUI.WindowFunction, UnityEngine.GUIContent, UnityEngine.GUIStyle) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
16 Examples
19
View Source File : GUIWindow.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm
License : GNU General Public License v3.0
Project Creator : AndrasMumm
public void Render(GUI.WindowFunction onDraw)
{
nextControlYOffset = 20f;
GUI.matrix = Matrix4x4.Scale(Vector3.one);
//GUI.Box(windowRect, text);
GUI.backgroundColor = Color.black;
Rect newWindowRect = GUI.Window(0, new Rect(windowX, windowY, width, height), onDraw, text);
windowX = newWindowRect.x;
windowY = newWindowRect.y;
}
19
View Source File : BehaviorEditor.cs
License : GNU General Public License v3.0
Project Creator : Aroueterra
License : GNU General Public License v3.0
Project Creator : Aroueterra
void DrawWindows()
{
GUILayout.BeginArea(all, style);
BeginWindows();
EditorGUILayout.LabelField(" ", GUILayout.Width(100));
EditorGUILayout.LabelField("replacedign Graph:", GUILayout.Width(100));
settings.currentGraph = (BehaviorGraph)EditorGUILayout.ObjectField(settings.currentGraph, typeof(BehaviorGraph), false, GUILayout.Width(200));
if (settings.currentGraph != null)
{
foreach (BaseNode n in settings.currentGraph.windows)
{
n.DrawCurve();
}
for (int i = 0; i < settings.currentGraph.windows.Count; i++)
{
BaseNode b = settings.currentGraph.windows[i];
if (b.drawNode is StateNode)
{
if (currentStateManager != null && b.stateRef.currentState == currentStateManager.currentState)
{
b.windowRect = GUI.Window(i, b.windowRect,
DrawNodeWindow, b.windowreplacedle,activeStyle);
}
else
{
b.windowRect = GUI.Window(i, b.windowRect,
DrawNodeWindow, b.windowreplacedle);
}
}
else
{
b.windowRect = GUI.Window(i, b.windowRect,
DrawNodeWindow, b.windowreplacedle);
}
}
}
EndWindows();
GUILayout.EndArea();
}
19
View Source File : DefaultInitializationErrorHandler.cs
License : GNU General Public License v3.0
Project Creator : ARPOISE
License : GNU General Public License v3.0
Project Creator : ARPOISE
void OnGUI()
{
// On error, create a full screen window.
if (mErrorOccurred)
GUI.Window(0, new Rect(0, 0, Screen.width, Screen.height), DrawWindowContent, "");
}
19
View Source File : ModMenuComponent.cs
License : MIT License
Project Creator : Dazegambler
License : MIT License
Project Creator : Dazegambler
void OnGUI()
{
if (pauseMenu.activeInHierarchy)
{
var list = ULTRAKIT.Loader.AddonLoader.addons;
guirect.height = 60 + 35 * list.Count();
GUI.skin = CoreContent.UIBundle.Loadreplacedet<GUISkin>("UIUltraMod");
GUI.Window(0, guirect, AddonsMenu, "");
if (Selected != null && AddonLoader.registry.ContainsKey(Selected))
{
GUI.Label(new Rect(addonMenuWidth + 25, 100, 1000, 30), $"{Selected.Data.ModName}");
GUI.Box(new Rect(addonMenuWidth+25,130,addonMenuWidth+10,110),"");
if (GUI.Button(new Rect(addonMenuWidth + 30, 135, addonMenuWidth, 30), "SPAWN INFO"))
{
GameObject.Instantiate(Info(Selected), GameObject.Find("Player").transform.position,Quaternion.idenreplacedy);
}
if (GUI.Button(new Rect(addonMenuWidth + 30, 170, addonMenuWidth, 30), "ENABLE/DISABLE"))
{
Selected.Enabled = !Selected.Enabled;
}
if (GUI.Button(new Rect(addonMenuWidth + 30, 205, addonMenuWidth, 30), "CLOSE"))
{
Selected = null;
}
}
Rect reloadNotifierRect = new Rect(
position: guirect.min + new Vector2(addonMenuWidth+10,0),
size: new Vector2(
x: 1000 / (Screen.width / 1920),
y: 60 / (Screen.height / 1080)));
GUI.Label(reloadNotifierRect, "Press F8 to\nreload addons\nat any time");
}
else
{
active = false;
}
}
19
View Source File : DependencyWeb.cs
License : GNU Lesser General Public License v3.0
Project Creator : disruptorbeam
License : GNU Lesser General Public License v3.0
Project Creator : disruptorbeam
private void OnGUI() {
if(lastPreplacedDetectedNoWebTestsSoDisplayDebugAsExample && testsAndTheirDependenciesList.Count == 0) {
MapDependencies();
}
GUIStyle refButton = new GUIStyle(GUI.skin.button);
refButton.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black;
Color defaultBgColor = GUI.backgroundColor;
GUI.backgroundColor = Color.gray;
if(GUI.Button(new Rect(0,0,75, 25), "Refresh", refButton)) {
inspectedNodeWindow = -1;
RenderedNodes = new List<DependencyNode>();
testsAndTheirDependenciesList = new List<KeyValuePair<string, string[]>>();
DependencyWebs = new List<DependencyNode>();
MapDependencies();
}
GUI.backgroundColor = defaultBgColor;
Rect allSize = new Rect(0, 0, lastRenderX + infoBoxMinWidth, maxWindowY + infoBoxMinWidth);
scroll = GUI.BeginScrollView(new Rect(0, 0, lastRenderX, lastRenderY), scroll, new Rect(0, 0, lastRenderX + infoBoxMinWidth, lastRenderY + infoBoxMinWidth), GUIStyle.none, GUIStyle.none);
GUI.Box(allSize, string.Empty);
for(int all = 0; all < DependencyWebs.Count; all++) {
int index = 0;
DependencyNode parentNode = DependencyWebs[all];
if(!RenderedNodes.Where(x => x.TestName == parentNode.TestName).Any()) {
RenderedNodes.Add(parentNode);
index = RenderedNodes.Count - 1;
float width = DetermineRectWidthBasedOnLengthOfString(RenderedNodes[index].TestName);
Rect newRect = originRect;
newRect.width = width;
RenderedNodes[index].rect = GenerateNewNonOverlappingRectPositionForNewNode(newRect);
} else {
index = RenderedNodes.FindIndex(a => a.TestName == parentNode.TestName);
}
//Create new node, or find existing one, and draw lines between this node and the dependency.
List<KeyValuePair<DependencyNodeConnectionType,string>> LinkedNodeTestNames = RenderedNodes[index].Dependencies.ToList();
for(int s = 0; s < LinkedNodeTestNames.Count; s++) {
if(LinkedNodeTestNames[s].Key == DependencyNodeConnectionType.Incoming) {
string testName = LinkedNodeTestNames[s].Value;
DependencyNode thisNode = new DependencyNode();
int indexChild = 0;
List<DependencyNode> match = RenderedNodes.Where(x => x.TestName == testName).ToList();
if(!match.Any()) {
thisNode.TestName = testName;
thisNode.Dependencies = DependencyWebs.Where(x => x.TestName == thisNode.TestName).Select(x => x.Dependencies).Single();
RenderedNodes.Add(thisNode);
indexChild = RenderedNodes.Count - 1;
float width = DetermineRectWidthBasedOnLengthOfString(RenderedNodes[indexChild].TestName);
Rect newRect = RenderedNodes[all].rect;
newRect.width = width;
RenderedNodes[indexChild].rect = GenerateNewNonOverlappingRectPositionForNewNode(newRect);
} else {
indexChild = RenderedNodes.FindIndex(a => a.TestName == testName);
}
Handles.BeginGUI();
Handles.DrawBezier(RenderedNodes[index].rect.center, RenderedNodes[indexChild].rect.center, new Vector2(RenderedNodes[index].rect.xMax + 50f, RenderedNodes[index].rect.center.y), new Vector2(RenderedNodes[indexChild].rect.xMin - 50f, RenderedNodes[indexChild].rect.center.y), Color.cyan, null, 5f);
Handles.EndGUI();
}
}
}
GUIStyle f = new GUIStyle(EditorStyles.foldout);
f.richText = true;
//Render each node window object.
BeginWindows();
for(int i = 0; i < RenderedNodes.Count; i++) {
RenderedNodes[i].rect = GUI.Window(i, RenderedNodes[i].rect, WindowEvents, RenderedNodes[i].TestName);
}
EndWindows();
string nodeDetails = inspectedNodeWindow >= 0 ? GetNodeDetails(RenderedNodes[inspectedNodeWindow]) : GetNodeDetails(new DependencyNode());
float boxHeight = TestMonitorHelpers.DetermineRectHeightBasedOnLinesInNodeDetails(nodeDetails) + 50;
float boxWidth = longestTestNameInInfoBox > infoBoxMinWidth ? longestTestNameInInfoBox : infoBoxMinWidth;
bool overflowX = boxWidth > infoBoxMinWidth;
//Account for size of scroll bar in scrollable space
if(overflowX) {
boxHeight += 40;
}
float scrollViewHeight = boxHeight < position.height ? boxHeight : position.height;
bool overflowY = scrollViewHeight == position.height;
if(overflowY) {
boxWidth += 40;
}
GUI.EndScrollView();
GUIStyle verticalScrollBar = new GUIStyle(GUI.skin.verticalScrollbar);
GUIStyle horizontalScrollBar = overflowX ? new GUIStyle(GUI.skin.horizontalScrollbar) : GUIStyle.none;
infoBoxScroll = GUI.BeginScrollView(new Rect(position.width - infoBoxMinWidth, 0, infoBoxMinWidth, scrollViewHeight), infoBoxScroll, new Rect(new Vector2(position.width - (infoBoxMinWidth - 5), 4), new Vector2(boxWidth, boxHeight)), horizontalScrollBar, verticalScrollBar);
//Display selected node's details in details panel.
GUIStyle infoBox = new GUIStyle(GUI.skin.box);
infoBox.richText = true;
infoBox.normal.background = MakeTextureFromColor(new Color(0.175f, 0.175f, 0.175f, 1f));
infoBox.alignment = TextAnchor.UpperLeft;
GUI.Box(new Rect(new Vector2(position.width - (infoBoxMinWidth - 5), 4), new Vector2(boxWidth, boxHeight)), nodeDetails, infoBox);
lastRenderX = position.width + infoBoxMinWidth;
lastRenderY = position.height;
GUI.EndScrollView();
}
19
View Source File : VectorShapeEditor.cs
License : MIT License
Project Creator : ecurtz
License : MIT License
Project Creator : ecurtz
protected bool OnChangeScaleGUI(Event guiEvent)
{
BeginWindows();
Rect popupRect = new Rect((position.width - popupWidth) / 2f, 0f, popupWidth, popupHeight);
popupRect = GUI.Window(0, popupRect, OnScalePopup, GUIContent.none, GUI.skin.box);
EndWindows();
return ((guiEvent.type != EventType.Layout) && (guiEvent.type != EventType.Repaint));
}
19
View Source File : Gui.cs
License : The Unlicense
Project Creator : jrodrigv
License : The Unlicense
Project Creator : jrodrigv
private void OnGUI()
{
if (!PreSettings.ConfigLoaded) return;
if (GuiEnabled && _gameUiToggle)
_windowRect = GUI.Window(320, _windowRect, GuiWindow, "");
}
19
View Source File : DeveloperConsole.cs
License : MIT License
Project Creator : mustafayaya
License : MIT License
Project Creator : mustafayaya
void OnGUI()
{
if (_active)//If active, draw console window
{
GUI.depth = 1;
windowRect = GUI.Window(0, windowRect, ConsoleWindow, "Developer Console", skin.window);
}
else if (drawCloseButtonOnMobile)
{
#if UNITY_STANDALONE
#else
if (GUI.Button(new Rect(windowRect.width - 25, 7, 15, 5), "-", skin.GetStyle("exitButton")) )
{
_active = !_active;
}
#endif
}
}
19
View Source File : TestParticles.cs
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
void OnGUI () {
// Show version number
GUI.Window(1, new Rect((Screen.width-260), 5, 250, 80), InfoWindow, "Info");
// Show Help GUI window
GUI.Window(2, new Rect((Screen.width-260), Screen.height-85, 250, 80), ParticleInformationWindow, "Help");
}
19
View Source File : UI.cs
License : MIT License
Project Creator : phorcys
License : MIT License
Project Creator : phorcys
private void OnGUI()
{
if (display && Main.enabled)
{
DateFile tbl = DateFile.instance;
if (tbl == null || !GameData.Characters.HasChar(tbl.MianActorID()) || GetQuquWindow.instance == null || GetQuquWindow.instance.cricketDate.Count == 0)
{
return;
}
Rect rect = new Rect((Screen.width - window_width) / 2, (Screen.height - window_height) / 2, window_width, window_height);
GUI.Window(952, rect, WindowFunction, "XRay");
}
}
19
View Source File : GUIMain.cs
License : MIT License
Project Creator : PULSAR-Modders
License : MIT License
Project Creator : PULSAR-Modders
void OnGUI()
{
if (GUIActive)
{
GUI.skin = ChangeSkin();
Window = GUI.Window(999910, Window, WindowFunction, "ModManager");
}
}
19
View Source File : NodeVisual.cs
License : Apache License 2.0
Project Creator : QinZhuo
License : Apache License 2.0
Project Creator : QinZhuo
void LeftGroup(){
var leftRect=new Rect(0,0,position.width*midLinePos,position.height);
GUI.BeginGroup(leftRect);
if(backTex!=null){
var xTex=leftRect.width/backTex.width;
var yTex=leftRect.height/backTex.height;
var xStart=viewOffset.x.Fix(-backTex.width,0,backTex.width);
var yStart=viewOffset.y.Fix(-backTex.height,0,backTex.height);
for (int x = 0; x <= xTex+1; x++)
{
for (int y = 0; y <= yTex+1; y++)
{
GUI.DrawTexture (new Rect (xStart+backTex.width*x, yStart+backTex.height*y,backTex.width,backTex.height), backTex);
}
}
}else
{
//Debug.LogError("background.png is null");
backTex=Resources.Load<Texture2D>("background");
//backTex=Resources.Load<Texture2D>("background.png");
}
//遍历所有节点,移除无效节点
for (int i = nodeRootList.Count - 1; i >= 0; --i)
{
if (nodeRootList[i].isRelease)
{
nodeRootList.RemoveAt(i);
}
}
if (curEvent.button == 1) // 鼠标右键
{
if (curEvent.type == EventType.MouseDown)
{
if (!makeTransitionMode)
{
bool clickedOnNode = false;
selectNode = GetMouseInNode();
clickedOnNode = (selectNode != null);
if (!clickedOnNode)
{
ShowMenu(0);
}
else
{
ShowMenu(1);
}
}
}
}
// 选择节点为空时,无法连线
if (selectNode == null)
{
makeTransitionMode = false;
}
if (!makeTransitionMode)
{
if (curEvent.type == EventType.MouseUp)
{
selectNode = null;
}
}
// 在连线状态,按下鼠标
if (makeTransitionMode && curEvent.type == EventType.MouseDown)
{
NodeView<DataT> newSelectNode = GetMouseInNode();
// 如果按下鼠标时,选中了一个节点,则将 新选中根节点 添加为 selectNode 的子节点
if(newSelectNode==null){
}else
if (selectNode != newSelectNode)
{
selectNode.AddChild(newSelectNode);
}
// 取消连线状态
makeTransitionMode = false;
// 清空选择节点
selectNode = null;
}
// 连线状态下 选择节点不为空
if (makeTransitionMode && selectNode != null)
{
ViewTool.DrawCurve(selectNode.windowRect.GetPos(Dir.right), mousePos);
}
// 开始绘制节点
// 注意:必须在 BeginWindows(); 和 EndWindows(); 之间 调用 GUI.Window 才能显示
BeginWindows();
for (int i = 0; i < nodeRootList.Count; i++)
{
NodeView<DataT> nodeView = nodeRootList[i];
nodeView.windowRect = GUI.Window(i, nodeView.windowRect, DrawNodeWindow,"");
nodeView.DrawToChildCurve();
}
EndWindows();
if(curEvent.button==0){
if (curEvent.type == EventType.MouseDrag)
{
selectNode = GetMouseInNode();
if(selectNode==null){
viewOffset+= curEvent.delta;
}
}
}
GUI.EndGroup();
}
19
View Source File : HudWindow.cs
License : Apache License 2.0
Project Creator : Unity-Technologies
License : Apache License 2.0
Project Creator : Unity-Technologies
public void DrawWindow(HudPanel hud)
{
if (m_IsActive && m_GuiDrawer != null)
{
if (m_AutoLayout)
{
m_WindowRect = hud.GetFreeWindowRect();
m_AutoLayout = false;
}
GUI.Window(m_WindowID, m_WindowRect, DrawWindowContents, m_replacedle);
}
}
19
View Source File : SelectEnvToSpawn.cs
License : Apache License 2.0
Project Creator : Unity-Technologies
License : Apache License 2.0
Project Creator : Unity-Technologies
void OnGUI()
{
if (showPopUp)
{
int height = heightRequirments + 38;
int yPos = (Screen.height / 2) - (height / 2);
GUI.skin.window.fontSize = fontSize;
// GUI.skin.window.margin.top = fontSize;
GUI.Window(0, new Rect((Screen.width / 2) - 200, yPos
, 400, height), ShowGUI, "Select Environment");
}
}
19
View Source File : ConsoleWindow.cs
License : GNU General Public License v3.0
Project Creator : veesusmikelheir
License : GNU General Public License v3.0
Project Creator : veesusmikelheir
private void OnGUI()
{
Font font = GUI.skin.font;
GUI.skin.font = consoleFont;
// UNITY PREVENTS "GUI" STUFF FROM BEING CALLED OUTSIDE "OnGUI"
if (textArea == null) textArea = new GUIStyle(GUI.skin.label);
if (window == null) window = new GUIStyle(GUI.skin.window);
window.active.background = window.normal.background;
window.hover.background = window.normal.background;
window.focused.background = window.normal.background;
window.onActive.background = window.normal.background;
window.onHover.background = window.normal.background;
window.onFocused.background = window.normal.background;
// FORCES WINDOW TO CLOSE IF THE GAME IS LOADING
if (GameContext.Instance.AutoSaveDirector.IsLoadingGame() && showWindow)
{
SetWindowOff();
}
// LISTENS TO MAIN INPUT
if (Event.current.isKey && Event.current.type == EventType.KeyDown)
{
// TOGGLES THE WINDOW
if ((Event.current.modifiers == EventModifiers.Control || Event.current.modifiers == EventModifiers.Command) && Event.current.keyCode == KeyCode.Tab && !GameContext.Instance.AutoSaveDirector.IsLoadingGame())
{
ToggleWindow();
}
}
if (showWindow)
{
GUI.backgroundColor = new Color(0, 0, 0, 0.25f);
GUI.Window(1234567892, new Rect(-20, -20, Screen.width + 20, Screen.height + 20), (id) => { }, string.Empty, window);
GUI.BringWindowToBack(1234567892);
GUI.backgroundColor = Color.white;
GUI.Window(1234567890, windowRect, DrawWindow, string.Empty, window);
GUI.BringWindowToFront(1234567890);
GUI.FocusWindow(1234567890);
if (autoComplete)
{
completeRect.x = 4 + CursorX;
GUI.Window(1234567891, completeRect, DrawACWindow, acreplacedle, window);
GUI.BringWindowToFront(1234567891);
}
if (Event.current.isKey || Event.current.isMouse || Event.current.isScrollWheel)
{
Event.current.Use();
}
}
GUI.skin.font = font;
}
19
View Source File : ConsoleWindow.cs
License : GNU General Public License v3.0
Project Creator : veesusmikelheir
License : GNU General Public License v3.0
Project Creator : veesusmikelheir
private void OnGUI()
{
// UNITY PREVENTS "GUI" STUFF FROM BEING CALLED OUTSIDE "OnGUI"
if (textArea == null) textArea = new GUIStyle(GUI.skin.label);
if (window == null) window = new GUIStyle(GUI.skin.window);
window.active.background = window.normal.background;
window.hover.background = window.normal.background;
window.focused.background = window.normal.background;
window.onActive.background = window.normal.background;
window.onHover.background = window.normal.background;
window.onFocused.background = window.normal.background;
if (showWindow)
{
GUI.Window(1234567890, windowRect, DrawWindow, string.Empty, window);
GUI.BringWindowToFront(1234567890);
}
}