UnityEngine.GUILayout.Width(float)

Here are the examples of the csharp api UnityEngine.GUILayout.Width(float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

809 Examples 7

19 Source : TransformInspector.cs
with Apache License 2.0
from 365082218

public override void OnInspectorGUI() {
            EditorGUIUtility.labelWidth = 15f;
        
            serializedObject.Update();
        
            DrawPosition();
            DrawRotation();
            DrawScale();
        
            GUILayout.BeginHorizontal();
            GUI.color = new Color(0.7f, 0.7f, 0.7f);
            EditorGUILayout.Vector3Field(new GUIContent("World Pos"), ((Transform) serializedObject.targetObject).position);
            GUI.color = Color.white;
            GUILayout.EndHorizontal();

            Quaternion q = ((Transform)serializedObject.targetObject).rotation;
            Vector3 vec = new Vector4(q.eulerAngles.x, q.eulerAngles.y, q.eulerAngles.z);
            GUILayout.BeginHorizontal();
            EditorGUILayout.Vector3Field(new GUIContent("World Rot"), vec);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                string info = LocalPosition.FindPropertyRelative("x").floatValue + ";" +
                              LocalPosition.FindPropertyRelative("y").floatValue + ";" +
                              LocalPosition.FindPropertyRelative("z").floatValue + ";" +
                              LocalRotation.FindPropertyRelative("x").floatValue + ";" +
                              LocalRotation.FindPropertyRelative("y").floatValue + ";" +
                              LocalRotation.FindPropertyRelative("z").floatValue + ";" +
                              LocalRotation.FindPropertyRelative("w").floatValue + ";" +
                              LocalScale.FindPropertyRelative("x").floatValue + ";" +
                              LocalScale.FindPropertyRelative("y").floatValue + ";" +
                              LocalScale.FindPropertyRelative("z").floatValue;
            
                bool copy = GUILayout.Button("Copy", GUILayout.Width(50f));
                bool paste = GUILayout.Button("Paste", GUILayout.Width(50f));
                bool reset = GUILayout.Button("Idenreplacedy", GUILayout.Width(70f));
                bool uniformScale = GUILayout.Button("Z - Uniform Scale", GUILayout.Width(110f));
            
                if (copy)
                    EditorGUIUtility.systemCopyBuffer = info;
                if (paste) {
                    string line = EditorGUIUtility.systemCopyBuffer;
                    if (info != line) {
                        bool success = false;
                        string[] atts = line.Split(';');
                        if (atts.Length == 10) {
                            float[] values = new float[10];
                            for (int i = 0; i < atts.Length; i++) {
                                float.TryParse(atts[i], out values[i]);
                            }
                            LocalPosition.vector3Value = new Vector3(values[0], values[1], values[2]);
                            LocalRotation.quaternionValue = new Quaternion(values[3], values[4], values[5], values[6]);
                            LocalScale.vector3Value = new Vector3(values[7], values[8], values[9]);
                            success = true;
                        }
                        if (!success)
                            Debug.LogError("Failed pasting data");
                    
                    }
                }
                if (uniformScale) {
                    float v = LocalScale.FindPropertyRelative("z").floatValue;
                    LocalScale.FindPropertyRelative("x").floatValue = v;
                    LocalScale.FindPropertyRelative("y").floatValue = v;
                }
            
                if (reset) {
                    LocalPosition.vector3Value = Vector3.zero;
                    LocalRotation.quaternionValue = Quaternion.idenreplacedy;
                    LocalScale.vector3Value = Vector3.one;
                }
            }
            GUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }

19 Source : TransformInspector.cs
with Apache License 2.0
from 365082218

private void DrawPosition() {
            GUILayout.BeginHorizontal();
            {
                bool reset = GUILayout.Button("P", GUILayout.Width(20f));
            
                EditorGUILayout.PropertyField(LocalPosition.FindPropertyRelative("x"));
                EditorGUILayout.PropertyField(LocalPosition.FindPropertyRelative("y"));
                EditorGUILayout.PropertyField(LocalPosition.FindPropertyRelative("z"));
            
                if (reset)
                    LocalPosition.vector3Value = Vector3.zero;
            }
            GUILayout.EndHorizontal();
        }

19 Source : TransformInspector.cs
with Apache License 2.0
from 365082218

void DrawScale() {
            GUILayout.BeginHorizontal();
            {
                bool reset = GUILayout.Button("S", GUILayout.Width(20f));
            
                EditorGUILayout.PropertyField(LocalScale.FindPropertyRelative("x"));
                EditorGUILayout.PropertyField(LocalScale.FindPropertyRelative("y"));
                EditorGUILayout.PropertyField(LocalScale.FindPropertyRelative("z"));

                if (reset)
                    LocalScale.vector3Value = Vector3.one;
            }
            GUILayout.EndHorizontal();
        }

19 Source : TransformInspector.cs
with Apache License 2.0
from 365082218

void DrawRotation() {
            GUILayout.BeginHorizontal();
            {
                bool reset = GUILayout.Button("R", GUILayout.Width(20f));
            
                Vector3 visible = (serializedObject.targetObject as Transform).localEulerAngles;
            
                visible.x = WrapAngle(visible.x);
                visible.y = WrapAngle(visible.y);
                visible.z = WrapAngle(visible.z);
            
                Axes changed = CheckDifference(LocalRotation);
                Axes altered = Axes.None;
            
                GUILayoutOption opt = GUILayout.MinWidth(30f);
            
                if (FloatField("X", ref visible.x, (changed & Axes.X) != 0, false, opt))
                    altered |= Axes.X;
                if (FloatField("Y", ref visible.y, (changed & Axes.Y) != 0, false, opt))
                    altered |= Axes.Y;
                if (FloatField("Z", ref visible.z, (changed & Axes.Z) != 0, false, opt))
                    altered |= Axes.Z;
            
                if (reset) {
                    LocalRotation.quaternionValue = Quaternion.idenreplacedy;
                } else if (altered != Axes.None) {
                    RegisterUndo("Change Rotation", serializedObject.targetObjects);
                
                    foreach (Object obj in serializedObject.targetObjects) {
                        Transform t = obj as Transform;
                        Vector3 v = t.localEulerAngles;
                    
                        if ((altered & Axes.X) != 0)
                            v.x = visible.x;
                        if ((altered & Axes.Y) != 0)
                            v.y = visible.y;
                        if ((altered & Axes.Z) != 0)
                            v.z = visible.z;
                    
                        t.localEulerAngles = v;
                    }
                }
            }
            GUILayout.EndHorizontal();
        }

19 Source : LuaConsole.cs
with Apache License 2.0
from 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 Source : CheckResources.cs
with Apache License 2.0
from 365082218

void ListTextures ()
		{
				textureListScrollPos = EditorGUILayout.BeginScrollView (textureListScrollPos);
		
				foreach (TextureDetails tDetails in ActiveTextures) {			
			
						GUILayout.BeginHorizontal ();
						GUILayout.Box (tDetails.texture, GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
			
						if (GUILayout.Button (tDetails.texture.name, GUILayout.Width (150))) {
								SelectObject (tDetails.texture, ctrlPressed);
						}
			
						string sizeLabel = "" + tDetails.texture.width + "x" + tDetails.texture.height;
						if (tDetails.isCubeMap)
								sizeLabel += "x6";
						sizeLabel += " - " + tDetails.mipMapCount + "mip";
						sizeLabel += "\n" + FormatSizeString (tDetails.memSizeKB) + " - " + tDetails.format + "";
			
						GUILayout.Label (sizeLabel, GUILayout.Width (120));
			
						if (GUILayout.Button (tDetails.FoundInMaterials.Count + " Mat", GUILayout.Width (50))) {
								SelectObjects (tDetails.FoundInMaterials, ctrlPressed);
						}
			
						if (GUILayout.Button (tDetails.FoundInRenderers.Count + " GO", GUILayout.Width (50))) {
								List<Object> FoundObjects = new List<Object> ();
								foreach (Renderer renderer in tDetails.FoundInRenderers)
										FoundObjects.Add (renderer.gameObject);
								SelectObjects (FoundObjects, ctrlPressed);
						}
			
						GUILayout.EndHorizontal ();	
				}
				if (ActiveTextures.Count > 0) {
						GUILayout.BeginHorizontal ();
						GUILayout.Box (" ", GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
			
						if (GUILayout.Button ("Select All", GUILayout.Width (150))) {
								List<Object> AllTextures = new List<Object> ();
								foreach (TextureDetails tDetails in ActiveTextures)
										AllTextures.Add (tDetails.texture);
								SelectObjects (AllTextures, ctrlPressed);
						}
						EditorGUILayout.EndHorizontal ();
				}
				EditorGUILayout.EndScrollView ();
		}

19 Source : CheckResources.cs
with Apache License 2.0
from 365082218

void ListMeshes ()
		{
				meshListScrollPos = EditorGUILayout.BeginScrollView (meshListScrollPos);
		
				foreach (MeshDetails tDetails in ActiveMeshDetails) {			
						if (tDetails.mesh != null) {
								GUILayout.BeginHorizontal ();
								/*
				if (tDetails.material.mainTexture!=null) GUILayout.Box(tDetails.material.mainTexture, GUILayout.Width(ThumbnailWidth), GUILayout.Height(ThumbnailHeight));
				else	
				{
					GUILayout.Box("n/a",GUILayout.Width(ThumbnailWidth),GUILayout.Height(ThumbnailHeight));
				}
				*/
				
								if (GUILayout.Button (tDetails.mesh.name, GUILayout.Width (150))) {
										SelectObject (tDetails.mesh, ctrlPressed);
								}
								string sizeLabel = "" + tDetails.mesh.vertexCount + " vert";
				
								GUILayout.Label (sizeLabel, GUILayout.Width (100));
				
				
								if (GUILayout.Button (tDetails.FoundInMeshFilters.Count + " GO", GUILayout.Width (50))) {
										List<Object> FoundObjects = new List<Object> ();
										foreach (MeshFilter meshFilter in tDetails.FoundInMeshFilters)
												FoundObjects.Add (meshFilter.gameObject);
										SelectObjects (FoundObjects, ctrlPressed);
								}
				
								if (GUILayout.Button (tDetails.FoundInSkinnedMeshRenderer.Count + " GO", GUILayout.Width (50))) {
										List<Object> FoundObjects = new List<Object> ();
										foreach (SkinnedMeshRenderer skinnedMeshRenderer in tDetails.FoundInSkinnedMeshRenderer)
												FoundObjects.Add (skinnedMeshRenderer.gameObject);
										SelectObjects (FoundObjects, ctrlPressed);
								}
				
				
								GUILayout.EndHorizontal ();	
						}
				}
				EditorGUILayout.EndScrollView ();		
		}

19 Source : SpriteSelector.cs
with Apache License 2.0
from 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 Source : UIAtlasInspector.cs
with Apache License 2.0
from 365082218

public override void OnInspectorGUI ()
	{
		EditorGUIUtility.LookLikeControls(80f);
		mAtlas = target as UIAtlas;

		NGUIEditorTools.DrawSeparator();

		if (mAtlas.replacement != null)
		{
			mType = AtlasType.Reference;
			mReplacement = mAtlas.replacement;
		}

		AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);

		if (mType != after)
		{
			if (after == AtlasType.Normal)
			{
				OnSelectAtlas(null);
			}
			else
			{
				mType = AtlasType.Reference;
			}
		}

		if (mType == AtlasType.Reference)
		{
			ComponentSelector.Draw<UIAtlas>(mAtlas.replacement, OnSelectAtlas);

			NGUIEditorTools.DrawSeparator();
			GUILayout.Label("You can have one atlas simply point to\n" +
				"another one. This is useful if you want to be\n" +
				"able to quickly replace the contents of one\n" +
				"atlas with another one, for example for\n" +
				"swapping an SD atlas with an HD one, or\n" +
				"replacing an English atlas with a Chinese\n" +
				"one. All the sprites referencing this atlas\n" +
				"will update their references to the new one.");

			if (mReplacement != mAtlas && mAtlas.replacement != mReplacement)
			{
				NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
				mAtlas.replacement = mReplacement;
				UnityEditor.EditorUtility.SetDirty(mAtlas);
			}
			return;
		}

		if (!mConfirmDelete)
		{
			NGUIEditorTools.DrawSeparator();
			Material mat = EditorGUILayout.ObjectField("Material", mAtlas.spriteMaterial, typeof(Material), false) as Material;

			if (mAtlas.spriteMaterial != mat)
			{
				NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
				mAtlas.spriteMaterial = mat;

				// Ensure that this atlas has valid import settings
				if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false);

				mAtlas.MarkAsDirty();
				mConfirmDelete = false;
			}

			if (mat != null)
			{
				Textreplacedet ta = EditorGUILayout.ObjectField("TP Import", null, typeof(Textreplacedet), false) as Textreplacedet;

				if (ta != null)
				{
					// Ensure that this atlas has valid import settings
					if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false);

					NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
					NGUIJson.LoadSpriteData(mAtlas, ta);
					if (mSprite != null) mSprite = mAtlas.GetSprite(mSprite.name);
					mAtlas.MarkAsDirty();
				}
				
				UIAtlas.Coordinates coords = (UIAtlas.Coordinates)EditorGUILayout.EnumPopup("Coordinates", mAtlas.coordinates);

				if (coords != mAtlas.coordinates)
				{
					NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
					mAtlas.coordinates = coords;
					mConfirmDelete = false;
				}

				float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize, GUILayout.Width(120f));

				if (pixelSize != mAtlas.pixelSize)
				{
					NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
					mAtlas.pixelSize = pixelSize;
					mConfirmDelete = false;
				}
			}
		}

		if (mAtlas.spriteMaterial != null)
		{
			Color blue = new Color(0f, 0.7f, 1f, 1f);
			Color green = new Color(0.4f, 1f, 0f, 1f);

			if (mConfirmDelete)
			{
				if (mSprite != null)
				{
					// Show the confirmation dialog
					NGUIEditorTools.DrawSeparator();
					GUILayout.Label("Are you sure you want to delete '" + mSprite.name + "'?");
					NGUIEditorTools.DrawSeparator();

					GUILayout.BeginHorizontal();
					{
						GUI.backgroundColor = Color.green;
						if (GUILayout.Button("Cancel")) mConfirmDelete = false;
						GUI.backgroundColor = Color.red;

						if (GUILayout.Button("Delete"))
						{
							NGUIEditorTools.RegisterUndo("Delete Sprite", mAtlas);
							mAtlas.spriteList.Remove(mSprite);
							mConfirmDelete = false;
						}
						GUI.backgroundColor = Color.white;
					}
					GUILayout.EndHorizontal();
				}
				else mConfirmDelete = false;
			}
			else
			{
				if (mSprite == null && mAtlas.spriteList.Count > 0)
				{
					string spriteName = EditorPrefs.GetString("NGUI Selected Sprite");
					if (!string.IsNullOrEmpty(spriteName)) mSprite = mAtlas.GetSprite(spriteName);
					if (mSprite == null) mSprite = mAtlas.spriteList[0];
				}

				if (!mConfirmDelete && mSprite != null)
				{
					NGUIEditorTools.DrawSeparator();
					NGUIEditorTools.AdvancedSpriteField(mAtlas, mSprite.name, SelectSprite, true);

					if (mSprite == null) return;

					Texture2D tex = mAtlas.spriteMaterial.mainTexture as Texture2D;

					if (tex != null)
					{
						Rect inner = mSprite.inner;
						Rect outer = mSprite.outer;

						if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
						{
							GUI.backgroundColor = green;
							outer = NGUIEditorTools.IntRect("Dimensions", mSprite.outer);

							Vector4 border = new Vector4(
								mSprite.inner.xMin - mSprite.outer.xMin,
								mSprite.inner.yMin - mSprite.outer.yMin,
								mSprite.outer.xMax - mSprite.inner.xMax,
								mSprite.outer.yMax - mSprite.inner.yMax);

							GUI.backgroundColor = blue;
							border = NGUIEditorTools.IntPadding("Border", border);
							GUI.backgroundColor = Color.white;

							inner.xMin = mSprite.outer.xMin + border.x;
							inner.yMin = mSprite.outer.yMin + border.y;
							inner.xMax = mSprite.outer.xMax - border.z;
							inner.yMax = mSprite.outer.yMax - border.w;
						}
						else
						{
							// Draw the inner and outer rectangle dimensions
							GUI.backgroundColor = green;
							outer = EditorGUILayout.RectField("Outer Rect", mSprite.outer);
							GUI.backgroundColor = blue;
							inner = EditorGUILayout.RectField("Inner Rect", mSprite.inner);
							GUI.backgroundColor = Color.white;
						}

						if (outer.xMax < outer.xMin) outer.xMax = outer.xMin;
						if (outer.yMax < outer.yMin) outer.yMax = outer.yMin;

						if (outer != mSprite.outer)
						{
							float x = outer.xMin - mSprite.outer.xMin;
							float y = outer.yMin - mSprite.outer.yMin;

							inner.x += x;
							inner.y += y;
						}

						// Sanity checks to ensure that the inner rect is always inside the outer
						inner.xMin = Mathf.Clamp(inner.xMin, outer.xMin, outer.xMax);
						inner.xMax = Mathf.Clamp(inner.xMax, outer.xMin, outer.xMax);
						inner.yMin = Mathf.Clamp(inner.yMin, outer.yMin, outer.yMax);
						inner.yMax = Mathf.Clamp(inner.yMax, outer.yMin, outer.yMax);
						
						bool changed = false;
						
						if (mSprite.inner != inner || mSprite.outer != outer)
						{
							NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
							mSprite.inner = inner;
							mSprite.outer = outer;
							MarkSpriteAsDirty();
							changed = true;
						}

						EditorGUILayout.Separator();

						if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
						{
							int left	= Mathf.RoundToInt(mSprite.paddingLeft	 * mSprite.outer.width);
							int right	= Mathf.RoundToInt(mSprite.paddingRight	 * mSprite.outer.width);
							int top		= Mathf.RoundToInt(mSprite.paddingTop	 * mSprite.outer.height);
							int bottom	= Mathf.RoundToInt(mSprite.paddingBottom * mSprite.outer.height);

							NGUIEditorTools.IntVector a = NGUIEditorTools.IntPair("Padding", "Left", "Top", left, top);
							NGUIEditorTools.IntVector b = NGUIEditorTools.IntPair(null, "Right", "Bottom", right, bottom);

							if (changed || a.x != left || a.y != top || b.x != right || b.y != bottom)
							{
								NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
								mSprite.paddingLeft		= a.x / mSprite.outer.width;
								mSprite.paddingTop		= a.y / mSprite.outer.height;
								mSprite.paddingRight	= b.x / mSprite.outer.width;
								mSprite.paddingBottom	= b.y / mSprite.outer.height;
								MarkSpriteAsDirty();
							}
						}
						else
						{
							// Create a button that can make the coordinates pixel-perfect on click
							GUILayout.BeginHorizontal();
							{
								GUILayout.Label("Correction", GUILayout.Width(75f));

								Rect corrected0 = outer;
								Rect corrected1 = inner;

								if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
								{
									corrected0 = NGUIMath.MakePixelPerfect(corrected0);
									corrected1 = NGUIMath.MakePixelPerfect(corrected1);
								}
								else
								{
									corrected0 = NGUIMath.MakePixelPerfect(corrected0, tex.width, tex.height);
									corrected1 = NGUIMath.MakePixelPerfect(corrected1, tex.width, tex.height);
								}

								if (corrected0 == mSprite.outer && corrected1 == mSprite.inner)
								{
									GUI.color = Color.grey;
									GUILayout.Button("Make Pixel-Perfect");
									GUI.color = Color.white;
								}
								else if (GUILayout.Button("Make Pixel-Perfect"))
								{
									outer = corrected0;
									inner = corrected1;
									GUI.changed = true;
								}
							}
							GUILayout.EndHorizontal();
						}
					}

					// This functionality is no longer used. It became obsolete when the Atlas Maker was added.
					/*NGUIEditorTools.DrawSeparator();

					GUILayout.BeginHorizontal();
					{
						EditorGUILayout.PrefixLabel("Add/Delete");

						if (GUILayout.Button("Clone Sprite"))
						{
							NGUIEditorTools.RegisterUndo("Add Sprite", mAtlas);
							UIAtlas.Sprite newSprite = new UIAtlas.Sprite();

							if (mSprite != null)
							{
								newSprite.name = "Copy of " + mSprite.name;
								newSprite.outer = mSprite.outer;
								newSprite.inner = mSprite.inner;
							}
							else
							{
								newSprite.name = "New Sprite";
							}

							mAtlas.spriteList.Add(newSprite);
							mSprite = newSprite;
						}

						// Show the delete button
						GUI.backgroundColor = Color.red;

						if (mSprite != null && GUILayout.Button("Delete", GUILayout.Width(55f)))
						{
							mConfirmDelete = true;
						}
						GUI.backgroundColor = Color.white;
					}
					GUILayout.EndHorizontal();*/

					if (NGUIEditorTools.previousSelection != null)
					{
						NGUIEditorTools.DrawSeparator();

						GUI.backgroundColor = Color.green;

						if (GUILayout.Button("<< Return to " + NGUIEditorTools.previousSelection.name))
						{
							NGUIEditorTools.SelectPrevious();
						}
						GUI.backgroundColor = Color.white;
					}
				}
			}
		}
	}

19 Source : ComponentSelector.cs
with Apache License 2.0
from 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 Source : ComponentSelector.cs
with Apache License 2.0
from 365082218

void OnGUI ()
	{
		EditorGUIUtility.LookLikeControls(80f);
		GUILayout.Label("Recently used components", "LODLevelNotifyText");
		NGUIEditorTools.DrawSeparator();

		if (mObjects.Length == 0)
		{
			EditorGUILayout.HelpBox("No recently used " + mType.ToString() + " components found.\nTry drag & dropping one instead, or creating a new one.", MessageType.Info);

			bool isDone = false;

			EditorGUILayout.Space();
			GUILayout.BeginHorizontal();
			GUILayout.FlexibleSpace();

			if (mType == typeof(UIFont))
			{
				if (GUILayout.Button("Open the Font Maker", GUILayout.Width(150f)))
				{
					EditorWindow.GetWindow<UIFontMaker>(false, "Font Maker", true);
					isDone = true;
				}
			}
			else if (mType == typeof(UIAtlas))
			{
				if (GUILayout.Button("Open the Atlas Maker", GUILayout.Width(150f)))
				{
					EditorWindow.GetWindow<UIAtlasMaker>(false, "Atlas Maker", true);
					isDone = true;
				}
			}

			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			if (isDone) Close();
		}
		else
		{
			MonoBehaviour sel = null;

			foreach (MonoBehaviour o in mObjects)
			{
				if (DrawObject(o))
				{
					sel = o;
				}
			}

			if (sel != null)
			{
				mCallback(sel);
				Close();
			}
		}
	}

19 Source : ComponentSelector.cs
with Apache License 2.0
from 365082218

bool DrawObject (MonoBehaviour mb)
	{
		bool retVal = false;

		GUILayout.BeginHorizontal();
		{
			if (EditorUtility.IsPersistent(mb.gameObject))
			{
				GUILayout.Label("Prefab", "AS TextArea", GUILayout.Width(80f), GUILayout.Height(20f));
			}
			else
			{
				GUI.color = Color.grey;
				GUILayout.Label("Object", "AS TextArea", GUILayout.Width(80f), GUILayout.Height(20f));
			}

			GUILayout.Label(NGUITools.GetHierarchy(mb.gameObject), "AS TextArea", GUILayout.Height(20f));
			GUI.color = Color.white;

			retVal = GUILayout.Button("Select", "ButtonLeft", GUILayout.Width(60f), GUILayout.Height(16f));
		}
		GUILayout.EndHorizontal();
		return retVal;
	}

19 Source : NGUIEditorTools.cs
with Apache License 2.0
from 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 Source : NGUIEditorTools.cs
with Apache License 2.0
from 365082218

static public void SpriteField (string fieldName, UIAtlas atlas, string spriteName,
		SpriteSelector.Callback callback, params GUILayoutOption[] options)
	{
		GUILayout.BeginHorizontal();
		GUILayout.Label(fieldName, GUILayout.Width(76f));

		if (GUILayout.Button(spriteName, "MiniPullDown", options))
		{
			SpriteSelector.Show(atlas, spriteName, callback);
		}
		GUILayout.EndHorizontal();
	}

19 Source : NGUIEditorTools.cs
with Apache License 2.0
from 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 Source : NGUIEditorTools.cs
with Apache License 2.0
from 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 Source : NGUITransformInspector.cs
with Apache License 2.0
from 365082218

static bool DrawButton(string replacedle, string tooltip, bool enabled, float width)
	{
		if (enabled)
		{
			// Draw a regular button
			return GUILayout.Button(new GUIContent(replacedle, tooltip), GUILayout.Width(width));
		}
		else
		{
			// Button should be disabled -- draw it darkened and ignore its return value
			Color color = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, 0.25f);
			GUILayout.Button(new GUIContent(replacedle, tooltip), GUILayout.Width(width));
			GUI.color = color;
			return false;
		}
	}

19 Source : UIAtlasMaker.cs
with Apache License 2.0
from 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 Source : UICameraTool.cs
with Apache License 2.0
from 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 Source : UICreateNewUIWizard.cs
with Apache License 2.0
from 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 Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 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 Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 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 Source : UIFontInspector.cs
with Apache License 2.0
from 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 Source : UIFontMaker.cs
with Apache License 2.0
from 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 Source : UIPanelTool.cs
with Apache License 2.0
from 365082218

bool DrawRow (Entry ent, UIPanel selected, bool isChecked)
	{
		bool retVal = false;
		string panelName, layer, widgetCount, drawCalls, clipping;

		if (ent != null)
		{
			panelName = ent.panel.name;
			layer = LayerMask.LayerToName(ent.panel.gameObject.layer);
			widgetCount = ent.widgets.Count.ToString();
			drawCalls = ent.panel.drawCalls.size.ToString();
			clipping = (ent.panel.clipping != UIDrawCall.Clipping.None) ? "Yes" : "";
		}
		else
		{
			panelName = "Panel's Name";
			layer = "Layer";
			widgetCount = "WG";
			drawCalls = "DC";
			clipping = "Clip";
		}

		if (ent != null) NGUIEditorTools.HighlightLine(ent.isEnabled ? new Color(0.6f, 0.6f, 0.6f) : Color.black);

		GUILayout.BeginHorizontal();
		{
			GUI.color = Color.white;

			if (isChecked != EditorGUILayout.Toggle(isChecked, GUILayout.Width(20f))) retVal = true;

			if (ent == null)
			{
				GUI.contentColor = Color.white;
			}
			else if (ent.isEnabled)
			{
				GUI.contentColor = (ent.panel == selected) ? new Color(0f, 0.8f, 1f) : Color.white; 
			}
			else
			{
				GUI.contentColor = (ent.panel == selected) ? new Color(0f, 0.5f, 0.8f) : Color.grey;
			}

#if UNITY_3_4
			if (GUILayout.Button(panelName, EditorStyles.structHeadingLabel, GUILayout.MinWidth(100f)))
#else
			if (GUILayout.Button(panelName, EditorStyles.label, GUILayout.MinWidth(100f)))
#endif
			{
				if (ent != null)
				{
					Selection.activeGameObject = ent.panel.gameObject;
					EditorUtility.SetDirty(ent.panel.gameObject);
				}
			}

			GUILayout.Label(layer, GUILayout.Width(ent == null ? 65f : 70f));
			GUILayout.Label(widgetCount, GUILayout.Width(30f));
			GUILayout.Label(drawCalls, GUILayout.Width(30f));
			GUILayout.Label(clipping, GUILayout.Width(30f));

			if (ent == null)
			{
				GUILayout.Label("Giz", GUILayout.Width(24f));
			}
			else
			{
				GUI.contentColor = ent.isEnabled ? Color.white : new Color(0.7f, 0.7f, 0.7f);
				bool debug = (ent.panel.debugInfo == UIPanel.DebugInfo.Gizmos);

				if (debug != EditorGUILayout.Toggle(debug, GUILayout.Width(20f)))
				{
					// debug != value, so it's currently inverse
					ent.panel.debugInfo = debug ? UIPanel.DebugInfo.None : UIPanel.DebugInfo.Gizmos;
					EditorUtility.SetDirty(ent.panel.gameObject);
				}
			}
		}
		GUILayout.EndHorizontal();
		return retVal;
	}

19 Source : UIPopupListInspector.cs
with Apache License 2.0
from 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 Source : CheckResources.cs
with Apache License 2.0
from 365082218

void ListMaterials ()
		{
				materialListScrollPos = EditorGUILayout.BeginScrollView (materialListScrollPos);
		
				foreach (MaterialDetails tDetails in ActiveMaterials) {			
						if (tDetails.material != null) {
								GUILayout.BeginHorizontal ();
				
								if (tDetails.material.mainTexture != null)
										GUILayout.Box (tDetails.material.mainTexture, GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
								else {
										GUILayout.Box ("n/a", GUILayout.Width (ThumbnailWidth), GUILayout.Height (ThumbnailHeight));
								}
				
								if (GUILayout.Button (tDetails.material.name, GUILayout.Width (150))) {
										SelectObject (tDetails.material, ctrlPressed);
								}
				
								string shaderLabel = tDetails.material.shader != null ? tDetails.material.shader.name : "no shader";
								GUILayout.Label (shaderLabel, GUILayout.Width (200));
				
								if (GUILayout.Button (tDetails.FoundInRenderers.Count + " GO", GUILayout.Width (50))) {
										List<Object> FoundObjects = new List<Object> ();
										foreach (Renderer renderer in tDetails.FoundInRenderers)
												FoundObjects.Add (renderer.gameObject);
										SelectObjects (FoundObjects, ctrlPressed);
								}
				
				
								GUILayout.EndHorizontal ();	
						}
				}
				EditorGUILayout.EndScrollView ();		
		}

19 Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 365082218

static public bool ShouldCreate (GameObject go, bool isValid)
	{
		GUI.color = isValid ? Color.green : Color.grey;

		GUILayout.BeginHorizontal();
		bool retVal = GUILayout.Button("Add To", GUILayout.Width(76f));
		GUI.color = Color.white;
		GameObject sel = EditorGUILayout.ObjectField(go, typeof(GameObject), true, GUILayout.Width(140f)) as GameObject;
		GUILayout.Label("Select the parent in the Hierarchy View", GUILayout.MinWidth(10000f));
		GUILayout.EndHorizontal();

		if (sel != go) Selection.activeGameObject = sel;

		if (retVal && isValid)
		{
			NGUIEditorTools.RegisterUndo("Add a Widget");
			return true;
		}
		return false;
	}

19 Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 365082218

void CreateLabel (GameObject go)
	{
		GUILayout.BeginHorizontal();
		Color c = EditorGUILayout.ColorField("Color", mColor, GUILayout.Width(220f));
		GUILayout.Label("Color tint the label will start with");
		GUILayout.EndHorizontal();

		if (mColor != c)
		{
			mColor = c;
			Save();
		}

		if (ShouldCreate(go, NGUISettings.font != null))
		{
			UILabel lbl = NGUITools.AddWidget<UILabel>(go);
			lbl.font = NGUISettings.font;
			lbl.text = "New Label";
			lbl.color = mColor;
			lbl.MakePixelPerfect();
			Selection.activeGameObject = lbl.gameObject;
		}
	}

19 Source : UICreateWidgetWizard.cs
with Apache License 2.0
from 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 Source : UIPanelInspector.cs
with Apache License 2.0
from 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 Source : CloudSettingsEditor.cs
with MIT License
from adrianpolimeni

private static Texture2D TextureField(string name, Texture2D texture)
        {
            GUILayout.BeginVertical();
            var style = new GUIStyle(GUI.skin.label);
            style.alignment = TextAnchor.UpperCenter;
            style.fixedWidth = 64;
            GUILayout.Label(name, style);
            var result = (Texture2D)EditorGUILayout.ObjectField(texture, typeof(Texture2D), false, GUILayout.Width(64), GUILayout.Height(64));
            GUILayout.EndVertical();
            return result;
        }

19 Source : ChatHistoryPanel.cs
with GNU General Public License v3.0
from aelariane

protected override void DrawMainPart()
        {
            rect.Reset();
            rect.MoveY();
            scrollRect.Reset();
            scrollArea.y = rect.y;

            if (messages.Count > 0)
            {
                scroll = BeginScrollView(scrollArea, scroll, scrollAreaView);
                UnityEngine.GUILayout.TextArea(showString, Style.Label, new GUILayoutOption[] { UnityEngine.GUILayout.Width(scrollArea.width) });
                //var options = new GUILayoutOption[0];
                //foreach (var msg in messages)
                //{
                //    GUILayout.Label(msg.ToString(), options);
                //}
                EndScrollView();
            }
        }

19 Source : Chat.cs
with GNU General Public License v3.0
from aelariane

protected override void OnEnable()
        {
            position = new Rect(0f, Style.ScreenHeight - 500, ChatWidth * (Style.WindowWidth / 700f), 470f);
            inputPosition = new Rect(30f, Style.ScreenHeight - 300 + 275, 300f * Style.WindowWidth / 700f + (30f * (Style.WindowWidth / 700f) - 30f), 25f);
            ChatStyle = new GUIStyle(Style.Label);
            ChatStyle.normal.textColor = Optimization.Caching.Colors.white;
            textFieldStyle = new GUIStyle(Style.TextField);
            textFieldStyle.fontSize = FontSize;
            if (UseBackground)
            {
                Texture2D black = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                black.SetPixel(0, 0, new Color(0f, 0f, 0f, BackgroundTransparency.Value));
                black.Apply();
                ChatStyle.normal.background = black;
            }
            ChatStyle.fontSize = FontSize;
            if (UseCustomChatSpace.Value)
            {
                ChatStyle.padding = new RectOffset(CustomChatSpaceLeft, CustomChatSpaceRight, CustomChatSpaceUp, CustomChatSpaceDown);
            }
            else
            {
                ChatStyle.padding = new RectOffset(0, 0, 0, 0);
            }
            ChatStyle.border = new RectOffset(0, 0, 0, 0);
            ChatStyle.margin = new RectOffset(0, 0, 0, 0);
            ChatStyle.overflow = new RectOffset(0, 0, 0, 0);
            //ChatStyle.fixedWidth = 330f * (Style.WindowWidth / 700f);
            labelOptions = UnityEngine.GUILayout.MinWidth(position.width);
            textFieldOptions = new GUILayoutOption[] { UnityEngine.GUILayout.Width(inputPosition.width) };
            scrollView = new Rect(0f, 0f, position.width, position.height);
            scrollAreaView = new Rect(0f, 0f, position.width, 2000f);
            scrollvector = Optimization.Caching.Vectors.v2zero;
        }

19 Source : Log.cs
with GNU General Public License v3.0
from aelariane

protected override void OnEnable()
        {
            locale.FormatColors();
            var cache = LogWidth * (Style.WindowWidth / 700f);
            position = new Rect(Style.ScreenWidth - cache, Style.ScreenHeight - 500f, cache, 470f);
            LogStyle = new GUIStyle(Style.Label);
            if (UseBackground)
            {
                Texture2D black = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                black.SetPixel(0, 0, new Color(0f, 0f, 0f, BackgroundTransparency.Value));
                black.Apply();
                LogStyle.normal.background = black;
            }
            LogStyle.fontSize = FontSize;
            if (UseCustomLogSpace.Value)
            {
                LogStyle.padding = new RectOffset(CustomLogSpaceLeft, CustomLogSpaceRight, CustomLogSpaceUp, CustomLogSpaceDown);
            }
            else
            {
                LogStyle.padding = new RectOffset(0, 0, 0, 0);
            }
            LogStyle.border = new RectOffset(0, 0, 0, 0);
            LogStyle.margin = new RectOffset(0, 0, 0, 0);
            LogStyle.overflow = new RectOffset(0, 0, 0, 0);
            labelOptions = UnityEngine.GUILayout.Width(position.width);
        }

19 Source : Chat.cs
with GNU General Public License v3.0
from aelariane

protected override void OnEnable()
        {
            position = new Rect(0f, Style.ScreenHeight - 500, ChatWidth * (Style.WindowWidth / 700f), 470f);
            inputPosition = new Rect(30f, Style.ScreenHeight - 300 + 275, 300f * Style.WindowWidth / 700f + (30f * (Style.WindowWidth / 700f) - 30f), 25f);
            ChatStyle = new GUIStyle(Style.Label);
            textFieldStyle = new GUIStyle(Style.TextField);
            textFieldStyle.fontSize = FontSize;
            if (UseBackground)
            {
                Texture2D black = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                black.SetPixel(0, 0, new Color(0f, 0f, 0f, BackgroundTransparency.Value));
                black.Apply();
                ChatStyle.normal.background = black;
            }
            ChatStyle.fontSize = FontSize;
            if (UseCustomChatSpace.Value)
            {
                ChatStyle.padding = new RectOffset(CustomChatSpaceLeft, CustomChatSpaceRight, CustomChatSpaceUp, CustomChatSpaceDown);
            }
            else
            {
                ChatStyle.padding = new RectOffset(0, 0, 0, 0);
            }
            ChatStyle.border = new RectOffset(0, 0, 0, 0);
            ChatStyle.margin = new RectOffset(0, 0, 0, 0);
            ChatStyle.overflow = new RectOffset(0, 0, 0, 0);
            //ChatStyle.fixedWidth = 330f * (Style.WindowWidth / 700f);
            labelOptions = UnityEngine.GUILayout.MinWidth(position.width);
            textFieldOptions = new GUILayoutOption[] { UnityEngine.GUILayout.Width(inputPosition.width) };
        }

19 Source : Log.cs
with GNU General Public License v3.0
from aelariane

protected override void OnEnable()
        {
            locale.FormatColors();
            var cache = LogWidth * (Style.WindowWidth / 700f);
            position = new Rect(Style.ScreenWidth - cache, Style.ScreenHeight - 500, cache, 470f);
            LogStyle = new GUIStyle(Style.Label);
            if (UseBackground)
            {
                Texture2D black = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                black.SetPixel(0, 0, new Color(0f, 0f, 0f, BackgroundTransparency.Value));
                black.Apply();
                LogStyle.normal.background = black;
            }
            LogStyle.fontSize = FontSize;
            if (UseCustomLogSpace.Value)
            {
                LogStyle.padding = new RectOffset(CustomLogSpaceLeft, CustomLogSpaceRight, CustomLogSpaceUp, CustomLogSpaceDown);
            }
            else
            {
                LogStyle.padding = new RectOffset(0, 0, 0, 0);
            }
            LogStyle.border = new RectOffset(0, 0, 0, 0);
            LogStyle.margin = new RectOffset(0, 0, 0, 0);
            LogStyle.overflow = new RectOffset(0, 0, 0, 0);
            labelOptions = UnityEngine.GUILayout.Width(position.width);
        }

19 Source : AssetDuplicateWindow.cs
with MIT License
from akof1314

protected override void DrawToolbarMore()
        {
            if (GUILayout.Button(replacedetDanshariStyle.Get().duplicateManualAdd, EditorStyles.toolbarButton, GUILayout.Width(70f)))
            {
                m_ManualAdd = true;
            }
        }

19 Source : AssetBaseWindow.cs
with MIT License
from akof1314

protected virtual void DrawGUI(GUIContent waiting, GUIContent nothing, bool expandCollapseComplex)
        {
            var style = replacedetDanshariStyle.Get();
            style.InitGUI();

            if (m_replacedetTreeModel.replacedetPaths != null)
            {
                if (!m_replacedetTreeModel.HasData())
                {
                    ShowNotification(nothing);
                    GUILayout.FlexibleSpace();
                }
                else
                {
                    EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                    if (expandCollapseComplex)
                    {
                        DrawToolbarExpandCollapse2();
                    }
                    else
                    {
                        DrawToolbarExpandCollapse();
                    }
                    EditorGUI.BeginChangeCheck();
                    m_replacedetTreeView.searchString = m_SearchField.OnToolbarGUI(m_replacedetTreeView.searchString);
                    if (EditorGUI.EndChangeCheck() && GUIUtility.keyboardControl == 0)
                    {
                        m_replacedetTreeView.SetFocusAndEnsureSelectedItem();
                    }
                    DrawToolbarMore();
                    if (GUILayout.Button(style.exportCsv, EditorStyles.toolbarButton, GUILayout.Width(70f)))
                    {
                        m_replacedetTreeModel.ExportCsv();
                    }
                    EditorGUILayout.EndHorizontal();
                    m_replacedetTreeView.OnGUI(GUILayoutUtility.GetRect(0, 100000, 0, 100000));
                }
                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                GUILayout.FlexibleSpace();
                EditorGUILayout.LabelField(m_replacedetTreeModel.replacedetPaths, style.labelStyle);
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                ShowNotification(waiting);
            }
        }

19 Source : AssetBaseWindow.cs
with MIT License
from akof1314

protected void DrawToolbarExpandCollapse()
        {
            if (GUILayout.Button(replacedetDanshariStyle.Get().expandAll, EditorStyles.toolbarButton, GUILayout.Width(50f)))
            {
                m_replacedetTreeView.ExpandAll();
            }
            if (GUILayout.Button(replacedetDanshariStyle.Get().collapseAll, EditorStyles.toolbarButton, GUILayout.Width(50f)))
            {
                m_replacedetTreeView.CollapseAll();
            }
        }

19 Source : AssetBaseWindow.cs
with MIT License
from akof1314

protected void DrawToolbarExpandCollapse2()
        {
            var style = replacedetDanshariStyle.Get();
            Rect toolBtnRect = GUILayoutUtility.GetRect(style.expandAll, EditorStyles.toolbarDropDown, GUILayout.Width(50f));
            if (GUI.Button(toolBtnRect, style.expandAll, EditorStyles.toolbarDropDown))
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(style.expandAll2, false, m_replacedetTreeView.ExpandAll);
                menu.AddItem(style.expandAll3, false, m_replacedetTreeView.ExpandAllExceptLast);
                menu.DropDown(toolBtnRect);
            }
            toolBtnRect = GUILayoutUtility.GetRect(style.collapseAll, EditorStyles.toolbarDropDown, GUILayout.Width(50f));
            if (GUI.Button(toolBtnRect, style.collapseAll, EditorStyles.toolbarDropDown))
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(style.collapseAll2, false, m_replacedetTreeView.CollapseAll);
                menu.AddItem(style.collapseAll3, false, m_replacedetTreeView.CollapseOnlyLast);
                menu.DropDown(toolBtnRect);
            }
        }

19 Source : ConsoleWindow.cs
with MIT License
from 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 Source : AssetDependenciesWindow.cs
with MIT License
from akof1314

protected override void DrawToolbarMore()
        {
            EditorGUI.BeginChangeCheck();
            m_FilterEmpty = GUILayout.Toggle(m_FilterEmpty, replacedetDanshariStyle.Get().dependenciesFilter, EditorStyles.toolbarButton,
                GUILayout.Width(70f));
            if (EditorGUI.EndChangeCheck() && m_replacedetTreeView != null)
            {
                (m_replacedetTreeView as replacedetDependenciesTreeView).SetFilterEmpty(m_FilterEmpty);
            }
        }

19 Source : ProductsWindow.cs
with GNU Lesser General Public License v3.0
from 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();
        }

19 Source : AttributesUtilityWindow.cs
with GNU Lesser General Public License v3.0
from ApexGameTools

private void OnGUI()
        {
            if (_refreshing)
            {
                if (!AttributesMaster.attributesEnabled)
                {
                    EditorGUILayout.HelpBox("Loading new Attributes file, please wait....", MessageType.Info);
                    return;
                }

                _refreshing = false;
            }

            var rect = EditorGUILayout.BeginVertical(GUILayout.Width(400), GUILayout.Height(400));
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);

            if (AttributesMaster.attributesEnabled)
            {
                if (string.IsNullOrEmpty(_fileLocation))
                {
                    EditorGUILayout.HelpBox("An attribute set has been defined, but it was not possible to find its file. Be sure to name the file the same as the enum.", MessageType.Info);
                    return;
                }
                else
                {
                    EditorGUILayout.HelpBox("An attribute set has been defined, and you can edit it below.\n\nPlease be aware that editing existing values will only change their name, not their value.\nTo delete a value simply remove its name.", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Welcome to the Attributes Utility.\nHere you can define an Attribute set to use with Apex products.", MessageType.Info);
            }

            DrawEntries();
            EditorGUILayout.EndScrollView();

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Remaining Slots:", (31 - _lastEntry).ToString());

            GUI.enabled = _isValid;
            if (AttributesMaster.attributesEnabled)
            {
                if (GUILayout.Button("Update Attribute Set"))
                {
                    WriteAttributeFile(_fileLocation, AttributesMaster.attributesEnumType.Name);
                    _refreshing = true;
                    replacedetDatabase.Refresh();
                }
            }
            else
            {
                if (GUILayout.Button("Create Attribute Set"))
                {
                    _fileLocation = Path.Combine(Application.dataPath, "ApexEnreplacedyAttributes.cs");
                    WriteAttributeFile(_fileLocation, "ApexEnreplacedyAttributes");
                    _refreshing = true;
                    replacedetDatabase.Refresh();
                }
            }

            GUI.enabled = true;

            EditorGUILayout.Separator();
            EditorGUILayout.EndVertical();
            this.minSize = new Vector2(rect.width, rect.height);
        }

19 Source : DefaultHeightNavigatorEditor.cs
with GNU Lesser General Public License v3.0
from ApexGameTools

private void DisplayProviderOptions()
        {
            if (_heightStrategyMissing)
            {
                EditorGUILayout.HelpBox("Unable to determine the height sampling mode since this is a prefab.\n Make sure to select a provider that is valid for the scene it is intended to be used in.", MessageType.Warning);
            }

            var label = new GUIContent("Height Sampler", "The height sampler to use, see the description on each below for details.");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(label, GUILayout.Width(EditorGUIUtility.labelWidth - 10f));

            var activeHeightMode = _heightStrategyMissing ? HeightSamplingMode.HeightMap : GameServices.heightStrategy.heightMode;
            var rootTarget = this.targets[0] as DefaultHeightNavigator;
            var refC = rootTarget.GetComponent<Collider>();
            var optionsIdx = ResolveOptionsIdx(refC, activeHeightMode);
            for (int i = 1; i < targets.Length; i++)
            {
                var b = this.targets[i] as MonoBehaviour;
                var c = b.GetComponent<Collider>();
                var tmpIdx = ResolveOptionsIdx(c, activeHeightMode);
                if (tmpIdx != optionsIdx)
                {
                    EditorGUILayout.LabelField("Multiple objects selected with different collider types.");
                    EditorGUILayout.EndHorizontal();
                    return;
                }
            }

            var options = _options[optionsIdx];
            var selectedIdx = -1;
            if (!_providerType.hasMultipleDifferentValues)
            {
                var selected = (ProviderType)_providerType.intValue;
                selectedIdx = options.FindIndex(selected);
                if (selectedIdx == -1)
                {
                    selectedIdx = 0;
                }
            }

            var newIdx = EditorGUILayout.Popup(selectedIdx, options.options);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.HelpBox(options.descriptions[newIdx], MessageType.Info);

            if (newIdx > -1)
            {
                _providerType.intValue = (int)options.providerMapping[newIdx];
            }
        }

19 Source : GridFieldUtilityWindow.cs
with GNU Lesser General Public License v3.0
from ApexGameTools

private void OnGUI()
        {
            var rect = EditorGUILayout.BeginVertical(GUILayout.Width(400), GUILayout.Height(400));
            EditorGUIUtility.labelWidth = 200f;

            EditorGUILayout.HelpBox("This tool allows you to easily generate a grid field, that is a number of grids sreplacedched together in order to cover a large scene", MessageType.Info);
            EditorGUILayout.Separator();

            EditorUtilities.Section("Field");

            _fieldSizeX = EditorGUILayout.IntField(new GUIContent("Grids along x-axis", "Number of grids along the x-axis."), _fieldSizeX);
            _fieldSizeZ = EditorGUILayout.IntField(new GUIContent("Grids along z-axis", "Number of grids along the x-axis."), _fieldSizeZ);
            _disableAutoInit = EditorGUILayout.Toggle(new GUIContent("Disable Automatic Initialization", "Sets the grid's automatic initialization setting to false."), _disableAutoInit);

            EditorGUILayout.Separator();
            _friendlyName = EditorGUILayout.TextField(new GUIContent("Grid Base Name", "An optional friendly name for the grids, each grid will also get a number post fix."), _friendlyName);

            EditorUtilities.Section("Layout");

            _sizeX = EditorGUILayout.IntField(new GUIContent("Size X", "Number of cells along the x-axis."), _sizeX);
            _sizeZ = EditorGUILayout.IntField(new GUIContent("Size Z", "Number of cells along the z-axis."), _sizeZ);

            _cellSize = EditorGUILayout.FloatField(new GUIContent("Cell Size", "The size of each grid cell, expressed as the length of one side."), _cellSize);
            _connectorPortalWidth = EditorGUILayout.FloatField(new GUIContent("Connector Portal Width", "The width of the connector portals.\nIf left at 0 it will default to the cellSize, but if larger units need to be able to traverse a connector the width must be set accordingly."), _connectorPortalWidth);
            _lowerBoundary = EditorGUILayout.FloatField(new GUIContent("Lower Boundary", "How far below the grid's plane does the grid have influence."), _lowerBoundary);
            _upperBoundary = EditorGUILayout.FloatField(new GUIContent("Upper Boundary", "How far above the grid's plane does the grid have influence."), _upperBoundary);
            _obstacleSensitivityRange = EditorGUILayout.FloatField(new GUIContent("Obstacle Sensitivity Range", "How close to the center of a cell must an obstacle be to block the cell."), _obstacleSensitivityRange);

            if (_obstacleSensitivityRange > (_cellSize / 2.0f))
            {
                _obstacleSensitivityRange = _cellSize / 2.0f;
            }

            EditorUtilities.Section("Subsections");

            _subSectionsX = EditorGUILayout.IntField(new GUIContent("Subsections X", "Number of subsections along the x-axis."), _subSectionsX);
            _subSectionsZ = EditorGUILayout.IntField(new GUIContent("Subsections Z", "Number of subsections along the z-axis."), _subSectionsZ);
            _subSectionsCellOverlap = EditorGUILayout.IntField(new GUIContent("Subsections Cell Overlap", "The number of cells by which subsections overlap neighbouring subsections."), _subSectionsCellOverlap);

            EditorGUI.indentLevel -= 1;
            EditorGUILayout.Separator();
            _generateHeightMap = EditorGUILayout.Toggle(new GUIContent("Generate Height Map", "Controls whether the grid generates a height map to allow height sensitive navigation."), _generateHeightMap);
            EditorGUI.indentLevel += 1;

            if (_generateHeightMap)
            {
                _heightLookupType = (HeightLookupType)EditorGUILayout.EnumPopup(new GUIContent("Lookup Type", "Dictionaries are fast but dense. Quad Trees are sparse but slower and are very dependent on height distributions. Use Quad trees on maps with large same height areas."), _heightLookupType);
                if (_heightLookupType == HeightLookupType.QuadTree)
                {
                    _heightLookupMaxDepth = EditorGUILayout.IntField(new GUIContent("Tree Depth", "The higher the allowed depth, the more sparse the tree will be but it will also get slower."), _heightLookupMaxDepth);
                }
            }

            EditorGUILayout.Separator();
            if (GUILayout.Button("Create Grid Field"))
            {
                CreateGridField();

                this.Close();
            }

            EditorGUILayout.Separator();
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndVertical();
            this.minSize = new Vector2(rect.width, rect.height);
        }

19 Source : HumanoidSpeedComponentEditor.cs
with GNU Lesser General Public License v3.0
from ApexGameTools

protected override void CreateUI()
        {
            base.CreateUI();

            if (Application.isPlaying)
            {
                EditorGUILayout.Separator();
                GUILayout.BeginHorizontal();
                _customSpeed = EditorGUILayout.FloatField(_customSpeed, GUILayout.Width(100));
                if (GUILayout.Button("Test Custom Speed"))
                {
                    var targets = this.targets;
                    var count = targets.Length;
                    for (int i = 0; i < count; i++)
                    {
                        var hs = targets[i] as HumanoidSpeedComponent;
                        hs.SetPreferredSpeed(_customSpeed);
                        _customSpeed = Mathf.Min(_customSpeed, hs.maximumSpeed);
                    }
                }

                GUILayout.EndHorizontal();
            }
        }

19 Source : ProductsWindow.cs
with GNU Lesser General Public License v3.0
from ApexGameTools

private void CreateFooter()
        {
            EditorGUILayout.BeginVertical("Box");

            //Auto update settings
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Automatic update checking is ", _styles.labelNoStretch);

            if (_settings.allowAutomaticUpdateCheck)
            {
                if (GUILayout.Button("on", _styles.labelOn))
                {
                    _settings.allowAutomaticUpdateCheck = !_settings.allowAutomaticUpdateCheck;
                }

                EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);

                GUILayout.Label(" every ", _styles.labelNoStretch);
                _settings.updateCheckIntervalHours = EditorGUILayout.IntField(_settings.updateCheckIntervalHours, _styles.smallIntField, GUILayout.Width(40f));
                GUILayout.Label(" hours.", _styles.labelNoStretch);
            }
            else
            {
                if (GUILayout.Button("off", _styles.labelOff))
                {
                    _settings.allowAutomaticUpdateCheck = !_settings.allowAutomaticUpdateCheck;
                }

                EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            }

            EditorGUILayout.EndHorizontal();

            //Last update check info
            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();
            string lastUpdateCheck = GetTimeSinceUpdate();
            GUILayout.Label("Last update check was", _styles.labelNoStretch);
            GUILayout.Label(lastUpdateCheck, _styles.labelNoStretch);
            EditorGUILayout.EndHorizontal();

            //Manual update
            if (GUILayout.Button("Check for Updates Now"))
            {
                _products = null;
                ProductManager.GetProductsInfoAsync(
                    _settings,
                    true,
                    prods =>
                    {
                        _products = prods;
                    });
            }

            EditorGUILayout.EndVertical();
        }

19 Source : AIInvestigator.cs
with GNU Lesser General Public License v3.0
from ApexGameTools

private void DrawAIOverviewComplete()
        {
            if (_referencers == null)
            {
                _aiStep = Step.Start;
                return;
            }

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Below you can see which AIs are in use in which scenes and prefabs.", SharedStyles.BuiltIn.wrappedText);
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            if (GUILayout.Button("Expand All", EditorStyles.toolbarButton))
            {
                _referencers.Apply(s => s.indirectExpanded = s.directExpanded = true);
                _aisList.Apply(ai => ai.directReferencesExpanded = ai.indirectReferencesExpanded = ai.directAIsExpanded = ai.indirectAIsExpanded = ai.directScenesOrPrefabsExpanded = ai.indirectScenesOrPrefabsExpanded = true);
            }

            if (GUILayout.Button("Collapse All", EditorStyles.toolbarButton))
            {
                _referencers.Apply(s => s.indirectExpanded = s.directExpanded = false);
                _aisList.Apply(ai => ai.directReferencesExpanded = ai.indirectReferencesExpanded = ai.directAIsExpanded = ai.indirectAIsExpanded = ai.directScenesOrPrefabsExpanded = ai.indirectScenesOrPrefabsExpanded = false);
            }

            if (GUILayout.Button("Copy", EditorStyles.toolbarButton))
            {
                EditorGUIUtility.systemCopyBuffer = Export();
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.LabelField("Group by", GUILayout.Width(60f));
            _aiGrouping = (AIGrouping)GUILayout.SelectionGrid((int)_aiGrouping, _aiGroupingTabreplacedles, 2, EditorStyles.toolbarButton);
            EditorGUILayout.EndHorizontal();

            if (_aiGrouping == AIGrouping.ScenesAndPrefabs)
            {
                _sceneScrollPos = EditorGUILayout.BeginScrollView(_sceneScrollPos, "Box");
                EditorGUILayout.LabelField("Scenes", SharedStyles.BuiltIn.centeredWrappedText);
                foreach (var scene in _referencers.Where(item => !item.isPrefab))
                {
                    DrawSceneOrPrefabLisreplacedem(scene);
                }

                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Prefabs", SharedStyles.BuiltIn.centeredWrappedText);
                foreach (var prefab in _referencers.Where(item => item.isPrefab))
                {
                    DrawSceneOrPrefabLisreplacedem(prefab);
                }

                EditorGUILayout.EndScrollView();
            }
            else
            {
                _aiScrollPos = EditorGUILayout.BeginScrollView(_aiScrollPos, "Box");
                EditorGUILayout.LabelField("AIs", SharedStyles.BuiltIn.centeredWrappedText);
                foreach (var aiRef in _aisList)
                {
                    DrawAILisreplacedem(aiRef);
                }

                EditorGUILayout.EndScrollView();
            }

            if (GUILayout.Button("Back"))
            {
                _aiScrollPos = _sceneScrollPos = Vector2.zero;
                _aiStep = Step.Start;
            }
        }

See More Examples