Here are the examples of the csharp api UnityEngine.GUI.Label(UnityEngine.Rect, UnityEngine.GUIContent, UnityEngine.GUIStyle) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
331 Examples
19
Source : NGUIEditorTools.cs
with Apache License 2.0
from 365082218
with Apache License 2.0
from 365082218
static public Rect DrawHeader (string text)
{
GUILayout.Space(28f);
Rect rect = GUILayoutUtility.GetLastRect();
rect.yMin += 5f;
rect.yMax -= 4f;
rect.width = Screen.width;
if (Event.current.type == EventType.Repaint)
{
GUI.color = Color.black;
GUI.DrawTexture(new Rect(0f, rect.yMin, Screen.width, rect.yMax - rect.yMin), gradientTexture);
GUI.color = new Color(0f, 0f, 0f, 0.25f);
GUI.DrawTexture(new Rect(0f, rect.yMin, Screen.width, 1f), blankTexture);
GUI.DrawTexture(new Rect(0f, rect.yMax - 1, Screen.width, 1f), blankTexture);
GUI.color = Color.white;
GUI.Label(new Rect(rect.x + 4f, rect.y, rect.width - 4, rect.height), text, EditorStyles.boldLabel);
}
return rect;
}
19
Source : PanelMain.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
protected internal override void Draw()
{
GUI.DrawTexture(urlRect, patreonIcon);
Vector2 position = Event.current.mousePosition;
if (urlRect.Contains(position))
{
GUI.Label(new Rect(position.x, position.y, 500f, 200f), locale["aottg2Message1"] + "\n" + locale["aottg2Message2"]);
}
if(UnityEngine.GUI.Button(urlRect, string.Empty, GUIStyle.none))
{
Application.OpenURL("https://www.patreon.com/aottg2");
}
enabledPanel = CheckActivePanel();
if (GUI.Button(profileRect, locale["profile"] + " <b>" + User.ProfileName + "</b>"))
{
CheckEnabled(AnarchyManager.ProfilePanel, new GUIBase[] { AnarchyManager.SinglePanel, AnarchyManager.ServerList, AnarchyManager.SettingsPanel });
}
rect.Reset();
if (Button("single"))
{
CheckEnabled(AnarchyManager.SinglePanel, new GUIBase[] { AnarchyManager.ProfilePanel, AnarchyManager.ServerList, AnarchyManager.SettingsPanel });
}
if (Button("multi"))
{
CheckEnabled(AnarchyManager.ServerList, new GUIBase[] { AnarchyManager.ProfilePanel, AnarchyManager.SinglePanel, AnarchyManager.SettingsPanel });
}
if (Button("settings"))
{
CheckEnabled(AnarchyManager.SettingsPanel, new GUIBase[] { AnarchyManager.ProfilePanel, AnarchyManager.ServerList, AnarchyManager.SinglePanel });
}
if (Button("custom_characters"))
{
if (enabledPanel < 0)
{
Application.LoadLevel("characterCreation");
return;
}
}
if(Button("snapshots"))
{
if(enabledPanel < 0)
{
Application.LoadLevel("SnapShot");
return;
}
}
if (Button("exit"))
{
Application.Quit();
}
}
19
Source : SettingsPanel.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static float BombStatSlider(SmartRect position, float value, string label, float offset, float step, float min, float max, bool move = true)
{
if (offset > 0f)
{
UnityEngine.GUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
value = UnityEngine.GUI.HorizontalSlider(position.ToRect(), value, min, max, Style.Slider, Style.SliderBody);
position.ResetX();
if (move)
{
position.MoveY();
}
if(step == 0.5f)
{
int low = Mathf.FloorToInt(value);
float diff = value - low;
if (diff >= 0.25f && diff < 0.75f)
{
return low + 0.5f;
}
else
{
return Mathf.RoundToInt(value);
}
}
else
{
return (int)value;
}
}
19
Source : Background.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
protected internal override void Draw()
{
if (movie != null)
{
UnityEngine.GUI.DrawTexture(screenRect, movie);
}
else
{
UnityEngine.GUI.DrawTexture(screenRect, texture);
}
UnityEngine.GUI.Label(screenRect, UIMainReferences.VersionShow, style);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static float HorizontalSlider(Rect position, float value, string label, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
return UGUI.HorizontalSlider(position, value, 0f, 1f, Style.Slider, Style.SliderBody);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static float HorizontalSlider(Rect position, float value, string label, float min, float max, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
return UGUI.HorizontalSlider(position, value, min, max, Style.Slider, Style.SliderBody);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void HorizontalSlider(Rect position, Setting<float> value, string label, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
value.Value = UGUI.HorizontalSlider(position, value.Value, 0f, 1f, Style.Slider, Style.SliderBody);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void HorizontalSlider(Rect position, Setting<float> value, string label, float min, float max, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
value.Value = UGUI.HorizontalSlider(position, value.Value, min, max, Style.Slider, Style.SliderBody);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static float HorizontalSlider(SmartRect position, float value, string label, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
value = UGUI.HorizontalSlider(position.ToRect(), value, 0f, 1f, Style.Slider, Style.SliderBody);
position.ResetX();
if (move)
{
position.MoveY();
}
return value;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static float HorizontalSlider(SmartRect position, float value, string label, float min, float max, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
value = UGUI.HorizontalSlider(position.ToRect(), value, min, max, Style.Slider, Style.SliderBody);
position.ResetX();
if (move)
{
position.MoveY();
}
return value;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void HorizontalSlider(SmartRect position, Setting<float> value, string label, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
value.Value = UGUI.HorizontalSlider(position.ToRect(), value.Value, 0f, 1f, Style.Slider, Style.SliderBody);
position.ResetX();
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void HorizontalSlider(SmartRect position, Setting<float> value, string label, float min, float max, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
value.Value = UGUI.HorizontalSlider(position.ToRect(), value.Value, min, max, Style.Slider, Style.SliderBody);
position.ResetX();
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Label(Rect position, string content)
{
UGUI.Label(position, content, Style.Label);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Label(SmartRect position, string content, bool move = false)
{
UGUI.Label(position.ToRect(), content, Style.Label);
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void LabelCenter(Rect position, string content)
{
UGUI.Label(position, content, Style.LabelCenter);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void LabelCenter(SmartRect position, string content, bool move = false)
{
UGUI.Label(position.ToRect(), content, Style.LabelCenter);
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static string TextField(Rect position, string value, string label, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
return UGUI.TextField(position, value, Style.TextField);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void TextField(Rect position, Setting<string> value, string label, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
value.Value = UGUI.TextField(position, value.Value, Style.TextField);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void TextField(Rect position, Setting<float> val, string label, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
if (!floats.ContainsKey(val))
{
floats.Add(val, val.Value.ToString());
}
string text = floats[val];
text = UGUI.TextField(position, text, Style.TextField);
float.TryParse(text, out val.Value);
floats[val] = text;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void TextField(Rect position, Setting<int> val, string label, float offset)
{
if (offset > 0f)
{
UGUI.Label(position, label, Style.Label);
position.x += offset;
position.width -= offset;
}
if (!integers.ContainsKey(val))
{
integers.Add(val, val.Value.ToString());
}
string text = integers[val];
text = UGUI.TextField(position, text, Style.TextField);
int.TryParse(text, out val.Value);
integers[val] = text;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static string TextField(SmartRect position, string value, string label, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
value = UGUI.TextField(position.ToRect(), value, Style.TextField);
position.ResetX();
if (move)
{
position.MoveY();
}
return value;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void TextField(SmartRect position, Setting<string> value, string label, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
value.Value = UGUI.TextField(position.ToRect(), value.Value, Style.TextField);
position.ResetX();
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void TextField(SmartRect position, Setting<float> val, string label, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
if (!floats.ContainsKey(val))
{
floats.Add(val, val.Value.ToString());
}
string text = floats[val];
text = UGUI.TextField(position.ToRect(), text, Style.TextField);
float.TryParse(text, out val.Value);
floats[val] = text;
position.ResetX();
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void TextField(SmartRect position, Setting<int> val, string label, float offset, bool move = false)
{
if (offset > 0f)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(offset);
}
if (!integers.ContainsKey(val))
{
integers.Add(val, val.Value.ToString());
}
string text = integers[val];
text = UGUI.TextField(position.ToRect(), text, Style.TextField);
int.TryParse(text, out val.Value);
integers[val] = text;
position.ResetX();
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool Toggle(Rect position, bool val, string label)
{
UGUI.Label(position, label, Style.Label);
return UGUI.Toggle(new Rect(position.x + position.width - Style.Height, position.y, Style.Height, Style.Height), val, string.Empty, Style.Toggle);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Toggle(Rect position, Setting<bool> val, string label)
{
UGUI.Label(position, label, Style.Label);
val.Value = UGUI.Toggle(new Rect(position.x + position.width - Style.Height, position.y, Style.Height, Style.Height), val.Value, string.Empty, Style.Toggle);
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool Toggle(SmartRect position, bool val, string label, bool move = false)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(position.width - Style.Height);
val = UGUI.Toggle(position.ToRect(), val, string.Empty, Style.Toggle);
position.ResetX();
if (move)
{
position.MoveY();
}
return val;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Toggle(SmartRect position, Setting<bool> val, string label, float offset, bool move = false)
{
UGUI.Label(position.ToRect(), label, Style.Label);
position.MoveOffsetX(position.width - Style.Height);
val.Value = UGUI.Toggle(position.ToRect(), val.Value, string.Empty, Style.Toggle);
position.ResetX();
if (move)
{
position.MoveY();
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool ToggleButton(Rect position, bool val, string label)
{
UGUI.Label(position, label, Style.Label);
if (UGUI.Button(position, val ? LabelEnabled : LabelDisabled, Style.TextButton))
{
return !val;
}
return val;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void ToggleButton(Rect position, Setting<bool> val, string label)
{
UGUI.Label(position, label, Style.Label);
if (UGUI.Button(position, val.Value ? LabelEnabled : LabelDisabled, Style.TextButton))
{
val.Value = !val.Value;
}
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static bool ToggleButton(SmartRect position, bool val, string label, bool move = false)
{
UGUI.Label(position.ToRect(), label, Style.Label);
if (UGUI.Button(position.ToRect(), val ? LabelEnabled : LabelDisabled, Style.TextButton))
{
val = !val;
}
if (move)
{
position.MoveY();
}
return val;
}
19
Source : GUI.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void ToggleButton(SmartRect position, Setting<bool> val, string label, bool move = false)
{
UGUI.Label(position.ToRect(), label, Style.Label);
if (UGUI.Button(position.ToRect(), val.Value ? LabelEnabled : LabelDisabled, Style.TextButton))
{
val.Value = !val.Value;
}
if (move)
{
position.MoveY();
}
}
19
Source : ConsoleWindow.cs
with MIT License
from akof1314
with MIT License
from akof1314
void OnGUI()
{
Event e = Event.current;
LoadIcons();
LogEntries.wrapped.UpdateEntries();
if (!m_HasUpdatedGuiStyles)
{
m_LineHeight = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight);
m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom;
UpdateListView();
}
GUILayout.BeginHorizontal(Constants.Toolbar);
if (LogEntries.wrapped.imporreplacedching)
{
LogEntries.wrapped.imporreplacedching = GUILayout.Toggle(LogEntries.wrapped.imporreplacedching, Constants.ImporreplacedchingLabel, Constants.MiniButton);
}
if (GUILayout.Button(Constants.ClearLabel, Constants.MiniButton))
{
LogEntries.Clear();
GUIUtility.keyboardControl = 0;
}
int currCount = LogEntries.wrapped.GetCount();
if (m_ListView.totalRows != currCount && m_ListView.totalRows > 0)
{
// scroll bar was at the bottom?
if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
{
m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight;
}
}
if (LogEntries.wrapped.searchFrame)
{
LogEntries.wrapped.searchFrame = false;
int selectedIndex = LogEntries.wrapped.GetSelectedEntryIndex();
if (selectedIndex != -1)
{
int showIndex = selectedIndex + 1;
if (currCount > showIndex)
{
int showCount = ms_LVHeight / RowHeight;
showIndex = showIndex + showCount / 2;
}
m_ListView.scrollPos.y = showIndex * RowHeight - ms_LVHeight;
}
}
EditorGUILayout.Space();
bool wasCollapsed = LogEntries.wrapped.collapse;
LogEntries.wrapped.collapse = GUILayout.Toggle(wasCollapsed, Constants.CollapseLabel, Constants.MiniButton);
bool collapsedChanged = (wasCollapsed != LogEntries.wrapped.collapse);
if (collapsedChanged)
{
// unselect if collapsed flag changed
m_ListView.row = -1;
// scroll to bottom
m_ListView.scrollPos.y = LogEntries.wrapped.GetCount() * RowHeight;
}
SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton));
#if UNITY_2019_1_OR_NEWER
SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton));
#endif
SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton));
#if UNITY_2018_3_OR_NEWER
ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown);
#endif
EditorGUILayout.Space();
if (m_DevBuild)
{
GUILayout.FlexibleSpace();
SetFlag(ConsoleFlags.StopForreplacedert, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForreplacedert), Constants.StopForreplacedertLabel, Constants.MiniButton));
SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForError), Constants.StopForErrorLabel, Constants.MiniButton));
}
GUILayout.FlexibleSpace();
// Search bar
GUILayout.Space(4f);
SearchField(e);
int errorCount = 0, warningCount = 0, logCount = 0;
LogEntries.wrapped.GetCountsByType(ref errorCount, ref warningCount, ref logCount);
EditorGUI.BeginChangeCheck();
bool setLogFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton);
bool setWarningFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton);
bool setErrorFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButton);
// Active entry index may no longer be valid
if (EditorGUI.EndChangeCheck())
{ }
LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelLog, setLogFlag);
LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelWarning, setWarningFlag);
LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelError, setErrorFlag);
if (GUILayout.Button(new GUIContent(errorCount > 0 ? iconFirstErrorSmall : iconFirstErrorMono, Constants.FirstErrorLabel), Constants.MiniButton))
{
int firstErrorIndex = LogEntries.wrapped.GetFirstErrorEntryIndex();
if (firstErrorIndex != -1)
{
SetActiveEntry(firstErrorIndex);
LogEntries.wrapped.searchFrame = true;
}
}
GUILayout.EndHorizontal();
SplitterGUILayout.BeginVerticalSplit(spl);
int rowHeight = RowHeight;
EditorGUIUtility.SetIconSize(new Vector2(rowHeight, rowHeight));
GUIContent tempContent = new GUIContent();
int id = GUIUtility.GetControlID(0);
int rowDoubleClicked = -1;
/////@TODO: Make Frame selected work with ListViewState
using (new GettingLogEntriesScope(m_ListView))
{
int selectedRow = -1;
bool openSelectedItem = false;
bool collapsed = LogEntries.wrapped.collapse;
foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, Constants.Box))
{
if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition))
{
m_ListView.row = el.row;
selectedRow = el.row;
if (e.clickCount == 2)
openSelectedItem = true;
}
else if (e.type == EventType.Repaint)
{
int mode = 0;
int entryCount = 0;
int searchIndex = 0;
int searchEndIndex = 0;
string text = LogEntries.wrapped.GetEntryLinesAndFlagAndCount(el.row, ref mode, ref entryCount,
ref searchIndex, ref searchEndIndex);
ConsoleFlags flag = (ConsoleFlags)mode;
bool isSelected = LogEntries.wrapped.IsEntrySelected(el.row);
// Draw the background
GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground;
s.Draw(el.position, false, false, isSelected, false);
// Draw the icon
#if !UNITY_2017_3_OR_NEWER
if (Constants.LogStyleLineCount == 1)
{
Rect rt = el.position;
rt.x += 6f;
rt.y += 2f;
rt.width = 16f;
rt.height = 16f;
GUI.DrawTexture(rt, GetIconForErrorMode(flag, false));
}
else
#endif
{
GUIStyle iconStyle = GetStyleForErrorMode(flag, true, Constants.LogStyleLineCount == 1);
iconStyle.Draw(el.position, false, false, isSelected, false);
}
// Draw the text
tempContent.text = text;
GUIStyle errorModeStyle = GetStyleForErrorMode(flag, false, Constants.LogStyleLineCount == 1);
if (string.IsNullOrEmpty(LogEntries.wrapped.searchString) || searchIndex == -1 || searchIndex >= text.Length)
{
errorModeStyle.Draw(el.position, tempContent, id, isSelected);
}
else
{
errorModeStyle.DrawWithTextSelection(el.position, tempContent, GUIUtility.keyboardControl, searchIndex, searchEndIndex);
}
if (collapsed)
{
Rect badgeRect = el.position;
tempContent.text = entryCount.ToString(CultureInfo.InvariantCulture);
Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent);
badgeRect.xMin = badgeRect.xMax - badgeSize.x;
badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f;
badgeRect.x -= 5f;
GUI.Label(badgeRect, tempContent, Constants.CountBadge);
}
}
}
if (selectedRow != -1)
{
if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1;
}
// Make sure the selected entry is up to date
if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0)
{
}
else
{
if (m_ListView.selectionChanged)
{
SetActiveEntry(m_ListView.row);
}
}
// Open entry using return key
if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0))
{
selectedRow = m_ListView.row;
openSelectedItem = true;
}
if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1)
ms_LVHeight = ListViewGUI.ilvState.rectHeight;
if (openSelectedItem)
{
rowDoubleClicked = selectedRow;
e.Use();
}
if (selectedRow != -1)
{
SetActiveEntry(selectedRow);
}
}
// Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been
// called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060.
if (rowDoubleClicked != -1)
LogEntries.wrapped.StacktraceListView_RowGotDoubleClicked();
EditorGUIUtility.SetIconSize(Vector2.zero);
StacktraceListView(e, tempContent);
SplitterGUILayout.EndVerticalSplit();
// Copy & Paste selected item
if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == "Copy")
{
if (e.type == EventType.ExecuteCommand)
LogEntries.wrapped.StacktraceListView_CopyAll();
e.Use();
}
}
19
Source : ResourceExporter.cs
with MIT License
from Albeoris
with MIT License
from Albeoris
public void OnGUI()
{
GUI.skin.box.normal.background = _blackTexture;
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), GUIContent.none);
Single progress = (100.0f * _currentIndex) / _totalCount;
GUI.Label(new Rect(0, 0, Screen.width, Screen.height), $"Exporting ({progress:F2}%): {_currentIndex} / {_totalCount}", _guiStyle);
}
19
Source : GUIWindow.cs
with GNU General Public License v3.0
from AndrasMumm
with GNU General Public License v3.0
from AndrasMumm
public void Label(string text)
{
GUI.Label(NextControlRect(), text);
}
19
Source : ClearanceVisualizer.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void OnGUI()
{
if (Camera.current == null || !Application.isPlaying)
{
return;
}
if (_style == null)
{
_style = new GUIStyle(GUI.skin.label)
{
fontSize = this.fontSize
};
}
var grids = FindObjectsOfType<GridComponent>();
if (grids != null)
{
foreach (var gridComp in grids)
{
var grid = gridComp.grid;
if (grid == null)
{
continue;
}
var matrix = grid.cellMatrix;
for (int x = 0; x < grid.sizeX; x++)
{
for (int z = 0; z < grid.sizeZ; z++)
{
var c = matrix[x, z] as IHaveClearance;
if (c == null || c.clearance <= 0f)
{
continue;
}
Vector3 pos = Camera.current.WorldToScreenPoint(matrix[x, z].position);
pos.y = Screen.height - pos.y;
GUI.color = this.textColor;
GUI.Label(new Rect(pos.x - 5f, pos.y - 10f, 50f, 20f), c.clearance.ToString(), _style);
}
}
}
}
}
19
Source : ListFieldBase.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private Rect DrawDragHandle()
{
var rect = GUILayoutUtility.GetLastRect();
var handleRect = new Rect(rect.x + _dragHandlePaddingX, rect.y + _dragHandlePaddingY, _dragHandleWidth, _dragHandleHeight);
GUI.Label(handleRect, new GUIContent(UIResources.InspectorDragHandle.texture), EditorStyling.Canvas.smallButtonIcon);
EditorGUIUtility.AddCursorRect(handleRect, MouseCursor.MoveArrow);
return handleRect;
}
19
Source : AIInspectorEditor.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void DrawLinkUI(AILinkView linkView)
{
HeaderHandler headerRects;
if (EditorApplication.isPlaying)
{
headerRects = HeaderHandler.GetHeaderRects(0);
}
else
{
headerRects = HeaderHandler.GetHeaderRects(2);
if (GUI.Button(headerRects.Next, SharedStyles.deleteTooltip, SharedStyles.BuiltIn.deleteButtonSmall))
{
GUI.changed = false;
_state.currentAIUI.RemoveSelected();
return;
}
if (GUI.Button(headerRects.Next, EditorStyling.changeTypeTooltip, SharedStyles.BuiltIn.changeButtonSmall))
{
ShowChangeLinkMenu(linkView);
}
}
GUI.Label(headerRects.Next, "AI Link | APEX AI", EditorStyling.Skinned.inspectorreplacedle);
EditorGUILayout.Separator();
DrawViewSharedUI(linkView);
}
19
Source : PathFinderVisualizer.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void OnGUI()
{
if (_styles == null)
{
_styles = new Styles();
}
if (costInfo != CostDiplay.None)
{
if (Camera.main == null)
{
return;
}
var nodes = _engine.expandedSet;
for (int i = 0; i < nodes.Count; i++)
{
var n = nodes[i];
if ((n == null) || (n is PortalCell))
{
continue;
}
int cost;
switch (costInfo)
{
case CostDiplay.MoveCost:
{
cost = n.g;
break;
}
case CostDiplay.Heuristics:
{
cost = n.h;
break;
}
default:
{
cost = n.f;
break;
}
}
var pos = Camera.main.WorldToScreenPoint(n.position);
pos.y = Screen.height - pos.y;
GUI.color = Color.black;
GUI.Label(new Rect(pos.x - 10f, pos.y - 6f, 50f, 20f), cost.ToString());
}
}
if (showInstructions)
{
float width = 300f;
float height = Screen.height * 0.9f;
GUILayout.BeginArea(new Rect(5f, (Screen.height / 2f) - (height / 2f), width, height), GUI.skin.window);
GUILayout.BeginVertical();
GUILayout.Label("Path Finder Visualization", _styles.headerStyle);
GUILayout.Label("Blue Squares represent the node being processed.");
GUILayout.Label("Yellow Squares represent the nodes that have been processed (closed).");
GUILayout.Label("Green Squares represent expanded nodes yet to be processed.");
GUILayout.Label("Purple Squares represent nodes from which a portal is crossed.");
GUILayout.Label("\nLeft click to set the Starting Point.\n\nRight click to set the End Point.\n\nPress 'Space' to visualize.\n\nPress 'R' to reset.");
GUILayout.EndVertical();
GUILayout.EndArea();
}
}
19
Source : PickupMaster.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void OnGUI()
{
GUI.Label(new Rect(10, 10, 150, 120), "Press Q to spawn a crate at the mouse position.\n\nPress W to spawn a worker at the mouse position.");
}
19
Source : AIInspectorEditor.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void DrawSelectorUI(SelectorView selectorView)
{
var isRoot = selectorView.isRoot;
HeaderHandler headerRects;
if (EditorApplication.isPlaying)
{
headerRects = HeaderHandler.GetHeaderRects(0);
}
else
{
if (isRoot)
{
headerRects = HeaderHandler.GetHeaderRects(1);
}
else
{
headerRects = HeaderHandler.GetHeaderRects(3);
if (GUI.Button(headerRects.Next, SharedStyles.deleteTooltip, SharedStyles.BuiltIn.deleteButtonSmall))
{
GUI.changed = false;
_state.currentAIUI.RemoveSelected();
return;
}
if (GUI.Button(headerRects.Next, EditorStyling.setRootTooltip, EditorStyling.Skinned.setRootButtonSmall))
{
_state.currentAIUI.SetRoot(selectorView.selector);
}
}
if (GUI.Button(headerRects.Next, EditorStyling.changeTypeTooltip, SharedStyles.BuiltIn.changeButtonSmall))
{
ShowChangeTypeMenu(selectorView.selector, (newSelector) => _state.currentAIUI.ReplaceSelector(selectorView, newSelector));
}
}
GUI.Label(headerRects.Next, string.Concat(_state.editedItem.name, (isRoot ? " (ROOT) " : string.Empty), " | APEX AI"), EditorStyling.Skinned.inspectorreplacedle);
EditorGUILayout.Separator();
DrawViewSharedUI(selectorView);
EditorGUILayout.Separator();
_state.editedItem.Render(_state);
}
19
Source : AIInspectorEditor.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void DrawQualifierUI(QualifierView qualifierView)
{
HeaderHandler headerRects;
if (EditorApplication.isPlaying || qualifierView.isDefault)
{
headerRects = HeaderHandler.GetHeaderRects(0);
}
else
{
headerRects = HeaderHandler.GetHeaderRects(2);
if (GUI.Button(headerRects.Next, SharedStyles.deleteTooltip, SharedStyles.BuiltIn.deleteButtonSmall))
{
GUI.changed = false;
_state.currentAIUI.RemoveSelected();
return;
}
if (GUI.Button(headerRects.Next, EditorStyling.changeTypeTooltip, SharedStyles.BuiltIn.changeButtonSmall))
{
ShowChangeTypeMenu(qualifierView.qualifier, (newQualifier) => _state.currentAIUI.ReplaceQualifier(qualifierView, newQualifier));
}
}
if (qualifierView.isDefault)
{
GUI.Label(headerRects.Next, string.Concat(_state.editedItem.name, " | APEX AI"), EditorStyling.Skinned.inspectorreplacedle);
}
else
{
var cbd = qualifierView.qualifier;
var isDisabled = !EditorGUI.ToggleLeft(headerRects.Next, string.Concat(_state.editedItem.name, " | APEX AI"), !cbd.isDisabled, EditorStyling.Skinned.inspectorreplacedle);
if (isDisabled != cbd.isDisabled)
{
cbd.isDisabled = isDisabled;
_state.currentAIUI.undoRedo.Do(new DisableOperation(cbd));
}
}
EditorGUILayout.Separator();
DrawViewSharedUI(qualifierView);
EditorGUILayout.Separator();
_state.editedItem.Render(_state);
}
19
Source : Vector4Field.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
public sealed override void RenderField(AIInspectorState state)
{
// solution found in EditorGUILayout.Vector4Field in UnityEditor namespace (decompiled)
var controlRect = EditorGUILayout.GetControlRect(true, 32f, EditorStyles.numberField);
_vector4Arr[0] = _curValue.x;
_vector4Arr[1] = _curValue.y;
_vector4Arr[2] = _curValue.z;
_vector4Arr[3] = _curValue.w;
controlRect.height = 16f;
GUI.Label(EditorGUI.IndentedRect(controlRect), _label, EditorStyles.label);
controlRect.y += 16f;
EditorGUI.BeginChangeCheck();
EditorGUI.indentLevel += 1;
EditorGUI.MultiFloatField(controlRect, _labelsArr, _vector4Arr);
EditorGUI.indentLevel -= 1;
if (EditorGUI.EndChangeCheck())
{
_curValue.x = _vector4Arr[0];
_curValue.y = _vector4Arr[1];
_curValue.z = _vector4Arr[2];
_curValue.w = _vector4Arr[3];
UpdateValue(_curValue, state);
}
}
19
Source : AIInspectorEditor.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void DrawActionUI(ActionView actionView)
{
HeaderHandler headerRects;
if (EditorApplication.isPlaying)
{
headerRects = HeaderHandler.GetHeaderRects(0);
}
else
{
headerRects = HeaderHandler.GetHeaderRects(2);
if (GUI.Button(headerRects.Next, SharedStyles.deleteTooltip, SharedStyles.BuiltIn.deleteButtonSmall))
{
GUI.changed = false;
_state.currentAIUI.RemoveSelected();
return;
}
if (GUI.Button(headerRects.Next, EditorStyling.changeTypeTooltip, SharedStyles.BuiltIn.changeButtonSmall))
{
ShowChangeTypeMenu(actionView.action, (newAction) => _state.currentAIUI.ReplaceAction(actionView.parent, newAction));
}
}
GUI.Label(headerRects.Next, string.Concat(_state.editedItem.name, " | APEX AI"), EditorStyling.Skinned.inspectorreplacedle);
EditorGUILayout.Separator();
DrawViewSharedUI(actionView);
EditorGUILayout.Separator();
_state.editedItem.Render(_state);
}
19
Source : AIInspectorEditor.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
private void DrawAIUI(AIUI aiui)
{
HeaderHandler headerRects;
if (EditorApplication.isPlaying)
{
headerRects = HeaderHandler.GetHeaderRects(0);
}
else
{
headerRects = HeaderHandler.GetHeaderRects(1);
if (GUI.Button(headerRects.Next, SharedStyles.deleteTooltip, SharedStyles.BuiltIn.deleteButtonSmall))
{
GUI.changed = false;
if (DisplayHelper.ConfirmDelete("AI", true))
{
AIEditorWindow.activeInstance.DeleteAI();
return;
}
}
}
GUI.Label(headerRects.Next, string.Concat(_state.currentAIUI.name, " | APEX AI"), EditorStyling.Skinned.inspectorreplacedle);
}
19
Source : RuleTileEditor.cs
with MIT License
from Aroueterra
with MIT License
from Aroueterra
private void OnDrawHeader(Rect rect)
{
GUI.Label(rect, "Tiling Rules");
}
19
Source : RuleTileEditor.cs
with MIT License
from Aroueterra
with MIT License
from Aroueterra
private static void RuleInspectorOnGUI(Rect rect, RuleTile.TilingRule tilingRule)
{
float y = rect.yMin;
EditorGUI.BeginChangeCheck();
GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Rule");
tilingRule.m_RuleTransform = (RuleTile.TilingRule.Transform)EditorGUI.EnumPopup(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_RuleTransform);
y += k_SingleLineHeight;
GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Collider");
tilingRule.m_ColliderType = (Tile.ColliderType)EditorGUI.EnumPopup(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_ColliderType);
y += k_SingleLineHeight;
GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Output");
tilingRule.m_Output = (RuleTile.TilingRule.OutputSprite)EditorGUI.EnumPopup(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_Output);
y += k_SingleLineHeight;
if (tilingRule.m_Output == RuleTile.TilingRule.OutputSprite.Animation)
{
GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Speed");
tilingRule.m_AnimationSpeed = EditorGUI.FloatField(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_AnimationSpeed);
y += k_SingleLineHeight;
}
if (tilingRule.m_Output == RuleTile.TilingRule.OutputSprite.Random)
{
GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Noise");
tilingRule.m_PerlinScale = EditorGUI.Slider(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_PerlinScale, 0.001f, 0.999f);
y += k_SingleLineHeight;
GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Shuffle");
tilingRule.m_RandomTransform = (RuleTile.TilingRule.Transform)EditorGUI.EnumPopup(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_RandomTransform);
y += k_SingleLineHeight;
}
if (tilingRule.m_Output != RuleTile.TilingRule.OutputSprite.Single)
{
GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Size");
EditorGUI.BeginChangeCheck();
int newLength = EditorGUI.DelayedIntField(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_Sprites.Length);
if (EditorGUI.EndChangeCheck())
Array.Resize(ref tilingRule.m_Sprites, Math.Max(newLength, 1));
y += k_SingleLineHeight;
for (int i = 0; i < tilingRule.m_Sprites.Length; i++)
{
tilingRule.m_Sprites[i] = EditorGUI.ObjectField(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), tilingRule.m_Sprites[i], typeof(Sprite), false) as Sprite;
y += k_SingleLineHeight;
}
}
}
19
Source : DefaultInitializationErrorHandler.cs
with GNU General Public License v3.0
from ARPOISE
with GNU General Public License v3.0
from ARPOISE
void DrawWindowContent(int id)
{
var headerRect = new Rect(0, 0, Screen.width, Screen.height / 8);
var bodyRect = new Rect(0, Screen.height / 8, Screen.width, Screen.height / 8 * 6);
var footerRect = new Rect(0, Screen.height - Screen.height / 8, Screen.width, Screen.height / 8);
GUI.Label(headerRect, headerLabel, headerStyle);
GUI.Label(bodyRect, mErrorText, bodyStyle);
if (GUI.Button(footerRect, "Close", footerStyle))
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
19
Source : PointCloudIdsExample.cs
with GNU General Public License v3.0
from ARPOISE
with GNU General Public License v3.0
from ARPOISE
void OnGUI()
{
int seenThisFrame = (m_PointCloudIdentifiers != null) ? m_PointCloudIdentifiers.Length : 0;
string formattedMessage = String.Format("{0} new/ {1} frame/ {2} seen", seenThisFrame-m_ExistingIdsSeen, seenThisFrame, m_IdentifiersSeenSoFar.Count );
GUI.Label(new Rect(100, 100, 200, 40), formattedMessage);
}
19
Source : FpsCounter.cs
with MIT License
from Arvtesh
with MIT License
from Arvtesh
public static void RenderFps(float fps, string s, Rect rc)
{
var text = string.Format("{0}: {1:F2}", s, fps);
if (fps < 10)
{
GUI.color = Color.red;
}
else if (fps < 30)
{
GUI.color = Color.yellow;
}
else
{
GUI.color = Color.green;
}
GUI.Label(rc, text);
}
See More Examples