Here are the examples of the csharp api UnityEngine.GUILayout.Space(float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1005 Examples
19
View Source File : LuaConsole.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void OnGUI()
{
if (!initedStyle)
{
GUIStyle entryInfoTyle = "CN EntryInfo";
textAreaStyle.richText = true;
textAreaStyle.normal.textColor = entryInfoTyle.normal.textColor;
initedStyle = true;
}
string[] statehints = new string[LuaState.statemap.Count];
LuaState[] states = new LuaState[LuaState.statemap.Count];
int n = 0;
foreach(var k in LuaState.statemap.Values) {
states[n] = k;
statehints[n++] = k.Name;
}
stateIndex = EditorGUILayout.Popup(stateIndex,statehints);
LuaState l = null;
if (stateIndex >= 0 && stateIndex <states.Length)
l = states[stateIndex];
if (current != null && current != l)
{
current.logDelegate -= AddLog;
current.errorDelegate -= AddError;
}
if(current!=l && l!=null) {
l.logDelegate += AddLog;
l.errorDelegate += AddError;
current = l;
}
//Output Text Area
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.ExpandHeight(true));
EditorGUILayout.TextArea(outputText, textAreaStyle, GUILayout.ExpandHeight(true));
GUILayout.EndScrollView();
//Filter Option Toggles
GUILayout.BeginHorizontal();
bool oldToggleLog = toggleLog;
bool oldToggleErr = toggleErr;
toggleLog = GUILayout.Toggle(oldToggleLog, "log", GUILayout.ExpandWidth(false));
toggleErr = GUILayout.Toggle(oldToggleErr, "error", GUILayout.ExpandWidth(false));
//Filter Input Field
GUILayout.Space(10f);
GUILayout.Label("filter:", GUILayout.ExpandWidth(false));
string oldFilterPattern = filterText;
filterText = GUILayout.TextField(oldFilterPattern, GUILayout.Width(200f));
//Menu Buttons
if (GUILayout.Button("clear", GUILayout.ExpandWidth(false)))
{
recordList.Clear();
ConsoleFlush();
}
GUILayout.EndHorizontal();
if (toggleLog != oldToggleLog || toggleErr != oldToggleErr || filterText != oldFilterPattern)
{
ConsoleFlush();
}
if (Event.current.type == EventType.Repaint)
{
inputAreaPosY = GUILayoutUtility.GetLastRect().yMax;
}
//Drag Spliter
ResizeScrollView();
//Input Area
GUI.SetNextControlName("Input");
inputText = EditorGUILayout.TextField(inputText, GUILayout.Height(inputAreaHeight));
if (Event.current.isKey && Event.current.type == EventType.KeyUp)
{
bool refresh = false;
if (Event.current.keyCode == KeyCode.Return)
{
if (inputText != "")
{
if (history.Count == 0 || history[history.Count - 1] != inputText)
{
history.Add(inputText);
}
AddLog(inputText);
DoCommand(inputText);
inputText = "";
refresh = true;
historyIndex = history.Count;
}
}
else if (Event.current.keyCode == KeyCode.UpArrow)
{
if (history.Count > 0)
{
historyIndex = historyIndex - 1;
if (historyIndex < 0)
{
historyIndex = 0;
}
else
{
inputText = history[historyIndex];
refresh = true;
}
}
}
else if (Event.current.keyCode == KeyCode.DownArrow)
{
if (history.Count > 0)
{
historyIndex = historyIndex + 1;
if (historyIndex > history.Count - 1)
{
historyIndex = history.Count - 1;
}
else
{
inputText = history[historyIndex];
refresh = true;
}
}
}
if (refresh)
{
Repaint();
EditorGUIUtility.editingTextField = false;
GUI.FocusControl("Input");
}
}
}
19
View Source File : LuaConsole.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void ResizeScrollView()
{
Rect dragSpliterRect = new Rect(0f, inputAreaPosY + 2, Screen.width, 2);
EditorGUI.DrawRect(dragSpliterRect, Color.black);
EditorGUIUtility.AddCursorRect(dragSpliterRect, MouseCursor.ResizeVertical);
GUILayout.Space(4);
Event e = Event.current;
#if UNITY_2017_3_OR_NEWER
if (e.type == EventType.MouseDown && dragSpliterRect.Contains(e.mousePosition))
#else
if (e.type == EventType.mouseDown && dragSpliterRect.Contains(e.mousePosition))
#endif
{
e.Use();
inputAreaResizing = true;
}
if (e.type == EventType.MouseDrag)
{
if (inputAreaResizing)
{
e.Use();
inputAreaHeight -= Event.current.delta.y;
inputAreaHeight = Mathf.Max(inputAreaHeight, 20f);
}
}
if (e.type == EventType.MouseUp)
inputAreaResizing = false;
}
19
View Source File : ComponentSelector.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
static public void Draw<T> (string buttonName, T obj, OnSelectionCallback cb, params GUILayoutOption[] options) where T : MonoBehaviour
{
GUILayout.BeginHorizontal();
bool show = GUILayout.Button(buttonName, "DropDownButton", GUILayout.Width(76f));
#if !UNITY_3_4
GUILayout.BeginVertical();
GUILayout.Space(5f);
#endif
T o = EditorGUILayout.ObjectField(obj, typeof(T), false, options) as T;
#if !UNITY_3_4
GUILayout.EndVertical();
#endif
if (o != null && Selection.activeObject != o.gameObject && GUILayout.Button("Edit", GUILayout.Width(40f)))
{
Selection.activeObject = o.gameObject;
}
GUILayout.EndHorizontal();
if (show) Show<T>(cb);
else if (o != obj) cb(o);
}
19
View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
static public Rect DrawBackground (Texture2D tex, float ratio)
{
Rect rect = GUILayoutUtility.GetRect(0f, 0f);
rect.width = Screen.width - rect.xMin;
rect.height = rect.width * ratio;
GUILayout.Space(rect.height);
if (Event.current.type == EventType.Repaint)
{
Texture2D blank = blankTexture;
Texture2D check = backdropTexture;
// Lines above and below the texture rectangle
GUI.color = new Color(0f, 0f, 0f, 0.2f);
GUI.DrawTexture(new Rect(rect.xMin, rect.yMin - 1, rect.width, 1f), blank);
GUI.DrawTexture(new Rect(rect.xMin, rect.yMax, rect.width, 1f), blank);
GUI.color = Color.white;
// Checker background
DrawTiledTexture(rect, check);
}
return rect;
}
19
View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
static public void DrawSeparator ()
{
GUILayout.Space(12f);
if (Event.current.type == EventType.Repaint)
{
Texture2D tex = blankTexture;
Rect rect = GUILayoutUtility.GetLastRect();
GUI.color = new Color(0f, 0f, 0f, 0.25f);
GUI.DrawTexture(new Rect(0f, rect.yMin + 6f, Screen.width, 4f), tex);
GUI.DrawTexture(new Rect(0f, rect.yMin + 6f, Screen.width, 1f), tex);
GUI.DrawTexture(new Rect(0f, rect.yMin + 9f, Screen.width, 1f), tex);
GUI.color = Color.white;
}
}
19
View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 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
View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
static public void HighlightLine (Color c)
{
Rect rect = GUILayoutUtility.GetRect(Screen.width - 16f, 22f);
GUILayout.Space(-23f);
c.a *= 0.3f;
GUI.color = c;
GUI.DrawTexture(rect, gradientTexture);
c.r *= 0.5f;
c.g *= 0.5f;
c.b *= 0.5f;
GUI.color = c;
GUI.DrawTexture(new Rect(rect.x, rect.y + 1f, rect.width, 1f), blankTexture);
GUI.DrawTexture(new Rect(rect.x, rect.y + rect.height - 1f, rect.width, 1f), blankTexture);
GUI.color = Color.white;
}
19
View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
static public IntVector IntPair (string prefix, string leftCaption, string rightCaption, int x, int y)
{
GUILayout.BeginHorizontal();
if (string.IsNullOrEmpty(prefix))
{
GUILayout.Space(82f);
}
else
{
GUILayout.Label(prefix, GUILayout.Width(74f));
}
EditorGUIUtility.LookLikeControls(48f);
IntVector retVal;
retVal.x = EditorGUILayout.IntField(leftCaption, x, GUILayout.MinWidth(30f));
retVal.y = EditorGUILayout.IntField(rightCaption, y, GUILayout.MinWidth(30f));
EditorGUIUtility.LookLikeControls(80f);
GUILayout.EndHorizontal();
return retVal;
}
19
View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
static public void SpriteField (string fieldName, string caption, UIAtlas atlas, string spriteName, SpriteSelector.Callback callback)
{
GUILayout.BeginHorizontal();
GUILayout.Label(fieldName, GUILayout.Width(76f));
if (atlas.GetSprite(spriteName) == null)
spriteName = "";
if (GUILayout.Button(spriteName, "MiniPullDown", GUILayout.Width(120f)))
{
SpriteSelector.Show(atlas, spriteName, callback);
}
if (!string.IsNullOrEmpty(caption))
{
GUILayout.Space(20f);
GUILayout.Label(caption);
}
GUILayout.EndHorizontal();
}
19
View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
static public void AdvancedSpriteField (UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
params GUILayoutOption[] options)
{
// Give the user a warning if there are no sprites in the atlas
if (atlas.spriteList.Count == 0)
{
EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
return;
}
// Sprite selection drop-down list
GUILayout.BeginHorizontal();
{
if (GUILayout.Button("Sprite", "DropDownButton", GUILayout.Width(76f)))
{
SpriteSelector.Show(atlas, spriteName, callback);
}
if (editable)
{
string sn = GUILayout.TextField(spriteName);
if (sn != spriteName)
{
UIAtlas.Sprite sp = atlas.GetSprite(spriteName);
if (sp != null)
{
NGUIEditorTools.RegisterUndo("Edit Sprite Name", atlas);
sp.name = sn;
spriteName = sn;
}
}
}
else
{
GUILayout.BeginHorizontal();
GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (GUILayout.Button("Edit", GUILayout.Width(40f)))
{
EditorPrefs.SetString("NGUI Selected Sprite", spriteName);
Select(atlas.gameObject);
}
}
}
GUILayout.EndHorizontal();
}
19
View Source File : SpriteSelector.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void OnGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
if (mAtlas == null)
{
GUILayout.Label("No Atlas selected.", "LODLevelNotifyText");
}
else
{
bool close = false;
GUILayout.Label(mAtlas.name + " Sprites", "LODLevelNotifyText");
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.Space(84f);
string before = NGUISettings.partialSprite;
string after = EditorGUILayout.TextField("", before, "SearchTextField");
NGUISettings.partialSprite = after;
if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f)))
{
NGUISettings.partialSprite = "";
GUIUtility.keyboardControl = 0;
}
GUILayout.Space(84f);
GUILayout.EndHorizontal();
Texture2D tex = mAtlas.texture as Texture2D;
if (tex == null)
{
GUILayout.Label("The atlas doesn't have a texture to work with");
return;
}
BetterList<string> sprites = mAtlas.GetListOfSprites(NGUISettings.partialSprite);
float size = 80f;
float padded = size + 10f;
int columns = Mathf.FloorToInt(Screen.width / padded);
if (columns < 1) columns = 1;
int offset = 0;
Rect rect = new Rect(10f, 0, size, size);
GUILayout.Space(10f);
mPos = GUILayout.BeginScrollView(mPos);
while (offset < sprites.size)
{
GUILayout.BeginHorizontal();
{
int col = 0;
rect.x = 10f;
for (; offset < sprites.size; ++offset)
{
UIAtlas.Sprite sprite = mAtlas.GetSprite(sprites[offset]);
if (sprite == null) continue;
// Button comes first
if (GUI.Button(rect, ""))
{
float delta = Time.realtimeSinceStartup - mClickTime;
mClickTime = Time.realtimeSinceStartup;
if (spriteName != sprite.name)
{
if (mSprite != null)
{
NGUIEditorTools.RegisterUndo("Atlas Selection", mSprite);
mSprite.spriteName = sprite.name;
mSprite.MakePixelPerfect();
EditorUtility.SetDirty(mSprite.gameObject);
}
else if (mCallback != null)
{
mName = sprite.name;
mCallback(sprite.name);
}
}
else if (delta < 0.5f) close = true;
}
if (Event.current.type == EventType.Repaint)
{
// On top of the button we have a checkboard grid
NGUIEditorTools.DrawTiledTexture(rect, NGUIEditorTools.backdropTexture);
Rect uv = sprite.outer;
if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height);
// Calculate the texture's scale that's needed to display the sprite in the clipped area
float scaleX = rect.width / uv.width;
float scaleY = rect.height / uv.height;
// Stretch the sprite so that it will appear proper
float aspect = (scaleY / scaleX) / ((float)tex.height / tex.width);
Rect clipRect = rect;
if (aspect != 1f)
{
if (aspect < 1f)
{
// The sprite is taller than it is wider
float padding = size * (1f - aspect) * 0.5f;
clipRect.xMin += padding;
clipRect.xMax -= padding;
}
else
{
// The sprite is wider than it is taller
float padding = size * (1f - 1f / aspect) * 0.5f;
clipRect.yMin += padding;
clipRect.yMax -= padding;
}
}
GUI.DrawTextureWithTexCoords(clipRect, tex, uv);
// Draw the selection
if (spriteName == sprite.name)
{
NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f));
}
}
if (++col >= columns)
{
++offset;
break;
}
rect.x += padded;
}
}
GUILayout.EndHorizontal();
GUILayout.Space(padded);
rect.y += padded;
}
GUILayout.EndScrollView();
if (close) Close();
}
}
19
View Source File : UIAtlasMaker.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void OnGUI ()
{
bool create = false;
bool update = false;
bool replace = false;
string prefabPath = "";
string matPath = "";
// If we have an atlas to work with, see if we can figure out the path for it and its material
if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
{
prefabPath = replacedetDatabase.GetreplacedetPath(NGUISettings.atlas.gameObject.GetInstanceID());
if (NGUISettings.atlas.spriteMaterial != null) matPath = replacedetDatabase.GetreplacedetPath(NGUISettings.atlas.spriteMaterial.GetInstanceID());
}
// replacedume default values if needed
if (string.IsNullOrEmpty(NGUISettings.atlasName)) NGUISettings.atlasName = "New Atlas";
if (string.IsNullOrEmpty(prefabPath)) prefabPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.atlasName + ".prefab";
if (string.IsNullOrEmpty(matPath)) matPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.atlasName + ".mat";
// Try to load the prefab
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (NGUISettings.atlas == null && go != null) NGUISettings.atlas = go.GetComponent<UIAtlas>();
EditorGUIUtility.LookLikeControls(80f);
GUILayout.Space(6f);
GUILayout.BeginHorizontal();
if (go == null)
{
GUI.backgroundColor = Color.green;
create = GUILayout.Button("Create", GUILayout.Width(76f));
}
else
{
GUI.backgroundColor = Color.red;
create = GUILayout.Button("Replace", GUILayout.Width(76f));
}
GUI.backgroundColor = Color.white;
NGUISettings.atlasName = GUILayout.TextField(NGUISettings.atlasName);
GUILayout.EndHorizontal();
if (create)
{
// If the prefab already exists, confirm that we want to overwrite it
if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
NGUISettings.atlasName + " atlas with the textures currently selected in the Project View? All other sprites will be deleted.", "Yes", "No"))
{
replace = true;
// Try to load the material
Material mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
// If the material doesn't exist, create it
if (mat == null)
{
Shader shader = Shader.Find("Unlit/Transparent Colored");
mat = new Material(shader);
// Save the material
replacedetDatabase.Createreplacedet(mat, matPath);
replacedetDatabase.Refresh();
// Load the material so it's usable
mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
}
if (NGUISettings.atlas == null || NGUISettings.atlas.name != NGUISettings.atlasName)
{
// Create a new prefab for the atlas
#if UNITY_3_4
Object prefab = (go != null) ? go : EditorUtility.CreateEmptyPrefab(prefabPath);
#else
Object prefab = (go != null) ? go : PrefabUtility.CreateEmptyPrefab(prefabPath);
#endif
// Create a new game object for the atlas
go = new GameObject(NGUISettings.atlasName);
go.AddComponent<UIAtlas>().spriteMaterial = mat;
// Update the prefab
#if UNITY_3_4
EditorUtility.ReplacePrefab(go, prefab);
#else
PrefabUtility.ReplacePrefab(go, prefab);
#endif
DestroyImmediate(go);
replacedetDatabase.Savereplacedets();
replacedetDatabase.Refresh();
// Select the atlas
go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
NGUISettings.atlas = go.GetComponent<UIAtlas>();
}
}
}
ComponentSelector.Draw<UIAtlas>("Select", NGUISettings.atlas, OnSelectAtlas);
List<Texture> textures = GetSelectedTextures();
if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
{
Material mat = NGUISettings.atlas.spriteMaterial;
Texture tex = NGUISettings.atlas.texture;
// Material information
GUILayout.BeginHorizontal();
{
if (mat != null)
{
if (GUILayout.Button("Material", GUILayout.Width(76f))) Selection.activeObject = mat;
GUILayout.Label(" " + mat.name);
}
else
{
GUI.color = Color.grey;
GUILayout.Button("Material", GUILayout.Width(76f));
GUI.color = Color.white;
GUILayout.Label(" N/A");
}
}
GUILayout.EndHorizontal();
// Texture atlas information
GUILayout.BeginHorizontal();
{
if (tex != null)
{
if (GUILayout.Button("Texture", GUILayout.Width(76f))) Selection.activeObject = tex;
GUILayout.Label(" " + tex.width + "x" + tex.height);
}
else
{
GUI.color = Color.grey;
GUILayout.Button("Texture", GUILayout.Width(76f));
GUI.color = Color.white;
GUILayout.Label(" N/A");
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
NGUISettings.atlasPadding = Mathf.Clamp(EditorGUILayout.IntField("Padding", NGUISettings.atlasPadding, GUILayout.Width(100f)), 0, 8);
GUILayout.Label((NGUISettings.atlasPadding == 1 ? "pixel" : "pixels") + " in-between of sprites");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
NGUISettings.atlasTrimming = EditorGUILayout.Toggle("Trim Alpha", NGUISettings.atlasTrimming, GUILayout.Width(100f));
GUILayout.Label("Remove empty space");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
NGUISettings.unityPacking = EditorGUILayout.Toggle("Unity Packer", NGUISettings.unityPacking, GUILayout.Width(100f));
GUILayout.Label("if off, use a custom packer");
GUILayout.EndHorizontal();
if (!NGUISettings.unityPacking)
{
GUILayout.BeginHorizontal();
NGUISettings.forceSquareAtlas = EditorGUILayout.Toggle("Force Square", NGUISettings.forceSquareAtlas, GUILayout.Width(100f));
GUILayout.Label("if on, forces a square atlas texture");
GUILayout.EndHorizontal();
}
#if UNITY_IPHONE || UNITY_ANDROID
GUILayout.BeginHorizontal();
NGUISettings.allow4096 = EditorGUILayout.Toggle("4096x4096", NGUISettings.allow4096, GUILayout.Width(100f));
GUILayout.Label("if off, limit atlases to 2048x2048");
GUILayout.EndHorizontal();
#endif
if (textures.Count > 0)
{
GUI.backgroundColor = Color.green;
update = GUILayout.Button("Add/Update All");
GUI.backgroundColor = Color.white;
}
else
{
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can reveal more options by selecting\none or more textures in the Project View\nwindow.");
}
}
else
{
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can create a new atlas by selecting\none or more textures in the Project View\nwindow, then clicking \"Create\".");
}
Dictionary<string, int> spriteList = GetSpriteList(textures);
if (spriteList.Count > 0)
{
NGUIEditorTools.DrawHeader("Sprites");
GUILayout.Space(-7f);
mScroll = GUILayout.BeginScrollView(mScroll);
bool delete = false;
int index = 0;
foreach (KeyValuePair<string, int> iter in spriteList)
{
++index;
NGUIEditorTools.HighlightLine(new Color(0.6f, 0.6f, 0.6f));
GUILayout.BeginHorizontal();
GUILayout.Label(index.ToString(), GUILayout.Width(24f));
GUILayout.Label(iter.Key);
if (iter.Value == 2)
{
GUI.color = Color.green;
GUILayout.Label("Add", GUILayout.Width(27f));
GUI.color = Color.white;
}
else if (iter.Value == 1)
{
GUI.color = Color.cyan;
GUILayout.Label("Update", GUILayout.Width(45f));
GUI.color = Color.white;
}
else
{
if (mDelNames.Contains(iter.Key))
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Delete", GUILayout.Width(60f)))
{
delete = true;
}
GUI.backgroundColor = Color.green;
if (GUILayout.Button("X", GUILayout.Width(22f)))
{
mDelNames.Remove(iter.Key);
delete = false;
}
GUI.backgroundColor = Color.white;
}
else
{
// If we have not yet selected a sprite for deletion, show a small "X" button
if (GUILayout.Button("X", GUILayout.Width(22f))) mDelNames.Add(iter.Key);
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
// If this sprite was marked for deletion, remove it from the atlas
if (delete)
{
List<SpriteEntry> sprites = new List<SpriteEntry>();
ExtractSprites(NGUISettings.atlas, sprites);
for (int i = sprites.Count; i > 0; )
{
SpriteEntry ent = sprites[--i];
if (mDelNames.Contains(ent.tex.name))
{
sprites.RemoveAt(i);
}
}
UpdateAtlas(NGUISettings.atlas, sprites);
mDelNames.Clear();
}
else if (update) UpdateAtlas(textures, true);
else if (replace) UpdateAtlas(textures, false);
return;
}
}
19
View Source File : UICreateNewUIWizard.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void OnGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
GUILayout.Label("Create a new UI with the following parameters:");
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
NGUISettings.layer = EditorGUILayout.LayerField("Layer", NGUISettings.layer, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("This is the layer your UI will reside on");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
camType = (CameraType)EditorGUILayout.EnumPopup("Camera", camType, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Should this UI have a camera?");
GUILayout.EndHorizontal();
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("When ready,");
bool create = GUILayout.Button("Create Your UI", GUILayout.Width(120f));
GUILayout.EndHorizontal();
if (create) CreateNewUI();
}
19
View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void CreateScrollBar (GameObject go)
{
if (NGUISettings.atlas != null)
{
NGUIEditorTools.SpriteField("Background", "Sprite used for the background", NGUISettings.atlas, mScrollBG, OnScrollBG);
NGUIEditorTools.SpriteField("Foreground", "Sprite used for the foreground (thumb)", NGUISettings.atlas, mScrollFG, OnScrollFG);
GUILayout.BeginHorizontal();
UIScrollBar.Direction dir = (UIScrollBar.Direction)EditorGUILayout.EnumPopup("Direction", mScrollDir, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Add colliders?", GUILayout.Width(90f));
bool draggable = EditorGUILayout.Toggle(mScrollCL);
GUILayout.EndHorizontal();
if (mScrollCL != draggable || mScrollDir != dir)
{
mScrollCL = draggable;
mScrollDir = dir;
Save();
}
}
if (ShouldCreate(go, NGUISettings.atlas != null))
{
int depth = NGUITools.CalculateNextDepth(go);
go = NGUITools.AddChild(go);
go.name = "Scroll Bar";
UISprite bg = NGUITools.AddWidget<UISprite>(go);
bg.type = UISprite.Type.Sliced;
bg.name = "Background";
bg.depth = depth;
bg.atlas = NGUISettings.atlas;
bg.spriteName = mScrollBG;
bg.transform.localScale = new Vector3(400f + bg.border.x + bg.border.z, 14f + bg.border.y + bg.border.w, 1f);
bg.MakePixelPerfect();
UISprite fg = NGUITools.AddWidget<UISprite>(go);
fg.type = UISprite.Type.Sliced;
fg.name = "Foreground";
fg.atlas = NGUISettings.atlas;
fg.spriteName = mScrollFG;
UIScrollBar sb = go.AddComponent<UIScrollBar>();
sb.background = bg;
sb.foreground = fg;
sb.direction = mScrollDir;
sb.barSize = 0.3f;
sb.scrollValue = 0.3f;
sb.ForceUpdate();
if (mScrollCL)
{
NGUITools.AddWidgetCollider(bg.gameObject);
NGUITools.AddWidgetCollider(fg.gameObject);
}
Selection.activeGameObject = go;
}
}
19
View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void OnGUI ()
{
// Load the saved preferences
if (!mLoaded) { mLoaded = true; Load(); }
EditorGUIUtility.LookLikeControls(80f);
GameObject go = NGUIEditorTools.SelectedRoot();
if (go == null)
{
GUILayout.Label("You must create a UI first.");
if (GUILayout.Button("Open the New UI Wizard"))
{
EditorWindow.GetWindow<UICreateNewUIWizard>(false, "New UI", true);
}
}
else
{
GUILayout.Space(4f);
GUILayout.BeginHorizontal();
ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas, GUILayout.Width(140f));
GUILayout.Label("Texture atlas used by widgets", GUILayout.MinWidth(10000f));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
ComponentSelector.Draw<UIFont>(NGUISettings.font, OnSelectFont, GUILayout.Width(140f));
GUILayout.Label("Font used by labels", GUILayout.MinWidth(10000f));
GUILayout.EndHorizontal();
GUILayout.Space(-2f);
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
WidgetType wt = (WidgetType)EditorGUILayout.EnumPopup("Template", mType, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Select a widget template to use");
GUILayout.EndHorizontal();
if (mType != wt) { mType = wt; Save(); }
switch (mType)
{
case WidgetType.Label: CreateLabel(go); break;
case WidgetType.Sprite: CreateSprite(go, mSprite); break;
case WidgetType.Texture: CreateSimpleTexture(go); break;
case WidgetType.Button: CreateButton(go); break;
case WidgetType.ImageButton: CreateImageButton(go); break;
case WidgetType.Checkbox: CreateCheckbox(go); break;
case WidgetType.ProgressBar: CreateSlider(go, false); break;
case WidgetType.Slider: CreateSlider(go, true); break;
case WidgetType.Input: CreateInput(go); break;
case WidgetType.PopupList: CreatePopup(go, true); break;
case WidgetType.PopupMenu: CreatePopup(go, false); break;
case WidgetType.ScrollBar: CreateScrollBar(go); break;
}
}
}
19
View Source File : UIFontInspector.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
override public void OnInspectorGUI ()
{
mFont = target as UIFont;
EditorGUIUtility.LookLikeControls(80f);
NGUIEditorTools.DrawSeparator();
//Lindean
if (mFont.dynamicFont != null)
{
mType = FontType.Dynamic;
}
if (mFont.replacement != null)
{
mType = FontType.Reference;
mReplacement = mFont.replacement;
}
else if (mFont.dynamicFont_1 != null)
{
mType = FontType.Dynamic;
}
GUILayout.BeginHorizontal();
FontType fontType = (FontType)EditorGUILayout.EnumPopup("Font Type", mType);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (mType != fontType)
{
if (fontType == FontType.Normal)
{
OnSelectFont(null);
}
else
{
mType = fontType;
}
//Lindean
if (mType != FontType.Dynamic && mFont.dynamicFont_1 != null)
mFont.dynamicFont_1 = null;
}
//Lindean
if (mType == FontType.Dynamic)
{
//Lindean - Draw settings for dynamic font
bool changed = false;
Font f = EditorGUILayout.ObjectField("Font", mFont.dynamicFont, typeof(Font), false) as Font;
if (f != mFont.dynamicFont)
{
mFont.dynamicFont = f;
changed = true;
}
Material mat = EditorGUILayout.ObjectField("Material", mFont.dynamicFontMaterial_1, typeof(Material), false) as Material;
if (mat != mFont.dynamicFontMaterial_1)
{
mFont.dynamicFontMaterial_1 = mat;
changed = true;
}
if (mFont.dynamicFontMaterial_1 == null)
GUILayout.Label("Warning: no coloring or clipping when using default font material");
int i = EditorGUILayout.IntField("Size", mFont.dynamicFontSize);
if (i != mFont.dynamicFontSize)
{
mFont.dynamicFontSize = i;
changed = true;
}
FontStyle style = (FontStyle)EditorGUILayout.EnumPopup("Style", mFont.dynamicFontStyle);
if (style != mFont.dynamicFontStyle)
{
mFont.dynamicFontStyle = style;
changed = true;
}
if (changed)
{
//force access to material property as it refreshes the texture replacedignment
Debug.Log("font changed...");
Material fontMat = mFont.material;
if (fontMat.mainTexture == null)
Debug.Log("font material texture issue...");
UIFont.OnFontRebuilt(mFont);
}
NGUIEditorTools.DrawSeparator();
// Font spacing
GUILayout.BeginHorizontal();
{
EditorGUIUtility.LookLikeControls(0f);
GUILayout.Label("Spacing", GUILayout.Width(60f));
GUILayout.Label("X", GUILayout.Width(12f));
int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
GUILayout.Label("Y", GUILayout.Width(12f));
int y = EditorGUILayout.IntField(mFont.verticalSpacing);
EditorGUIUtility.LookLikeControls(80f);
if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
{
NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
mFont.horizontalSpacing = x;
mFont.verticalSpacing = y;
}
}
GUILayout.EndHorizontal();
}
//Lindean
if (mType == FontType.Reference)
{
ComponentSelector.Draw<UIFont>(mFont.replacement, OnSelectFont);
NGUIEditorTools.DrawSeparator();
GUILayout.Label("You can have one font simply point to\n" +
"another one. This is useful if you want to be\n" +
"able to quickly replace the contents of one\n" +
"font with another one, for example for\n" +
"swapping an SD font with an HD one, or\n" +
"replacing an English font with a Chinese\n" +
"one. All the labels referencing this font\n" +
"will update their references to the new one.");
if (mReplacement != mFont && mFont.replacement != mReplacement)
{
NGUIEditorTools.RegisterUndo("Font Change", mFont);
mFont.replacement = mReplacement;
UnityEditor.EditorUtility.SetDirty(mFont);
}
return;
}
else if (mType == FontType.Dynamic)
{
#if UNITY_3_5
EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
NGUIEditorTools.DrawSeparator();
Font fnt = EditorGUILayout.ObjectField("TTF Font", mFont.dynamicFont_1, typeof(Font), false) as Font;
if (fnt != mFont.dynamicFont_1)
{
NGUIEditorTools.RegisterUndo("Font change", mFont);
mFont.dynamicFont_1 = fnt;
}
GUILayout.BeginHorizontal();
int size = EditorGUILayout.IntField("Size", mFont.dynamicFontSize_1, GUILayout.Width(120f));
FontStyle style = (FontStyle)EditorGUILayout.EnumPopup(mFont.dynamicFontStyle_1);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (size != mFont.dynamicFontSize_1)
{
NGUIEditorTools.RegisterUndo("Font change", mFont);
mFont.dynamicFontSize_1 = size;
}
if (style != mFont.dynamicFontStyle_1)
{
NGUIEditorTools.RegisterUndo("Font change", mFont);
mFont.dynamicFontStyle_1 = style;
}
Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;
if (mFont.material != mat)
{
NGUIEditorTools.RegisterUndo("Font Material", mFont);
mFont.material = mat;
}
#endif
}
else
{
NGUIEditorTools.DrawSeparator();
ComponentSelector.Draw<UIAtlas>(mFont.atlas, OnSelectAtlas);
if (mFont.atlas != null)
{
if (mFont.bmFont.isValid)
{
NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
}
EditorGUILayout.Space();
}
else
{
// No atlas specified -- set the material and texture rectangle directly
Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;
if (mFont.material != mat)
{
NGUIEditorTools.RegisterUndo("Font Material", mFont);
mFont.material = mat;
}
}
// For updating the font's data when importing from an external source, such as the texture packer
bool resetWidthHeight = false;
if (mFont.atlas != null || mFont.material != null)
{
Textreplacedet data = EditorGUILayout.ObjectField("Import Data", null, typeof(Textreplacedet), false) as Textreplacedet;
if (data != null)
{
NGUIEditorTools.RegisterUndo("Import Font Data", mFont);
BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes);
mFont.MarkAsDirty();
resetWidthHeight = true;
Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters");
}
}
if (mFont.bmFont.isValid)
{
Color green = new Color(0.4f, 1f, 0f, 1f);
Texture2D tex = mFont.texture;
if (tex != null)
{
if (mFont.atlas == null)
{
// Pixels are easier to work with than UVs
Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false);
// Automatically set the width and height of the rectangle to be the original font texture's dimensions
if (resetWidthHeight)
{
pixels.width = mFont.texWidth;
pixels.height = mFont.texHeight;
}
// Font sprite rectangle
GUI.backgroundColor = green;
pixels = EditorGUILayout.RectField("Pixel Rect", pixels);
GUI.backgroundColor = Color.white;
// Create a button that can make the coordinates pixel-perfect on click
GUILayout.BeginHorizontal();
{
Rect corrected = NGUIMath.MakePixelPerfect(pixels);
if (corrected == pixels)
{
GUI.color = Color.grey;
GUILayout.Button("Make Pixel-Perfect");
GUI.color = Color.white;
}
else if (GUILayout.Button("Make Pixel-Perfect"))
{
pixels = corrected;
GUI.changed = true;
}
}
GUILayout.EndHorizontal();
// Convert the pixel coordinates back to UV coordinates
Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height);
if (mFont.uvRect != uvRect)
{
NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont);
mFont.uvRect = uvRect;
}
//NGUIEditorTools.DrawSeparator();
EditorGUILayout.Space();
}
}
}
}
// The font must be valid at this point for the rest of the options to show up
if (mFont.isDynamic || mFont.bmFont.isValid)
{
// Font spacing
GUILayout.BeginHorizontal();
{
EditorGUIUtility.LookLikeControls(0f);
GUILayout.Label("Spacing", GUILayout.Width(60f));
GUILayout.Label("X", GUILayout.Width(12f));
int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
GUILayout.Label("Y", GUILayout.Width(12f));
int y = EditorGUILayout.IntField(mFont.verticalSpacing);
GUILayout.Space(18f);
EditorGUIUtility.LookLikeControls(80f);
if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
{
NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
mFont.horizontalSpacing = x;
mFont.verticalSpacing = y;
}
}
GUILayout.EndHorizontal();
if (mFont.atlas == null)
{
mView = View.Font;
mUseShader = false;
float pixelSize = EditorGUILayout.FloatField("Pixel Size", mFont.pixelSize, GUILayout.Width(120f));
if (pixelSize != mFont.pixelSize)
{
NGUIEditorTools.RegisterUndo("Font Change", mFont);
mFont.pixelSize = pixelSize;
}
}
EditorGUILayout.Space();
}
// Preview option
if (!mFont.isDynamic && mFont.atlas != null)
{
GUILayout.BeginHorizontal();
{
mView = (View)EditorGUILayout.EnumPopup("Preview", mView);
GUILayout.Label("Shader", GUILayout.Width(45f));
mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f));
}
GUILayout.EndHorizontal();
}
// Dynamic fonts don't support emoticons
if (!mFont.isDynamic && mFont.bmFont.isValid)
{
if (mFont.atlas != null)
{
NGUIEditorTools.DrawHeader("Symbols and Emoticons");
List<BMSymbol> symbols = mFont.symbols;
for (int i = 0; i < symbols.Count; )
{
BMSymbol sym = symbols[i];
GUILayout.BeginHorizontal();
GUILayout.Label(sym.sequence, GUILayout.Width(40f));
if (NGUIEditorTools.SimpleSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite))
mSelectedSymbol = sym;
if (GUILayout.Button("Edit", GUILayout.Width(40f)))
{
if (mFont.atlas != null)
{
EditorPrefs.SetString("NGUI Selected Sprite", sym.spriteName);
NGUIEditorTools.Select(mFont.atlas.gameObject);
}
}
GUI.backgroundColor = Color.red;
if (GUILayout.Button("X", GUILayout.Width(22f)))
{
NGUIEditorTools.RegisterUndo("Remove symbol", mFont);
mSymbolSequence = sym.sequence;
mSymbolSprite = sym.spriteName;
symbols.Remove(sym);
mFont.MarkAsDirty();
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
GUILayout.Space(4f);
++i;
}
if (symbols.Count > 0)
{
NGUIEditorTools.DrawSeparator();
}
GUILayout.BeginHorizontal();
mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f));
NGUIEditorTools.SimpleSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite);
bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite);
GUI.backgroundColor = isValid ? Color.green : Color.grey;
if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid)
{
NGUIEditorTools.RegisterUndo("Add symbol", mFont);
mFont.AddSymbol(mSymbolSequence, mSymbolSprite);
mFont.MarkAsDirty();
mSymbolSequence = "";
mSymbolSprite = "";
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
if (symbols.Count == 0)
{
EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info);
}
else GUILayout.Space(4f);
}
}
}
19
View Source File : UIPanelInspector.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
public override void OnInspectorGUI ()
{
UIPanel panel = target as UIPanel;
BetterList<UIDrawCall> drawcalls = panel.drawCalls;
EditorGUIUtility.LookLikeControls(80f);
//NGUIEditorTools.DrawSeparator();
EditorGUILayout.Space();
float alpha = EditorGUILayout.Slider("Alpha", panel.alpha, 0f, 1f);
if (alpha != panel.alpha)
{
NGUIEditorTools.RegisterUndo("Panel Alpha", panel);
panel.alpha = alpha;
}
if (panel.showInPanelTool != EditorGUILayout.Toggle("Panel Tool", panel.showInPanelTool))
{
panel.showInPanelTool = !panel.showInPanelTool;
EditorUtility.SetDirty(panel);
EditorWindow.FocusWindowIfItsOpen<UIPanelTool>();
}
panel.isTop = EditorGUILayout.Toggle("IsTop",panel.isTop);
panel.isLeft = EditorGUILayout.Toggle("IsLeft",panel.isLeft);
GUILayout.BeginHorizontal();
bool norms = EditorGUILayout.Toggle("Normals", panel.generateNormals, GUILayout.Width(100f));
GUILayout.Label("Needed for lit shaders");
GUILayout.EndHorizontal();
if (panel.generateNormals != norms)
{
panel.generateNormals = norms;
panel.UpdateDrawcalls();
EditorUtility.SetDirty(panel);
}
GUILayout.BeginHorizontal();
bool depth = EditorGUILayout.Toggle("Depth Preplaced", panel.depthPreplaced, GUILayout.Width(100f));
GUILayout.Label("Doubles draw calls, saves fillrate");
GUILayout.EndHorizontal();
if (panel.depthPreplaced != depth)
{
panel.depthPreplaced = depth;
panel.UpdateDrawcalls();
EditorUtility.SetDirty(panel);
}
if (depth)
{
UICamera cam = UICamera.FindCameraForLayer(panel.gameObject.layer);
if (cam == null || cam.GetComponent<Camera>().orthographic)
{
EditorGUILayout.HelpBox("Please note that depth preplaced will only save fillrate when used with 3D UIs, and only UIs drawn by the game camera. If you are using a separate camera for the UI, you will not see any benefit!", MessageType.Warning);
}
}
GUILayout.BeginHorizontal();
bool stat = EditorGUILayout.Toggle("Static", panel.widgetsAreStatic, GUILayout.Width(100f));
GUILayout.Label("Check if widgets won't move");
GUILayout.EndHorizontal();
if (panel.widgetsAreStatic != stat)
{
panel.widgetsAreStatic = stat;
panel.UpdateDrawcalls();
EditorUtility.SetDirty(panel);
}
EditorGUILayout.LabelField("Widgets", panel.widgets.size.ToString());
EditorGUILayout.LabelField("Draw Calls", drawcalls.size.ToString());
UIPanel.DebugInfo di = (UIPanel.DebugInfo)EditorGUILayout.EnumPopup("Debug Info", panel.debugInfo);
if (panel.debugInfo != di)
{
panel.debugInfo = di;
EditorUtility.SetDirty(panel);
}
UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", panel.clipping);
if (panel.clipping != clipping)
{
panel.clipping = clipping;
EditorUtility.SetDirty(panel);
}
if (panel.clipping != UIDrawCall.Clipping.None)
{
Vector4 range = panel.clipRange;
GUILayout.BeginHorizontal();
GUILayout.Space(80f);
Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Space(80f);
Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w));
GUILayout.EndHorizontal();
if (size.x < 0f) size.x = 0f;
if (size.y < 0f) size.y = 0f;
range.x = pos.x;
range.y = pos.y;
range.z = size.x;
range.w = size.y;
if (panel.clipRange != range)
{
NGUIEditorTools.RegisterUndo("Clipping Change", panel);
panel.clipRange = range;
EditorUtility.SetDirty(panel);
}
if (panel.clipping == UIDrawCall.Clipping.SoftClip)
{
GUILayout.BeginHorizontal();
GUILayout.Space(80f);
Vector2 soft = EditorGUILayout.Vector2Field("Softness", panel.clipSoftness);
GUILayout.EndHorizontal();
if (soft.x < 1f) soft.x = 1f;
if (soft.y < 1f) soft.y = 1f;
if (panel.clipSoftness != soft)
{
NGUIEditorTools.RegisterUndo("Clipping Change", panel);
panel.clipSoftness = soft;
EditorUtility.SetDirty(panel);
}
}
#if UNITY_ANDROID || UNITY_IPHONE
if (PlayerSettings.targetGlesGraphics == TargetGlesGraphics.OpenGLES_1_x)
{
EditorGUILayout.HelpBox("Clipping requires shader support!\n\nOpen File -> Build Settings -> Player Settings -> Other Settings, then set:\n\n- Graphics Level: OpenGL ES 2.0.", MessageType.Error);
}
#endif
}
if (clipping == UIDrawCall.Clipping.HardClip)
{
EditorGUILayout.HelpBox("Hard clipping has been removed due to major performance issues on certain Android devices. Alpha clipping will be used instead.", MessageType.Warning);
}
if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(panel.transform.lossyScale))
{
EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error);
if (GUILayout.Button("Auto-fix"))
{
NGUIEditorTools.FixUniform(panel.gameObject);
}
}
foreach (UIDrawCall dc in drawcalls)
{
NGUIEditorTools.DrawSeparator();
EditorGUILayout.ObjectField("Material", dc.material, typeof(Material), false);
EditorGUILayout.LabelField("Triangles", dc.triangles.ToString());
if (clipping != UIDrawCall.Clipping.None && !dc.isClipped)
{
EditorGUILayout.HelpBox("You must switch this material's shader to Unlit/Transparent Colored or Unlit/Premultiplied Colored in order for clipping to work.",
MessageType.Warning);
}
}
}
19
View Source File : UIPopupListInspector.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
public override void OnInspectorGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
mList = target as UIPopupList;
ComponentSelector.Draw<UIAtlas>(mList.atlas, OnSelectAtlas);
ComponentSelector.Draw<UIFont>(mList.font, OnSelectFont);
GUILayout.BeginHorizontal();
UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel;
if (mList.textLabel != lbl)
{
RegisterUndo();
mList.textLabel = lbl;
if (lbl != null) lbl.text = mList.selection;
}
GUILayout.Space(44f);
GUILayout.EndHorizontal();
if (mList.atlas != null)
{
NGUIEditorTools.SpriteField("Background", mList.atlas, mList.backgroundSprite, OnBackground);
NGUIEditorTools.SpriteField("Highlight", mList.atlas, mList.highlightSprite, OnHighlight);
GUILayout.BeginHorizontal();
GUILayout.Space(6f);
GUILayout.Label("Options");
GUILayout.EndHorizontal();
string text = "";
foreach (string s in mList.items) text += s + "\n";
GUILayout.Space(-14f);
GUILayout.BeginHorizontal();
GUILayout.Space(84f);
string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f));
GUILayout.EndHorizontal();
if (modified != text)
{
RegisterUndo();
string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
mList.items.Clear();
foreach (string s in split) mList.items.Add(s);
if (string.IsNullOrEmpty(mList.selection) || !mList.items.Contains(mList.selection))
{
mList.selection = mList.items.Count > 0 ? mList.items[0] : "";
}
}
string sel = NGUIEditorTools.DrawList("Selection", mList.items.ToArray(), mList.selection);
if (mList.selection != sel)
{
RegisterUndo();
mList.selection = sel;
}
UIPopupList.Position pos = (UIPopupList.Position)EditorGUILayout.EnumPopup("Position", mList.position);
if (mList.position != pos)
{
RegisterUndo();
mList.position = pos;
}
float ts = EditorGUILayout.FloatField("Text Scale", mList.textScale);
Color tc = EditorGUILayout.ColorField("Text Color", mList.textColor);
Color bc = EditorGUILayout.ColorField("Background", mList.backgroundColor);
Color hc = EditorGUILayout.ColorField("Highlight", mList.highlightColor);
GUILayout.BeginHorizontal();
bool isLocalized = EditorGUILayout.Toggle("Localized", mList.isLocalized, GUILayout.Width(100f));
bool isAnimated = EditorGUILayout.Toggle("Animated", mList.isAnimated);
GUILayout.EndHorizontal();
if (mList.textScale != ts ||
mList.textColor != tc ||
mList.highlightColor != hc ||
mList.backgroundColor != bc ||
mList.isLocalized != isLocalized ||
mList.isAnimated != isAnimated)
{
RegisterUndo();
mList.textScale = ts;
mList.textColor = tc;
mList.backgroundColor = bc;
mList.highlightColor = hc;
mList.isLocalized = isLocalized;
mList.isAnimated = isAnimated;
}
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.Space(6f);
GUILayout.Label("Padding", GUILayout.Width(76f));
GUILayout.BeginVertical();
GUILayout.Space(-12f);
Vector2 padding = EditorGUILayout.Vector2Field("", mList.padding);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
if (mList.padding != padding)
{
RegisterUndo();
mList.padding = padding;
}
EditorGUIUtility.LookLikeControls(100f);
GameObject go = EditorGUILayout.ObjectField("Event Receiver", mList.eventReceiver,
typeof(GameObject), true) as GameObject;
string fn = EditorGUILayout.TextField("Function Name", mList.functionName);
if (mList.eventReceiver != go || mList.functionName != fn)
{
RegisterUndo();
mList.eventReceiver = go;
mList.functionName = fn;
}
}
}
19
View Source File : UISliderInspector.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
public override void OnInspectorGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
UISlider slider = target as UISlider;
NGUIEditorTools.DrawSeparator();
float sliderValue = EditorGUILayout.Slider("Value", slider.sliderValue, 0f, 1f);
if (slider.sliderValue != sliderValue)
{
NGUIEditorTools.RegisterUndo("Slider Change", slider);
slider.sliderValue = sliderValue;
UnityEditor.EditorUtility.SetDirty(slider);
}
int steps = EditorGUILayout.IntSlider("Steps", slider.numberOfSteps, 0, 11);
if (slider.numberOfSteps != steps)
{
NGUIEditorTools.RegisterUndo("Slider Change", slider);
slider.numberOfSteps = steps;
slider.ForceUpdate();
UnityEditor.EditorUtility.SetDirty(slider);
}
NGUIEditorTools.DrawSeparator();
Transform fg = EditorGUILayout.ObjectField("Foreground", slider.foreground, typeof(Transform), true) as Transform;
Transform tb = EditorGUILayout.ObjectField("Thumb", slider.thumb, typeof(Transform), true) as Transform;
UISlider.Direction dir = (UISlider.Direction)EditorGUILayout.EnumPopup("Direction", slider.direction);
// If we're using a sprite for the foreground, ensure it's using a proper pivot.
ValidatePivot(fg, "Foreground sprite", dir);
NGUIEditorTools.DrawSeparator();
GameObject er = EditorGUILayout.ObjectField("Event Recv.", slider.eventReceiver, typeof(GameObject), true) as GameObject;
GUILayout.BeginHorizontal();
string fn = EditorGUILayout.TextField("Function", slider.functionName);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (slider.foreground != fg ||
slider.thumb != tb ||
slider.direction != dir ||
slider.eventReceiver != er ||
slider.functionName != fn)
{
NGUIEditorTools.RegisterUndo("Slider Change", slider);
slider.foreground = fg;
slider.thumb = tb;
slider.direction = dir;
slider.eventReceiver = er;
slider.functionName = fn;
if (slider.thumb != null)
{
slider.thumb.localPosition = Vector3.zero;
slider.sliderValue = -1f;
slider.sliderValue = sliderValue;
}
else slider.ForceUpdate();
UnityEditor.EditorUtility.SetDirty(slider);
}
}
19
View Source File : UISpriteInspector.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
override protected void DrawExtraProperties ()
{
NGUIEditorTools.DrawSeparator();
if (GetType() == typeof(UISpriteInspector))
{
//GUILayout.BeginHorizontal();
UISprite.Type type = (UISprite.Type)EditorGUILayout.EnumPopup("Sprite Type", mSprite.type);
//GUILayout.Label("sprite", GUILayout.Width(58f));
//GUILayout.EndHorizontal();
if (mSprite.type != type)
{
NGUIEditorTools.RegisterUndo("Sprite Change", mSprite);
mSprite.type = type;
EditorUtility.SetDirty(mSprite.gameObject);
}
}
if (mSprite.type == UISprite.Type.Sliced)
{
bool fill = EditorGUILayout.Toggle("Fill Center", mSprite.fillCenter);
if (mSprite.fillCenter != fill)
{
NGUIEditorTools.RegisterUndo("Sprite Change", mSprite);
mSprite.fillCenter = fill;
EditorUtility.SetDirty(mSprite.gameObject);
}
}
else if (mSprite.type == UISprite.Type.Filled)
{
if ((int)mSprite.fillDirection > (int)UISprite.FillDirection.Radial360)
{
mSprite.fillDirection = UISprite.FillDirection.Horizontal;
EditorUtility.SetDirty(mSprite);
}
UISprite.FillDirection fillDirection = (UISprite.FillDirection)EditorGUILayout.EnumPopup("Fill Dir", mSprite.fillDirection);
float fillAmount = EditorGUILayout.Slider("Fill Amount", mSprite.fillAmount, 0f, 1f);
bool invert = EditorGUILayout.Toggle("Invert Fill", mSprite.invert);
if (mSprite.fillDirection != fillDirection || mSprite.fillAmount != fillAmount || mSprite.invert != invert)
{
NGUIEditorTools.RegisterUndo("Sprite Change", mSprite);
mSprite.fillDirection = fillDirection;
mSprite.fillAmount = fillAmount;
mSprite.invert = invert;
EditorUtility.SetDirty(mSprite);
}
}
GUILayout.Space(4f);
}
19
View Source File : UICameraTool.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void DrawRow (Camera cam)
{
if (cam != null) NGUIEditorTools.HighlightLine(new Color(0.6f, 0.6f, 0.6f));
GUILayout.BeginHorizontal();
{
bool enabled = (cam == null || (NGUITools.GetActive(cam.gameObject) && cam.enabled));
GUI.color = Color.white;
if (cam != null)
{
if (enabled != EditorGUILayout.Toggle(enabled, GUILayout.Width(20f)))
{
cam.enabled = !enabled;
EditorUtility.SetDirty(cam.gameObject);
}
}
else
{
GUILayout.Space(30f);
}
bool highlight = (cam == null || Selection.activeGameObject == null) ? false :
(0 != (cam.cullingMask & (1 << Selection.activeGameObject.layer)));
if (enabled)
{
GUI.color = highlight ? new Color(0f, 0.8f, 1f) : Color.white;
}
else
{
GUI.color = highlight ? new Color(0f, 0.5f, 0.8f) : Color.grey;
}
string camName, camLayer;
if (cam == null)
{
camName = "Camera's Name";
camLayer = "Layer";
}
else
{
camName = cam.name + (cam.orthographic ? " (2D)" : " (3D)");
camLayer = LayerMask.LayerToName(cam.gameObject.layer);
}
#if UNITY_3_4
if (GUILayout.Button(camName, EditorStyles.structHeadingLabel, GUILayout.MinWidth(100f)) && cam != null)
#else
if (GUILayout.Button(camName, EditorStyles.label, GUILayout.MinWidth(100f)) && cam != null)
#endif
{
Selection.activeGameObject = cam.gameObject;
EditorUtility.SetDirty(cam.gameObject);
}
GUILayout.Label(camLayer, GUILayout.Width(70f));
GUI.color = enabled ? Color.white : new Color(0.7f, 0.7f, 0.7f);
if (cam == null)
{
GUILayout.Label("EV", GUILayout.Width(26f));
}
else
{
UICamera uic = cam.GetComponent<UICamera>();
bool ev = (uic != null && uic.enabled);
if (ev != EditorGUILayout.Toggle(ev, GUILayout.Width(20f)))
{
if (uic == null) uic = cam.gameObject.AddComponent<UICamera>();
uic.enabled = !ev;
}
}
if (cam == null)
{
GUILayout.Label("Mask", GUILayout.Width(100f));
}
else
{
int mask = LayerMaskField(cam.cullingMask, GUILayout.Width(105f));
if (cam.cullingMask != mask)
{
NGUIEditorTools.RegisterUndo("Camera Mask Change", cam);
cam.cullingMask = mask;
}
}
}
GUILayout.EndHorizontal();
}
19
View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void CreateSprite (GameObject go, string field)
{
if (NGUISettings.atlas != null)
{
NGUIEditorTools.SpriteField("Sprite", "Sprite that will be created", NGUISettings.atlas, field, OnSprite);
if (!string.IsNullOrEmpty(field))
{
GUILayout.BeginHorizontal();
NGUISettings.pivot = (UIWidget.Pivot)EditorGUILayout.EnumPopup("Pivot", NGUISettings.pivot, GUILayout.Width(200f));
GUILayout.Space(20f);
GUILayout.Label("Initial pivot point used by the sprite");
GUILayout.EndHorizontal();
}
}
if (ShouldCreate(go, NGUISettings.atlas != null))
{
UISprite sprite = NGUITools.AddWidget<UISprite>(go);
sprite.name = sprite.name + " (" + field + ")";
sprite.atlas = NGUISettings.atlas;
sprite.spriteName = field;
sprite.pivot = NGUISettings.pivot;
sprite.MakePixelPerfect();
Selection.activeGameObject = sprite.gameObject;
}
}
19
View Source File : UIFontMaker.cs
License : Apache License 2.0
Project Creator : 365082218
License : Apache License 2.0
Project Creator : 365082218
void OnGUI ()
{
string prefabPath = "";
string matPath = "";
if (NGUISettings.font != null && NGUISettings.font.name == NGUISettings.fontName)
{
prefabPath = replacedetDatabase.GetreplacedetPath(NGUISettings.font.gameObject.GetInstanceID());
if (NGUISettings.font.material != null) matPath = replacedetDatabase.GetreplacedetPath(NGUISettings.font.material.GetInstanceID());
}
// replacedume default values if needed
if (string.IsNullOrEmpty(NGUISettings.fontName)) NGUISettings.fontName = "New Font";
if (string.IsNullOrEmpty(prefabPath)) prefabPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".prefab";
if (string.IsNullOrEmpty(matPath)) matPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".mat";
EditorGUIUtility.LookLikeControls(80f);
NGUIEditorTools.DrawHeader("Input");
GUILayout.BeginHorizontal();
mType = (FontType)EditorGUILayout.EnumPopup("Type", mType);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
int create = 0;
if (mType == FontType.Dynamic)
{
NGUISettings.dynamicFont = EditorGUILayout.ObjectField("Font TTF", NGUISettings.dynamicFont, typeof(Font), false) as Font;
GUILayout.BeginHorizontal();
NGUISettings.dynamicFontSize = EditorGUILayout.IntField("Font Size", NGUISettings.dynamicFontSize, GUILayout.Width(120f));
NGUISettings.dynamicFontStyle = (FontStyle)EditorGUILayout.EnumPopup(NGUISettings.dynamicFontStyle);
GUILayout.Space(18f);
GUILayout.EndHorizontal();
if (NGUISettings.dynamicFont != null)
{
NGUIEditorTools.DrawHeader("Output");
GUILayout.BeginHorizontal();
GUILayout.Label("Font Name", GUILayout.Width(76f));
GUI.backgroundColor = Color.white;
NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);
GUILayout.EndHorizontal();
}
NGUIEditorTools.DrawSeparator();
#if UNITY_3_5
EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
// Helpful info
if (NGUISettings.dynamicFont == null)
{
EditorGUILayout.HelpBox("Dynamic font creation happens right in Unity. Simply specify the TrueType font to be used as source.", MessageType.Info);
}
EditorGUILayout.HelpBox("Please note that dynamic fonts can't be made a part of an atlas, and they will always be drawn in a separate draw call. You WILL need to adjust transform position's Z rather than depth!", MessageType.Warning);
if (NGUISettings.dynamicFont != null)
{
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.backgroundColor = Color.green;
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (go != null)
{
if (go.GetComponent<UIFont>() != null)
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Replace the Font", GUILayout.Width(140f))) create = 1;
}
else
{
GUI.backgroundColor = Color.grey;
GUILayout.Button("Rename Your Font", GUILayout.Width(140f));
}
}
else
{
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Create the Font", GUILayout.Width(140f))) create = 1;
}
GUI.backgroundColor = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
#endif
}
else
{
NGUISettings.fontData = EditorGUILayout.ObjectField("Font Data", NGUISettings.fontData, typeof(Textreplacedet), false) as Textreplacedet;
NGUISettings.fontTexture = EditorGUILayout.ObjectField("Texture", NGUISettings.fontTexture, typeof(Texture2D), false) as Texture2D;
// Draw the atlas selection only if we have the font data and texture specified, just to make it easier
if (NGUISettings.fontData != null && NGUISettings.fontTexture != null)
{
NGUIEditorTools.DrawHeader("Output");
GUILayout.BeginHorizontal();
GUILayout.Label("Font Name", GUILayout.Width(76f));
GUI.backgroundColor = Color.white;
NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);
GUILayout.EndHorizontal();
ComponentSelector.Draw<UIFont>("Select", NGUISettings.font, OnSelectFont);
ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas);
}
NGUIEditorTools.DrawSeparator();
// Helpful info
if (NGUISettings.fontData == null)
{
EditorGUILayout.HelpBox("The bitmap font creation mostly takes place outside of Unity. You can use BMFont on" +
"Windows or your choice of Glyph Designer or the less expensive bmGlyph on the Mac.\n\n" +
"Either of these tools will create a FNT file for you that you will drag & drop into the field above.", MessageType.Info);
}
else if (NGUISettings.fontTexture == null)
{
EditorGUILayout.HelpBox("When exporting your font, you should get two files: the TXT, and the texture. Only one texture can be used per font.", MessageType.Info);
}
else if (NGUISettings.atlas == null)
{
EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
"labels using this font will generate an extra draw call, and will need to be sorted by " +
"adjusting the Z instead of the Depth.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Create a Font without an Atlas", GUILayout.Width(200f))) create = 2;
GUI.backgroundColor = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
else
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (go != null)
{
if (go.GetComponent<UIFont>() != null)
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Replace the Font", GUILayout.Width(140f))) create = 3;
}
else
{
GUI.backgroundColor = Color.grey;
GUILayout.Button("Rename Your Font", GUILayout.Width(140f));
}
}
else
{
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Create the Font", GUILayout.Width(140f))) create = 3;
}
GUI.backgroundColor = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
}
if (create != 0)
{
GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
NGUISettings.fontName + " font with the currently selected values? This action can't be undone.", "Yes", "No"))
{
// Try to load the material
Material mat = null;
// Non-atlased font
if (create == 2)
{
mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
// If the material doesn't exist, create it
if (mat == null)
{
Shader shader = Shader.Find("Unlit/Transparent Colored");
mat = new Material(shader);
// Save the material
replacedetDatabase.Createreplacedet(mat, matPath);
replacedetDatabase.Refresh();
// Load the material so it's usable
mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
}
mat.mainTexture = NGUISettings.fontTexture;
}
// Font doesn't exist yet
if (go == null || go.GetComponent<UIFont>() == null)
{
// Create a new prefab for the atlas
Object prefab = CreateEmptyPrefab(prefabPath);
// Create a new game object for the font
go = new GameObject(NGUISettings.fontName);
NGUISettings.font = go.AddComponent<UIFont>();
CreateFont(NGUISettings.font, create, mat);
// Update the prefab
ReplacePrefab(go, prefab);
DestroyImmediate(go);
replacedetDatabase.Refresh();
// Select the atlas
go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
NGUISettings.font = go.GetComponent<UIFont>();
}
else
{
NGUISettings.font = go.GetComponent<UIFont>();
CreateFont(NGUISettings.font, create, mat);
}
MarkAsChanged();
}
}
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static float HorizontalSlider(float val, string label)
{
UGUI.BeginHorizontal();
Label(label);
UGUI.Space(5f);
val = UGUI.HorizontalSlider(val, 0f, 1f, Style.Slider, Style.SliderBody, DefaultOption);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static float HorizontalSlider(float val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] sliderOpts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val = UGUI.HorizontalSlider(val, 0f, 1f, Style.Slider, Style.SliderBody, sliderOpts);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static float HorizontalSlider(float val, string label, float min, float max)
{
UGUI.BeginHorizontal();
Label(label);
UGUI.Space(5f);
val = UGUI.HorizontalSlider(val, min, max, Style.Slider, Style.SliderBody, DefaultOption);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static float HorizontalSlider(float val, string label, float min, float max, GUILayoutOption[] lblOpts, GUILayoutOption[] sliderOpts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val = UGUI.HorizontalSlider(val, min, max, Style.Slider, Style.SliderBody, sliderOpts);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void HorizontalSlider(Setting<float> val, string label)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
val.Value = UGUI.HorizontalSlider(val.Value, 0f, 1f, Style.Slider, Style.SliderBody, DefaultOption);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void HorizontalSlider(Setting<float> val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] sliderOpts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val.Value = UGUI.HorizontalSlider(val.Value, 0f, 1f, Style.Slider, Style.SliderBody, sliderOpts);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void HorizontalSlider(Setting<float> val, string label, float min, float max)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
val.Value = UGUI.HorizontalSlider(val.Value, min, max, Style.Slider, Style.SliderBody, DefaultOption);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void HorizontalSlider(Setting<float> val, string label, float min, float max, GUILayoutOption[] lblOpts, GUILayoutOption[] sliderOpts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val.Value = UGUI.HorizontalSlider(val.Value, min, max, Style.Slider, Style.SliderBody, sliderOpts);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void Space()
{
UGUI.Space(5f);
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void Space(float offset)
{
UGUI.Space(offset);
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static string TextField(string val, string label)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
val = UGUI.TextField(val, Style.TextButton, DefaultOption);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static string TextField(string val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] txtopts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val = UGUI.TextField(val, Style.TextButton, txtopts);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void TextField(Setting<string> val, string label)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
val.Value = UGUI.TextField(val.Value, Style.TextButton, DefaultOption);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void TextField(Setting<string> val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] txtopts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val.Value = UGUI.TextField(val.Value, Style.TextButton, txtopts);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void TextField(Setting<float> val, string label)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
TextField(val);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void TextField(Setting<float> val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] txtopts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
TextField(val, txtopts);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void TextField(Setting<int> val, string label)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
TextField(val);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void TextField(Setting<int> val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] txtopts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
TextField(val, txtopts);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static bool ToggleButton(bool val, string label)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
val = UGUI.Button(val ? GUI.LabelEnabled : GUI.LabelDisabled, Style.TextButton, DefaultOption);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static bool ToggleButton(bool val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] btnOpts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val = UGUI.Button(val ? GUI.LabelEnabled : GUI.LabelDisabled, Style.TextButton, btnOpts);
UGUI.EndHorizontal();
return val;
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void ToggleButton(Setting<bool> val, string label)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, DefaultOption);
UGUI.Space(5f);
val.Value = UGUI.Button(val.Value ? GUI.LabelEnabled : GUI.LabelDisabled, Style.TextButton, DefaultOption);
UGUI.EndHorizontal();
}
19
View Source File : GUILayout.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public static void ToggleButton(Setting<bool> val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] btnOpts)
{
UGUI.BeginHorizontal();
UGUI.Label(label, Style.Label, lblOpts);
UGUI.Space(5f);
val.Value = UGUI.Button(val.Value ? GUI.LabelEnabled : GUI.LabelDisabled, Style.TextButton, btnOpts);
UGUI.EndHorizontal();
}
19
View Source File : ConsoleWindow.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : 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
View Source File : ConsoleWindow.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
public override void OnGUI(Rect rect)
{
string itemValue = m_Object as string;
if (itemValue == null)
{
Debug.LogError("Invalid object");
return;
}
if (m_TextSearch == null)
{
m_TextSearch = itemValue;
}
const float kColumnWidth = 70f;
const float kSpacing = 10f;
GUILayout.Space(3);
GUILayout.Label(m_MenuType == MenuType.Add ? Styles.headerAdd : Styles.headerEdit, EditorStyles.boldLabel);
Rect seperatorRect = GUILayoutUtility.GetRect(1, 1);
FlexibleMenu.DrawRect(seperatorRect,
(EditorGUIUtility.isProSkin)
? new Color(0.32f, 0.32f, 0.32f, 1.333f)
: new Color(0.6f, 0.6f, 0.6f, 1.333f)); // dark : light
GUILayout.Space(4);
// Optional text
GUILayout.BeginHorizontal();
GUILayout.Label(Styles.optionalText, GUILayout.Width(kColumnWidth));
GUILayout.Space(kSpacing);
m_TextSearch = EditorGUILayout.TextField(m_TextSearch);
GUILayout.EndHorizontal();
GUILayout.Space(5f);
// Cancel, Ok
GUILayout.BeginHorizontal();
GUILayout.Space(10);
if (GUILayout.Button(Styles.cancel))
{
editorWindow.Close();
}
if (GUILayout.Button(Styles.ok))
{
var textSearch = m_TextSearch.Trim();
if (!string.IsNullOrEmpty(textSearch))
{
m_Object = m_TextSearch;
Accepted();
editorWindow.Close();
}
}
GUILayout.Space(10);
GUILayout.EndHorizontal();
}
19
View Source File : ConsoleScript.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm
License : GNU General Public License v3.0
Project Creator : AndrasMumm
void DrawToolbar()
{
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
if (GUILayout.Button(clearLabel))
{
logs.Clear();
}
if (GUILayout.Button("Reload Scene"))
{
Scene scene = SceneManager.GetActiveScene();
SceneManager.LoadScene(scene.name);
}
GUILayout.EndVertical();
foreach (LogType logType in Enum.GetValues(typeof(LogType)))
{
var currentState = logTypeFilters[logType];
var label = logType.ToString();
logTypeFilters[logType] = GUILayout.Toggle(currentState, label, GUILayout.ExpandWidth(false));
GUILayout.Space(20);
}
isCollapsed = GUILayout.Toggle(isCollapsed, collapseLabel, GUILayout.ExpandWidth(false));
GUILayout.EndHorizontal();
}
19
View Source File : InspectorScript.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm
License : GNU General Public License v3.0
Project Creator : AndrasMumm
private void OnDraw(int id)
{
GUILayout.Space(50);
GUILayout.Label("Currently hovered UI Elements:");
DisplayCurrentlyPressedUINames();
Window.MakeDragable();
}
19
View Source File : ProductsWindow.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools
private void CreateProductEntry(ProductInfo p)
{
EditorGUILayout.BeginVertical("Box");
EditorGUILayout.BeginHorizontal();
//Create and anchor the foldout
GUILayout.Label(GUIContent.none);
var productLabel = new GUIContent(" " + p.name, p.icon.texture);
p.expanded = EditorGUI.Foldout(GUILayoutUtility.GetLastRect(), p.expanded, productLabel, true, _styles.foldout);
//New update marker
if (p.newUpdateAvailable)
{
if (p.status == ProductStatus.PatchAvailable)
{
GUILayout.Label(new GUIContent("#", "New patch available!"), _styles.labelHighlight, GUILayout.Width(20));
}
else
{
GUILayout.Label(new GUIContent("!", "New update available!"), _styles.labelHighlight, GUILayout.Width(20));
}
}
else
{
GUILayout.Label(GUIContent.none, GUILayout.Width(20));
}
//Version
GUIContent status;
if (p.installedVersion == null)
{
status = new GUIContent("N/A", "Not installed");
}
else
{
status = new GUIContent(Write(p.installedVersion), "Installed version");
}
GUILayout.Label(status, _styles.centeredText, GUILayout.Width(50));
//Link buttons / status
if (p.status != ProductStatus.UpToDate)
{
if (p.status == ProductStatus.ComingSoon)
{
EditorGUILayout.LabelField("Coming soon", GUILayout.Width(80));
}
else if (p.status == ProductStatus.UpdateAvailable)
{
if (GUILayout.Button(new GUIContent("Update It", string.Format("Version {0} is now available.\n\nClick to open the product's page on the Unity replacedet Store.", p.newestVersion)), EditorStyles.toolbarButton, GUILayout.Width(80)))
{
replacedetStore.Open(p.storeUrl);
}
}
else if (p.status == ProductStatus.ProductAvailable)
{
if (GUILayout.Button(new GUIContent("Get It", "Now available.\n\nClick to open the product's page on the Unity replacedet Store."), EditorStyles.toolbarButton, GUILayout.Width(80)))
{
replacedetStore.Open(p.storeUrl);
}
}
else if (p.status == ProductStatus.PatchAvailable)
{
if (GUILayout.Button(new GUIContent("Patch It", "A patch is available.\n\nClick to download and apply the patch. Patches are hot fixes and all patches will be included in the following product update."), EditorStyles.toolbarButton, GUILayout.Width(80)))
{
ProductManager.ApplyPatches(p, _settings);
}
}
}
else
{
GUILayout.Space(80f);
}
EditorGUILayout.EndHorizontal();
//Details
if (p.expanded)
{
GUILayout.Box(GUIContent.none, _styles.boxSeparator);
var description = string.IsNullOrEmpty(p.description) ? "No description available" : p.description;
EditorGUILayout.LabelField(description, _styles.labelWithWrap);
EditorGUILayout.BeginHorizontal();
if (!string.IsNullOrEmpty(p.productUrl))
{
if (GUILayout.Button("Product Page", _styles.labelLink))
{
Application.OpenURL(p.productUrl);
}
EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
}
if (!string.IsNullOrEmpty(p.changeLogPath))
{
if (GUILayout.Button("Change Log", _styles.labelLink))
{
Application.OpenURL(p.changeLogPath);
}
EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
}
See More Examples