UnityEngine.GUILayout.BeginHorizontal(UnityEngine.GUIContent, UnityEngine.GUIStyle, params UnityEngine.GUILayoutOption[])

Here are the examples of the csharp api UnityEngine.GUILayout.BeginHorizontal(UnityEngine.GUIContent, UnityEngine.GUIStyle, params UnityEngine.GUILayoutOption[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

358 Examples 7

private void OnGUI()
        {
            //m_BluePrintList = Q_InventoryMainEditorWindow.inventoryItemList.bluePrints;
            GUILayout.Label("Crafting Editor", labelStyle);
            GUILayout.Space(10);

            //if(inventoryItemList.bluePrints == null)
            //{
            //    inventoryItemList.bluePrints = new List<CraftingBluePrint>();
            //    window.Repaint();
            //}
            using (var h = new EditorGUILayout.HorizontalScope())
            {
                using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos))
                {
                    scrollPos = scrollView.scrollPosition;
                    if (GUILayout.Button("Create New BluePrint"))
                    {
                        CreateNewBluePrint();
                    }

                    GUILayout.Space(10);

                    if (inventoryItemList.bluePrints.Count > 0)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false)))
                        {
                            ClearReorderableList();
                            if (viewIndex > 1)
                                viewIndex--;
                            else if (viewIndex == 1)
                                viewIndex = inventoryItemList.bluePrints.Count;
                            InitializeReorderableList();
                        }

                        GUILayout.Space(5);

                        if (GUILayout.Button("Next", GUILayout.ExpandWidth(false)))
                        {
                            ClearReorderableList();
                            if (viewIndex < inventoryItemList.bluePrints.Count)
                            {
                                viewIndex++;
                            }

                            else if (viewIndex == inventoryItemList.bluePrints.Count)
                            {
                                viewIndex = 1;
                            }
                            InitializeReorderableList();
                        }


                        GUILayout.Space(180);

                        if (GUILayout.Button("Delete BluePrint", GUILayout.ExpandWidth(false)))
                        {
                            DeleteBluePrint(viewIndex - 1);
                        }

                        GUILayout.EndHorizontal();

                        if (inventoryItemList.bluePrints.Count > 0)
                        {
                            GUILayout.BeginHorizontal();

                            viewIndex = Mathf.Clamp(EditorGUILayout.IntField("Current BluePrint", viewIndex, GUILayout.ExpandWidth(false)), 1, inventoryItemList.bluePrints.Count);
                            EditorGUILayout.LabelField("of   " + inventoryItemList.bluePrints.Count.ToString() + "  BluePrint", "", GUILayout.ExpandWidth(false));

                            GUILayout.EndHorizontal();

                            GUILayout.Space(10);
                            //数据显示
                            //name
                            EditorGUI.BeginChangeCheck();
                            inventoryItemList.bluePrints[viewIndex - 1].bluePrintName = EditorGUILayout.DelayedTextField("BluePrint Name", inventoryItemList.bluePrints[viewIndex - 1].bluePrintName as string);
                            if (EditorGUI.EndChangeCheck())
                            {
                                replacedetDatabase.Renamereplacedet(EditorPrefs.GetString("DatabasePath") + "/BluePrints/" + inventoryItemList.bluePrints[viewIndex - 1].name + ".replacedet", inventoryItemList.bluePrints[viewIndex - 1].bluePrintName);
                                replacedetDatabase.Savereplacedets();
                            }
                            GUILayout.Space(5);
                            //icon
                            inventoryItemList.bluePrints[viewIndex - 1].icon = EditorGUILayout.ObjectField("BluePrint Icon", inventoryItemList.bluePrints[viewIndex - 1].icon, typeof(Sprite), false) as Sprite;
                            GUILayout.Space(5);
                            //target
                            inventoryItemList.bluePrints[viewIndex - 1].targereplacedem = EditorGUILayout.ObjectField("Product", inventoryItemList.bluePrints[viewIndex - 1].targereplacedem, typeof(Item), false) as Item;
                            GUILayout.Space(5);
                            //amount after crafting
                            inventoryItemList.bluePrints[viewIndex - 1].craftingAmount = Mathf.Clamp(EditorGUILayout.IntField("Product Amount", inventoryItemList.bluePrints[viewIndex - 1].craftingAmount), 0, 9999999);
                            GUILayout.Space(5);
                            //Success Chance
                            inventoryItemList.bluePrints[viewIndex - 1].successChance = Mathf.Clamp(EditorGUILayout.FloatField("Success Chance", inventoryItemList.bluePrints[viewIndex - 1].successChance), 0, 1);
                            GUILayout.Space(5);
                            //Crafting Time
                            inventoryItemList.bluePrints[viewIndex - 1].craftingTime = Mathf.Clamp(EditorGUILayout.FloatField("Crafting Time", inventoryItemList.bluePrints[viewIndex - 1].craftingTime), 0, 9999999);
                            GUILayout.Space(5);
                            //move after crafting
                            inventoryItemList.bluePrints[viewIndex - 1].moveAfterCrafting = EditorGUILayout.Toggle("Moved After Crafting", inventoryItemList.bluePrints[viewIndex - 1].moveAfterCrafting, GUILayout.ExpandWidth(false));
                            GUILayout.Space(10);


                            //ingredients
                            GUILayout.Label("Ingredients");
                            if (m_BluePrintList != null && m_BluePrintSerializedObject != null)
                            {
                                m_BluePrintSerializedObject.ApplyModifiedProperties();
                                m_BluePrintSerializedObject.Update();
                                m_BluePrintList.DoLayoutList();
                                m_BluePrintSerializedObject.ApplyModifiedProperties();
                            }

                            GUILayout.Space(10);

                            //prices
                            GUILayout.Label("Prices");
                            if (m_BuyPriceList != null && m_BuySerializedObject != null)
                            {
                                m_BuySerializedObject.ApplyModifiedProperties();
                                m_BuySerializedObject.Update();
                                m_BuyPriceList.DoLayoutList();
                                m_BuySerializedObject.ApplyModifiedProperties();
                            }
                        }

                    }

                    else
                    {
                        GUILayout.Space(50);
                        GUILayout.Label("Don't Have A BluePrint", normalCenterStyle);
                    }
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(inventoryItemList);
                if (viewIndex > 0)
                    EditorUtility.SetDirty(inventoryItemList.bluePrints[viewIndex - 1]);
            }
        }

19 View Source File : TimelineWindow_HeaderGui.cs
License : MIT License
Project Creator : BattleDawnNZ

void SequencerHeaderGUI()
        {
            using (new EditorGUI.DisabledScope(state.editSequence.replacedet == null))
            {
                GUILayout.BeginVertical();
                {
                    TransportToolbarGUI();

                    GUILayout.BeginHorizontal(GUILayout.Width(sequenceHeaderRect.width));
                    {
                        if (state.editSequence.replacedet != null)
                        {
                            GUILayout.Space(DirectorStyles.kBaseIndent);
                            AddButtonGUI();
                            GUILayout.FlexibleSpace();
                            EditModeToolbarGUI(currentMode);
                            ShowMarkersButton();
                            EditorGUILayout.Space();
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
        }

19 View Source File : UIFontMaker.cs
License : Apache License 2.0
Project Creator : 365082218

void OnGUI ()
	{
		string prefabPath = "";
		string matPath = "";

		if (NGUISettings.font != null && NGUISettings.font.name == NGUISettings.fontName)
		{
			prefabPath = replacedetDatabase.GetreplacedetPath(NGUISettings.font.gameObject.GetInstanceID());
			if (NGUISettings.font.material != null) matPath = replacedetDatabase.GetreplacedetPath(NGUISettings.font.material.GetInstanceID());
		}

		// replacedume default values if needed
		if (string.IsNullOrEmpty(NGUISettings.fontName)) NGUISettings.fontName = "New Font";
		if (string.IsNullOrEmpty(prefabPath)) prefabPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".prefab";
		if (string.IsNullOrEmpty(matPath)) matPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.fontName + ".mat";

		EditorGUIUtility.LookLikeControls(80f);
		NGUIEditorTools.DrawHeader("Input");

		GUILayout.BeginHorizontal();
		mType = (FontType)EditorGUILayout.EnumPopup("Type", mType);
		GUILayout.Space(18f);
		GUILayout.EndHorizontal();
		int create = 0;

		if (mType == FontType.Dynamic)
		{
			NGUISettings.dynamicFont = EditorGUILayout.ObjectField("Font TTF", NGUISettings.dynamicFont, typeof(Font), false) as Font;

			GUILayout.BeginHorizontal();
			NGUISettings.dynamicFontSize = EditorGUILayout.IntField("Font Size", NGUISettings.dynamicFontSize, GUILayout.Width(120f));
			NGUISettings.dynamicFontStyle = (FontStyle)EditorGUILayout.EnumPopup(NGUISettings.dynamicFontStyle);
			GUILayout.Space(18f);
			GUILayout.EndHorizontal();

			if (NGUISettings.dynamicFont != null)
			{
				NGUIEditorTools.DrawHeader("Output");

				GUILayout.BeginHorizontal();
				GUILayout.Label("Font Name", GUILayout.Width(76f));
				GUI.backgroundColor = Color.white;
				NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);
				GUILayout.EndHorizontal();
			}
			NGUIEditorTools.DrawSeparator();

#if UNITY_3_5
			EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
			// Helpful info
			if (NGUISettings.dynamicFont == null)
			{
				EditorGUILayout.HelpBox("Dynamic font creation happens right in Unity. Simply specify the TrueType font to be used as source.", MessageType.Info);
			}
			EditorGUILayout.HelpBox("Please note that dynamic fonts can't be made a part of an atlas, and they will always be drawn in a separate draw call. You WILL need to adjust transform position's Z rather than depth!", MessageType.Warning);

			if (NGUISettings.dynamicFont != null)
			{
				NGUIEditorTools.DrawSeparator();

				GUILayout.BeginHorizontal();
				GUILayout.FlexibleSpace();
				GUI.backgroundColor = Color.green;

				GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;

				if (go != null)
				{
					if (go.GetComponent<UIFont>() != null)
					{
						GUI.backgroundColor = Color.red;
						if (GUILayout.Button("Replace the Font", GUILayout.Width(140f))) create = 1;
					}
					else
					{
						GUI.backgroundColor = Color.grey;
						GUILayout.Button("Rename Your Font", GUILayout.Width(140f));
					}
				}
				else
				{
					GUI.backgroundColor = Color.green;
					if (GUILayout.Button("Create the Font", GUILayout.Width(140f))) create = 1;
				}

				GUI.backgroundColor = Color.white;
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
			}
#endif
		}
		else
		{
			NGUISettings.fontData = EditorGUILayout.ObjectField("Font Data", NGUISettings.fontData, typeof(Textreplacedet), false) as Textreplacedet;
			NGUISettings.fontTexture = EditorGUILayout.ObjectField("Texture", NGUISettings.fontTexture, typeof(Texture2D), false) as Texture2D;

			// Draw the atlas selection only if we have the font data and texture specified, just to make it easier
			if (NGUISettings.fontData != null && NGUISettings.fontTexture != null)
			{
				NGUIEditorTools.DrawHeader("Output");

				GUILayout.BeginHorizontal();
				GUILayout.Label("Font Name", GUILayout.Width(76f));
				GUI.backgroundColor = Color.white;
				NGUISettings.fontName = GUILayout.TextField(NGUISettings.fontName);
				GUILayout.EndHorizontal();

				ComponentSelector.Draw<UIFont>("Select", NGUISettings.font, OnSelectFont);
				ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas);
			}
			NGUIEditorTools.DrawSeparator();

			// Helpful info
			if (NGUISettings.fontData == null)
			{
				EditorGUILayout.HelpBox("The bitmap font creation mostly takes place outside of Unity. You can use BMFont on" +
					"Windows or your choice of Glyph Designer or the less expensive bmGlyph on the Mac.\n\n" +
					"Either of these tools will create a FNT file for you that you will drag & drop into the field above.", MessageType.Info);
			}
			else if (NGUISettings.fontTexture == null)
			{
				EditorGUILayout.HelpBox("When exporting your font, you should get two files: the TXT, and the texture. Only one texture can be used per font.", MessageType.Info);
			}
			else if (NGUISettings.atlas == null)
			{
				EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
					"labels using this font will generate an extra draw call, and will need to be sorted by " +
					"adjusting the Z instead of the Depth.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);

				NGUIEditorTools.DrawSeparator();

				GUILayout.BeginHorizontal();
				GUILayout.FlexibleSpace();
				GUI.backgroundColor = Color.red;
				if (GUILayout.Button("Create a Font without an Atlas", GUILayout.Width(200f))) create = 2;
				GUI.backgroundColor = Color.white;
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
			}
			else
			{
				GUILayout.BeginHorizontal();
				GUILayout.FlexibleSpace();

				GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;

				if (go != null)
				{
					if (go.GetComponent<UIFont>() != null)
					{
						GUI.backgroundColor = Color.red;
						if (GUILayout.Button("Replace the Font", GUILayout.Width(140f))) create = 3;
					}
					else
					{
						GUI.backgroundColor = Color.grey;
						GUILayout.Button("Rename Your Font", GUILayout.Width(140f));
					}
				}
				else
				{
					GUI.backgroundColor = Color.green;
					if (GUILayout.Button("Create the Font", GUILayout.Width(140f))) create = 3;
				}
				GUI.backgroundColor = Color.white;
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
			}
		}

		if (create != 0)
		{
			GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;

			if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
				NGUISettings.fontName + " font with the currently selected values? This action can't be undone.", "Yes", "No"))
			{
				// Try to load the material
				Material mat = null;
				
				// Non-atlased font
				if (create == 2)
				{
					mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;

					// If the material doesn't exist, create it
					if (mat == null)
					{
						Shader shader = Shader.Find("Unlit/Transparent Colored");
						mat = new Material(shader);

						// Save the material
						replacedetDatabase.Createreplacedet(mat, matPath);
						replacedetDatabase.Refresh();

						// Load the material so it's usable
						mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
					}
					mat.mainTexture = NGUISettings.fontTexture;
				}

				// Font doesn't exist yet
				if (go == null || go.GetComponent<UIFont>() == null)
				{
					// Create a new prefab for the atlas
					Object prefab = CreateEmptyPrefab(prefabPath);

					// Create a new game object for the font
					go = new GameObject(NGUISettings.fontName);
					NGUISettings.font = go.AddComponent<UIFont>();
					CreateFont(NGUISettings.font, create, mat);

					// Update the prefab
					ReplacePrefab(go, prefab);
					DestroyImmediate(go);
					replacedetDatabase.Refresh();

					// Select the atlas
					go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
					NGUISettings.font = go.GetComponent<UIFont>();
				}
				else
				{
					NGUISettings.font = go.GetComponent<UIFont>();
					CreateFont(NGUISettings.font, create, mat);
				}
				MarkAsChanged();
			}
		}
	}

19 View Source File : TMP_FontAssetEditor.cs
License : MIT License
Project Creator : ashishgopalhattimare

public override void OnInspectorGUI()
        {
            // Check Warnings


            //Debug.Log("OnInspectorGUI Called.");
            Event currentEvent = Event.current;

            serializedObject.Update();

            // TextMeshPro Font Info Panel
            Rect rect = EditorGUILayout.GetControlRect();

            
            GUI.Label(rect, "Face Info", EditorStyles.boldLabel);

            rect.x += rect.width - 130f;
            rect.width = 130f;

            if (GUI.Button(rect, "Update Atlas Texture"))
            {
                TMPro_FontreplacedetCreatorWindow.ShowFontAtlasCreatorWindow(target as TMP_Fontreplacedet);
            }


            EditorGUI.indentLevel = 1;

            GUI.enabled = false; // Lock UI

            float labelWidth = EditorGUIUtility.labelWidth;
            float fieldWidth = EditorGUIUtility.fieldWidth;

            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Name"), new GUIContent("Font Source"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("PointSize"));

            GUI.enabled = true;
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Scale"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("LineHeight"));

            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Ascender"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("CapHeight"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Baseline"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Descender"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Underline"), new GUIContent("Underline Offset"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("strikethrough"), new GUIContent("Strikethrough Offset"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("SuperscriptOffset"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("SubscriptOffset"));
            
            SerializedProperty subSize_prop = m_fontInfo_prop.FindPropertyRelative("SubSize");
            EditorGUILayout.PropertyField(subSize_prop, new GUIContent("Super / Subscript Size"));
            subSize_prop.floatValue = Mathf.Clamp(subSize_prop.floatValue, 0.25f, 1f);
            

            GUI.enabled = false;
            //EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Padding"));

            //GUILayout.label("Atlas Size");
            EditorGUI.indentLevel = 1;
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Padding"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("AtlasWidth"), new GUIContent("Width"));
            EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("AtlasHeight"), new GUIContent("Height"));
            
            GUI.enabled = true;

            EditorGUILayout.Space();

            EditorGUI.indentLevel = 0;
            UI_PanelState.fontSubreplacedetsPanel = EditorGUILayout.Foldout(UI_PanelState.fontSubreplacedetsPanel, new GUIContent("Font Sub-replacedets"), true, TMP_UIStyleManager.boldFoldout);

            if (UI_PanelState.fontSubreplacedetsPanel)
            {
                GUI.enabled = false;
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField(font_atlas_prop, new GUIContent("Font Atlas"));
                EditorGUILayout.PropertyField(font_material_prop, new GUIContent("Font Material"));
                GUI.enabled = true;
                EditorGUILayout.Space();
            }
            
            string evt_cmd = Event.current.commandName; // Get Current Event CommandName to check for Undo Events

            // FONT SETTINGS
            EditorGUI.indentLevel = 0;
            UI_PanelState.fontWeightPanel = EditorGUILayout.Foldout(UI_PanelState.fontWeightPanel, new GUIContent("Font Weights", "The Font replacedets that will be used for different font weights and the settings used to simulate a typeface when no replacedet is available."), true, TMP_UIStyleManager.boldFoldout);

            if (UI_PanelState.fontWeightPanel)
            {
                EditorGUIUtility.labelWidth *= 0.75f;
                EditorGUIUtility.fieldWidth *= 0.25f;

                EditorGUILayout.BeginVertical();
                EditorGUI.indentLevel = 1;
                rect = EditorGUILayout.GetControlRect(true);
                rect.x += EditorGUIUtility.labelWidth;
                rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2f;
                GUI.Label(rect, "Normal Style", EditorStyles.boldLabel);
                rect.x += rect.width;
                GUI.Label(rect, "Italic Style", EditorStyles.boldLabel);
                
                EditorGUI.indentLevel = 1;

                //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(1), new GUIContent("100 - Thin"));
                //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(2), new GUIContent("200 - Extra-Light"));
                //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(3), new GUIContent("300 - Light"));
                EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(4), new GUIContent("400 - Regular"));
                //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(5), new GUIContent("500 - Medium"));
                //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(6), new GUIContent("600 - Demi-Bold"));
                EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(7), new GUIContent("700 - Bold"));
                //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(8), new GUIContent("800 - Heavy"));
                //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(9), new GUIContent("900 - Black"));

                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.BeginVertical();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(font_normalStyle_prop, new GUIContent("Normal Weight"));
                font_normalStyle_prop.floatValue = Mathf.Clamp(font_normalStyle_prop.floatValue, -3.0f, 3.0f);
                if (GUI.changed || evt_cmd == k_UndoRedo)
                {
                    GUI.changed = false;

                    // Modify the material property on matching material presets.
                    for (int i = 0; i < m_materialPresets.Length; i++)
                        m_materialPresets[i].SetFloat("_WeightNormal", font_normalStyle_prop.floatValue);
                }

                EditorGUILayout.PropertyField(font_boldStyle_prop, new GUIContent("Bold Weight"));
                font_boldStyle_prop.floatValue = Mathf.Clamp(font_boldStyle_prop.floatValue, -3.0f, 3.0f);
                if (GUI.changed || evt_cmd == k_UndoRedo)
                {
                    GUI.changed = false;

                    // Modify the material property on matching material presets.
                    for (int i = 0; i < m_materialPresets.Length; i++)
                        m_materialPresets[i].SetFloat("_WeightBold", font_boldStyle_prop.floatValue);
                }
                EditorGUILayout.EndHorizontal();
                
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(font_normalSpacing_prop, new GUIContent("Spacing Offset"));
                font_normalSpacing_prop.floatValue = Mathf.Clamp(font_normalSpacing_prop.floatValue, -100, 100);
                if (GUI.changed || evt_cmd == k_UndoRedo)
                {
                    GUI.changed = false;
                }

                EditorGUILayout.PropertyField(font_boldSpacing_prop, new GUIContent("Bold Spacing"));
                font_boldSpacing_prop.floatValue = Mathf.Clamp(font_boldSpacing_prop.floatValue, 0, 100);
                if (GUI.changed || evt_cmd == k_UndoRedo)
                {
                    GUI.changed = false;
                }
                EditorGUILayout.EndHorizontal();
                
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(font_italicStyle_prop, new GUIContent("Italic Style"));
                font_italicStyle_prop.intValue = Mathf.Clamp(font_italicStyle_prop.intValue, 15, 60);
                
                EditorGUILayout.PropertyField(font_tabSize_prop, new GUIContent("Tab Multiple"));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();
            }

            EditorGUIUtility.labelWidth = 0;
            EditorGUIUtility.fieldWidth = 0;
            
            // FALLBACK FONT replacedETS
            EditorGUI.indentLevel = 0;
            UI_PanelState.fallbackFontreplacedetPanel = EditorGUILayout.Foldout(UI_PanelState.fallbackFontreplacedetPanel, new GUIContent("Fallback Font replacedets", "Select the Font replacedets that will be searched and used as fallback when characters are missing from this font replacedet."), true, TMP_UIStyleManager.boldFoldout);

            if (UI_PanelState.fallbackFontreplacedetPanel)
            {
                EditorGUIUtility.labelWidth = 120;
                EditorGUI.indentLevel = 0;

                m_list.DoLayoutList();
                EditorGUILayout.Space();
            }

            // GLYPH INFO TABLE
            #region Glyph Table
            EditorGUIUtility.labelWidth = labelWidth;
            EditorGUIUtility.fieldWidth = fieldWidth;
            EditorGUI.indentLevel = 0;

            UI_PanelState.glyphInfoPanel = EditorGUILayout.Foldout(UI_PanelState.glyphInfoPanel, new GUIContent("Glyph Table"), true, TMP_UIStyleManager.boldFoldout);

            if (UI_PanelState.glyphInfoPanel)
            {
                int arraySize = m_glyphInfoList_prop.arraySize;
                int itemsPerPage = 15;

                // Display Glyph Management Tools
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    // Search Bar implementation
                    #region DISPLAY SEARCH BAR
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUIUtility.labelWidth = 130f;
                        EditorGUI.BeginChangeCheck();
                        string searchPattern = EditorGUILayout.TextField("Glyph Search", m_GlyphSearchPattern, "SearchTextField");
                        if (EditorGUI.EndChangeCheck() || m_isSearchDirty)
                        {
                            if (string.IsNullOrEmpty(searchPattern) == false)
                            {
                                m_GlyphSearchPattern = searchPattern;

                                // Search Glyph Table for potential matches
                                SearchGlyphTable(m_GlyphSearchPattern, ref m_GlyphSearchList);
                            }
                            else
                                m_GlyphSearchPattern = null;

                            m_isSearchDirty = false;
                        }

                        string styleName = string.IsNullOrEmpty(m_GlyphSearchPattern) ? "SearchCancelButtonEmpty" : "SearchCancelButton";
                        if (GUILayout.Button(GUIContent.none, styleName))
                        {
                            GUIUtility.keyboardControl = 0;
                            m_GlyphSearchPattern = string.Empty;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    #endregion

                    // Display Page Navigation
                    if (!string.IsNullOrEmpty(m_GlyphSearchPattern))
                        arraySize = m_GlyphSearchList.Count;

                    DisplayPageNavigation(ref m_CurrentGlyphPage, arraySize, itemsPerPage);
                }
                EditorGUILayout.EndVertical();

                // Display Glyph Table Elements
                
                if (arraySize > 0)
                {
                    // Display each GlyphInfo entry using the GlyphInfo property drawer.
                    for (int i = itemsPerPage * m_CurrentGlyphPage; i < arraySize && i < itemsPerPage * (m_CurrentGlyphPage + 1); i++)
                    {
                        // Define the start of the selection region of the element.
                        Rect elementStartRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));

                        int elementIndex = i;
                        if (!string.IsNullOrEmpty(m_GlyphSearchPattern))
                            elementIndex = m_GlyphSearchList[i];
                            
                        SerializedProperty glyphInfo = m_glyphInfoList_prop.GetArrayElementAtIndex(elementIndex);

                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                        
                        EditorGUI.BeginDisabledGroup(i != m_SelectedGlyphRecord);
                        {
                            EditorGUILayout.PropertyField(glyphInfo);
                        }
                        EditorGUI.EndDisabledGroup();

                        EditorGUILayout.EndVertical();

                        // Define the end of the selection region of the element.
                        Rect elementEndRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));

                        // Check for Item selection
                        Rect selectionArea = new Rect(elementStartRegion.x, elementStartRegion.y, elementEndRegion.width, elementEndRegion.y - elementStartRegion.y);
                        if (DoSelectionCheck(selectionArea))
                        {
                            if (m_SelectedGlyphRecord == i)
                                m_SelectedGlyphRecord = -1;
                            else
                            {
                                m_SelectedGlyphRecord = i;
                                m_AddGlyphWarning.isEnabled = false;
                                m_unicodeHexLabel = k_placeholderUnicodeHex;
                                GUIUtility.keyboardControl = 0;
                            }
                        }

                        // Draw Selection Highlight and Glyph Options
                        if (m_SelectedGlyphRecord == i)
                        {
                            TMP_EditorUtility.DrawBox(selectionArea, 2f, new Color32(40, 192, 255, 255));

                            // Draw Glyph management options
                            Rect controlRect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * 1f);
                            float optionAreaWidth = controlRect.width * 0.6f;
                            float btnWidth = optionAreaWidth / 3;

                            Rect position = new Rect(controlRect.x + controlRect.width * .4f, controlRect.y, btnWidth, controlRect.height);

                            // Copy Selected Glyph to Target Glyph ID
                            GUI.enabled = !string.IsNullOrEmpty(m_dstGlyphID);
                            if (GUI.Button(position, new GUIContent("Copy to")))
                            {
                                GUIUtility.keyboardControl = 0;

                                // Convert Hex Value to Decimal
                                int dstGlyphID = TMP_TextUtilities.StringToInt(m_dstGlyphID);

                                //Add new glyph at target Unicode hex id.
                                if (!AddNewGlyph(elementIndex, dstGlyphID))
                                {
                                    m_AddGlyphWarning.isEnabled = true;
                                    m_AddGlyphWarning.expirationTime = EditorApplication.timeSinceStartup + 1;
                                }

                                m_dstGlyphID = string.Empty;
                                m_isSearchDirty = true;

                                TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, m_fontreplacedet);
                            }

                            // Target Glyph ID
                            GUI.enabled = true;
                            position.x += btnWidth;

                            GUI.SetNextControlName("GlyphID_Input");
                            m_dstGlyphID = EditorGUI.TextField(position, m_dstGlyphID);

                            // Placeholder text
                            EditorGUI.LabelField(position, new GUIContent(m_unicodeHexLabel, "The Unicode (Hex) ID of the duplicated Glyph"), TMP_UIStyleManager.label);

                            // Only filter the input when the destination glyph ID text field has focus.
                            if (GUI.GetNameOfFocusedControl() == "GlyphID_Input")
                            {
                                m_unicodeHexLabel = string.Empty;

                                //Filter out unwanted characters.
                                char chr = Event.current.character;
                                if ((chr < '0' || chr > '9') && (chr < 'a' || chr > 'f') && (chr < 'A' || chr > 'F'))
                                {
                                    Event.current.character = '\0';
                                }
                            }
                            else
                                m_unicodeHexLabel = k_placeholderUnicodeHex;


                            // Remove Glyph
                            position.x += btnWidth;
                            if (GUI.Button(position, "Remove"))
                            {
                                GUIUtility.keyboardControl = 0;

                                RemoveGlyphFromList(elementIndex);

                                isreplacedetDirty = true;
                                m_SelectedGlyphRecord = -1;
                                m_isSearchDirty = true;
                                break;
                            }

                            if (m_AddGlyphWarning.isEnabled && EditorApplication.timeSinceStartup < m_AddGlyphWarning.expirationTime)
                            {
                                EditorGUILayout.HelpBox("The Destination Glyph ID already exists", MessageType.Warning);
                            }

                        }
                    }
                }

                DisplayPageNavigation(ref m_CurrentGlyphPage, arraySize, itemsPerPage);

                EditorGUILayout.Space();
            }
            #endregion


            // KERNING TABLE PANEL
            #region Kerning Table
            EditorGUIUtility.labelWidth = labelWidth;
            EditorGUIUtility.fieldWidth = fieldWidth;
            EditorGUI.indentLevel = 0;

            UI_PanelState.kerningInfoPanel = EditorGUILayout.Foldout(UI_PanelState.kerningInfoPanel, new GUIContent("Glyph Adjustment Table"), true, TMP_UIStyleManager.boldFoldout);

            if (UI_PanelState.kerningInfoPanel)
            {
                int arraySize = m_kerningPairs_prop.arraySize;
                int itemsPerPage = 20;

                // Display Kerning Pair Management Tools
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    // Search Bar implementation
                    #region DISPLAY SEARCH BAR
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUIUtility.labelWidth = 150f;
                        EditorGUI.BeginChangeCheck();
                        string searchPattern = EditorGUILayout.TextField("Adjustment Pair Search", m_KerningTableSearchPattern, "SearchTextField");
                        if (EditorGUI.EndChangeCheck() || m_isSearchDirty)
                        {
                            if (string.IsNullOrEmpty(searchPattern) == false)
                            {
                                m_KerningTableSearchPattern = searchPattern;

                                // Search Glyph Table for potential matches
                                SearchKerningTable(m_KerningTableSearchPattern, ref m_KerningTableSearchList);
                            }
                            else
                                m_KerningTableSearchPattern = null;

                            m_isSearchDirty = false;
                        }

                        string styleName = string.IsNullOrEmpty(m_KerningTableSearchPattern) ? "SearchCancelButtonEmpty" : "SearchCancelButton";
                        if (GUILayout.Button(GUIContent.none, styleName))
                        {
                            GUIUtility.keyboardControl = 0;
                            m_KerningTableSearchPattern = string.Empty;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    #endregion

                    // Display Page Navigation
                    if (!string.IsNullOrEmpty(m_KerningTableSearchPattern))
                        arraySize = m_KerningTableSearchList.Count;

                    DisplayPageNavigation(ref m_CurrentKerningPage, arraySize, itemsPerPage);
                }
                EditorGUILayout.EndVertical();


                //Rect pos;
                //pos = EditorGUILayout.GetControlRect(false, 20);

                //pos.x += 5;
                //EditorGUI.LabelField(pos, "First Glyph", TMP_UIStyleManager.TMP_GUISkin.label);
                //pos.x += 100;
                //EditorGUI.LabelField(pos, "Adjustment Values", TMP_UIStyleManager.TMP_GUISkin.label);

                //pos.x = pos.width / 2 + 5;
                //EditorGUI.LabelField(pos, "Second Glyph", TMP_UIStyleManager.TMP_GUISkin.label);
                //pos.x += 100;
                //EditorGUI.LabelField(pos, "Adjustment Values", TMP_UIStyleManager.TMP_GUISkin.label);

                if (arraySize > 0)
                {
                    // Display each GlyphInfo entry using the GlyphInfo property drawer.
                    for (int i = itemsPerPage * m_CurrentKerningPage; i < arraySize && i < itemsPerPage * (m_CurrentKerningPage + 1); i++)
                    {
                        // Define the start of the selection region of the element.
                        Rect elementStartRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));

                        int elementIndex = i;
                        if (!string.IsNullOrEmpty(m_KerningTableSearchPattern))
                            elementIndex = m_KerningTableSearchList[i];

                        SerializedProperty kerningInfo = m_kerningPairs_prop.GetArrayElementAtIndex(elementIndex);
                        
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                        EditorGUI.BeginDisabledGroup(i != m_SelectedAdjustmentRecord);
                        {
                            EditorGUILayout.PropertyField(kerningInfo, new GUIContent("Selectable"));
                        }
                        EditorGUI.EndDisabledGroup();

                        EditorGUILayout.EndVertical();

                        // Define the end of the selection region of the element.
                        Rect elementEndRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));

                        // Check for Item selection
                        Rect selectionArea = new Rect(elementStartRegion.x, elementStartRegion.y, elementEndRegion.width, elementEndRegion.y - elementStartRegion.y);
                        if (DoSelectionCheck(selectionArea))
                        {
                            if (m_SelectedAdjustmentRecord == i)
                            {
                                m_SelectedAdjustmentRecord = -1;
                            }
                            else
                            {
                                m_SelectedAdjustmentRecord = i;
                                GUIUtility.keyboardControl = 0;
                            }
                        }

                        // Draw Selection Highlight and Kerning Pair Options
                        if (m_SelectedAdjustmentRecord == i)
                        {
                            TMP_EditorUtility.DrawBox(selectionArea, 2f, new Color32(40, 192, 255, 255));

                            // Draw Glyph management options
                            Rect controlRect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * 1f);
                            float optionAreaWidth = controlRect.width;
                            float btnWidth = optionAreaWidth / 4;

                            Rect position = new Rect(controlRect.x + controlRect.width - btnWidth, controlRect.y, btnWidth, controlRect.height);

                            // Remove Kerning pair
                            GUI.enabled = true;
                            if (GUI.Button(position, "Remove"))
                            {
                                GUIUtility.keyboardControl = 0;

                                m_kerningTable.RemoveKerningPair(i);
                                m_fontreplacedet.ReadFontDefinition();

                                isreplacedetDirty = true;
                                m_SelectedAdjustmentRecord = -1;
                                m_isSearchDirty = true;
                                break;
                            }
                        }
                    }
                }

                DisplayPageNavigation(ref m_CurrentKerningPage, arraySize, itemsPerPage);

                GUILayout.Space(5);

                // Add new kerning pair
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUILayout.PropertyField(m_kerningPair_prop);
                }
                EditorGUILayout.EndVertical();

                if (GUILayout.Button("Add New Kerning Pair"))
                {
                    int firstGlyph = m_kerningPair_prop.FindPropertyRelative("m_FirstGlyph").intValue;
                    int secondGlyph = m_kerningPair_prop.FindPropertyRelative("m_SecondGlyph").intValue;

                    GlyphValueRecord firstGlyphAdjustments = GetGlyphAdjustments(m_kerningPair_prop.FindPropertyRelative("m_FirstGlyphAdjustments"));
                    GlyphValueRecord secondGlyphAdjustments = GetGlyphAdjustments(m_kerningPair_prop.FindPropertyRelative("m_SecondGlyphAdjustments"));

                    errorCode = m_kerningTable.AddGlyphPairAdjustmentRecord((uint)firstGlyph, firstGlyphAdjustments, (uint)secondGlyph, secondGlyphAdjustments);

                    // Sort Kerning Pairs & Reload Font replacedet if new kerning pair was added.
                    if (errorCode != -1)
                    {
                        m_kerningTable.SortKerningPairs();
                        m_fontreplacedet.ReadFontDefinition();
                        serializedObject.ApplyModifiedProperties();
                        isreplacedetDirty = true;
                        m_isSearchDirty = true;
                    }
                    else
                    {
                        timeStamp = System.DateTime.Now.AddSeconds(5);
                    }

                    // Clear Add Kerning Pair Panel
                    // TODO
                }

                if (errorCode == -1)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label("Kerning Pair already <color=#ffff00>exists!</color>", TMP_UIStyleManager.label);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    if (System.DateTime.Now > timeStamp)
                        errorCode = 0;
                }
            }
            #endregion


            if (serializedObject.ApplyModifiedProperties() || evt_cmd == k_UndoRedo || isreplacedetDirty)
            {
                TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, m_fontreplacedet);

                isreplacedetDirty = false;
                EditorUtility.SetDirty(target);
            }


            // Clear selection if mouse event was not consumed. 
            GUI.enabled = true;
            if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0)
                m_SelectedAdjustmentRecord = -1;

        }

19 View Source File : CheckResources.cs
License : Apache License 2.0
Project Creator : 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 View Source File : UICreateNewUIWizard.cs
License : Apache License 2.0
Project Creator : 365082218

void OnGUI ()
	{
		EditorGUIUtility.LookLikeControls(80f);

		GUILayout.Label("Create a new UI with the following parameters:");
		NGUIEditorTools.DrawSeparator();

		GUILayout.BeginHorizontal();
		NGUISettings.layer = EditorGUILayout.LayerField("Layer", NGUISettings.layer, GUILayout.Width(200f));
		GUILayout.Space(20f);
		GUILayout.Label("This is the layer your UI will reside on");
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		camType = (CameraType)EditorGUILayout.EnumPopup("Camera", camType, GUILayout.Width(200f));
		GUILayout.Space(20f);
		GUILayout.Label("Should this UI have a camera?");
		GUILayout.EndHorizontal();

		NGUIEditorTools.DrawSeparator();
		GUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("When ready,");
		bool create = GUILayout.Button("Create Your UI", GUILayout.Width(120f));
		GUILayout.EndHorizontal();

		if (create) CreateNewUI();
	}

19 View Source File : AnimationTrackInspector.cs
License : MIT License
Project Creator : BattleDawnNZ

public static void MatchTargetsFieldGUI(SerializedProperty property)
        {
            const float ToggleWidth = 20;
            int value = 0;

            MatchTargetFields enumValue = (MatchTargetFields)property.intValue;

            EditorGUI.BeginChangeCheck();
            Rect rect = EditorGUILayout.GetControlRect(false, kLineHeight * 2);
            Rect itemRect = new Rect(rect.x, rect.y, rect.width, kLineHeight);
            EditorGUI.BeginProperty(rect, Styles.MatchTargetFieldsreplacedle, property);
            float minWidth = 0, maxWidth = 0;
            EditorStyles.label.CalcMinMaxWidth(Styles.Xreplacedle, out minWidth, out maxWidth);
            float width = minWidth + ToggleWidth;

            GUILayout.BeginHorizontal();
            Rect r = EditorGUI.PrefixLabel(itemRect, Styles.Positionreplacedle);
            int oldIndent = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;
            r.width = width;
            value |= EditorGUI.ToggleLeft(r, Styles.Xreplacedle, enumValue.HasAny(MatchTargetFields.PositionX)) ? (int)MatchTargetFields.PositionX : 0;
            r.x += width;
            value |= EditorGUI.ToggleLeft(r, Styles.Yreplacedle, enumValue.HasAny(MatchTargetFields.PositionY)) ? (int)MatchTargetFields.PositionY : 0;
            r.x += width;
            value |= EditorGUI.ToggleLeft(r, Styles.Zreplacedle, enumValue.HasAny(MatchTargetFields.PositionZ)) ? (int)MatchTargetFields.PositionZ : 0;
            EditorGUI.indentLevel = oldIndent;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            itemRect.y += kLineHeight;
            r = EditorGUI.PrefixLabel(itemRect, Styles.Rotationreplacedle);
            EditorGUI.indentLevel = 0;
            r.width = width;
            value |= EditorGUI.ToggleLeft(r, Styles.Xreplacedle, enumValue.HasAny(MatchTargetFields.RotationX)) ? (int)MatchTargetFields.RotationX : 0;
            r.x += width;
            value |= EditorGUI.ToggleLeft(r, Styles.Yreplacedle, enumValue.HasAny(MatchTargetFields.RotationY)) ? (int)MatchTargetFields.RotationY : 0;
            r.x += width;
            value |= EditorGUI.ToggleLeft(r, Styles.Zreplacedle, enumValue.HasAny(MatchTargetFields.RotationZ)) ? (int)MatchTargetFields.RotationZ : 0;
            EditorGUI.indentLevel = oldIndent;
            GUILayout.EndHorizontal();

            EditorGUI.EndProperty();
            if (EditorGUI.EndChangeCheck())
            {
                property.intValue = value;
            }
        }

19 View Source File : ComponentSelector.cs
License : Apache License 2.0
Project Creator : 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 View Source File : TimelineWindow_TrackGui.cs
License : MIT License
Project Creator : BattleDawnNZ

void DrawNoSequenceGUI(WindowState windowState)
        {
            bool showCreateButton = false;
            var currentlySelectedGo = UnityEditor.Selection.activeObject != null ? UnityEditor.Selection.activeObject as GameObject : null;
            var textContent = DirectorStyles.noTimelinereplacedetSelected;
            var existingDirector = currentlySelectedGo != null ? currentlySelectedGo.GetComponent<PlayableDirector>() : null;
            var existingreplacedet = existingDirector != null ? existingDirector.playablereplacedet : null;

            if (currentlySelectedGo != null && !TimelineUtility.IsPrefabOrreplacedet(currentlySelectedGo) && existingreplacedet == null)
            {
                showCreateButton = true;
                textContent = new GUIContent(String.Format(DirectorStyles.createTimelineOnSelection.text, currentlySelectedGo.name, "a Director component and a Timeline replacedet"));
            }
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            GUILayout.Label(textContent);

            if (showCreateButton)
            {
                GUILayout.BeginHorizontal();
                var textSize = GUI.skin.label.CalcSize(textContent);
                GUILayout.Space((textSize.x / 2.0f) - (WindowConstants.createButtonWidth / 2.0f));
                if (GUILayout.Button("Create", GUILayout.Width(WindowConstants.createButtonWidth)))
                {
                    var message = DirectorStyles.createNewTimelineText.text + " '" + currentlySelectedGo.name + "'";
                    string newSequencePath = EditorUtility.SaveFilePanelInProject(DirectorStyles.createNewTimelineText.text, currentlySelectedGo.name + "Timeline", "playable", message, ProjectWindowUtil.GetActiveFolderPath());
                    if (!string.IsNullOrEmpty(newSequencePath))
                    {
                        var newreplacedet = CreateInstance<Timelinereplacedet>();
                        replacedetDatabase.Createreplacedet(newreplacedet, newSequencePath);

                        Undo.IncrementCurrentGroup();

                        if (existingDirector == null)
                        {
                            existingDirector = Undo.AddComponent<PlayableDirector>(currentlySelectedGo);
                        }

                        existingDirector.playablereplacedet = newreplacedet;
                        SetCurrentTimeline(existingDirector);
                        var newTrack = TimelineHelpers.CreateTrack<AnimationTrack>();

                        windowState.previewMode = false;
                        TimelineUtility.SetSceneGameObject(windowState.editSequence.director, newTrack, currentlySelectedGo);
                    }

                    // If we reach this point, the state of the pannel has changed; skip the rest of this GUI phase
                    // Fixes: case 955831 - [OSX] NullReferenceException when creating a timeline on a selected object
                    GUIUtility.ExitGUI();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
        }

19 View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 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 View Source File : BlendshapePrinter.cs
License : GNU General Public License v3.0
Project Creator : ARPOISE

void OnGUI()
	{
		if (shapeEnabled) {

			string blendshapes = "";
			string shapeNames = "";
			string valueNames = "";
			foreach(KeyValuePair<string,float> kvp in currentBlendShapes) {
				blendshapes += " [";
				blendshapes += kvp.Key.ToString ();
				blendshapes += ":";
				blendshapes += kvp.Value.ToString ();
				blendshapes += "]\n";
				shapeNames += "\"";
				shapeNames += kvp.Key.ToString ();
				shapeNames += "\",\n";
				valueNames += kvp.Value.ToString ();
				valueNames += "\n";
			}

			GUILayout.BeginHorizontal (GUILayout.ExpandHeight(true));
			GUILayout.Box (blendshapes);
			GUILayout.EndHorizontal ();

			Debug.Log (shapeNames);
			Debug.Log (valueNames);

		}
	}

19 View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 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 View Source File : UIAtlasMaker.cs
License : Apache License 2.0
Project Creator : 365082218

void OnGUI ()
	{
		bool create = false;
		bool update = false;
		bool replace = false;

		string prefabPath = "";
		string matPath = "";

		// If we have an atlas to work with, see if we can figure out the path for it and its material
		if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
		{
			prefabPath = replacedetDatabase.GetreplacedetPath(NGUISettings.atlas.gameObject.GetInstanceID());
			if (NGUISettings.atlas.spriteMaterial != null) matPath = replacedetDatabase.GetreplacedetPath(NGUISettings.atlas.spriteMaterial.GetInstanceID());
		}

		// replacedume default values if needed
		if (string.IsNullOrEmpty(NGUISettings.atlasName)) NGUISettings.atlasName = "New Atlas";
		if (string.IsNullOrEmpty(prefabPath)) prefabPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.atlasName + ".prefab";
		if (string.IsNullOrEmpty(matPath)) matPath = NGUIEditorTools.GetSelectionFolder() + NGUISettings.atlasName + ".mat";

		// Try to load the prefab
		GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
		if (NGUISettings.atlas == null && go != null) NGUISettings.atlas = go.GetComponent<UIAtlas>();

		EditorGUIUtility.LookLikeControls(80f);

		GUILayout.Space(6f);
		GUILayout.BeginHorizontal();

		if (go == null)
		{
			GUI.backgroundColor = Color.green;
			create = GUILayout.Button("Create", GUILayout.Width(76f));
		}
		else
		{
			GUI.backgroundColor = Color.red;
			create = GUILayout.Button("Replace", GUILayout.Width(76f));
		}

		GUI.backgroundColor = Color.white;
		NGUISettings.atlasName = GUILayout.TextField(NGUISettings.atlasName);
		GUILayout.EndHorizontal();

		if (create)
		{
			// If the prefab already exists, confirm that we want to overwrite it
			if (go == null || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to replace the contents of the " +
				NGUISettings.atlasName + " atlas with the textures currently selected in the Project View? All other sprites will be deleted.", "Yes", "No"))
			{
				replace = true;

				// Try to load the material
				Material mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;

				// If the material doesn't exist, create it
				if (mat == null)
				{
					Shader shader = Shader.Find("Unlit/Transparent Colored");
					mat = new Material(shader);

					// Save the material
					replacedetDatabase.Createreplacedet(mat, matPath);
					replacedetDatabase.Refresh();

					// Load the material so it's usable
					mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
				}

				if (NGUISettings.atlas == null || NGUISettings.atlas.name != NGUISettings.atlasName)
				{
					// Create a new prefab for the atlas
#if UNITY_3_4
					Object prefab = (go != null) ? go : EditorUtility.CreateEmptyPrefab(prefabPath); 
#else
					Object prefab = (go != null) ? go : PrefabUtility.CreateEmptyPrefab(prefabPath);
#endif
					// Create a new game object for the atlas
					go = new GameObject(NGUISettings.atlasName);
					go.AddComponent<UIAtlas>().spriteMaterial = mat;

					// Update the prefab
#if UNITY_3_4
					EditorUtility.ReplacePrefab(go, prefab);
#else
					PrefabUtility.ReplacePrefab(go, prefab);
#endif
					DestroyImmediate(go);
					replacedetDatabase.Savereplacedets();
					replacedetDatabase.Refresh();

					// Select the atlas
					go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
					NGUISettings.atlas = go.GetComponent<UIAtlas>();
				}
			}
		}

		ComponentSelector.Draw<UIAtlas>("Select", NGUISettings.atlas, OnSelectAtlas);

		List<Texture> textures = GetSelectedTextures();

		if (NGUISettings.atlas != null && NGUISettings.atlas.name == NGUISettings.atlasName)
		{
			Material mat = NGUISettings.atlas.spriteMaterial;
			Texture tex = NGUISettings.atlas.texture;

			// Material information
			GUILayout.BeginHorizontal();
			{
				if (mat != null)
				{
					if (GUILayout.Button("Material", GUILayout.Width(76f))) Selection.activeObject = mat;
					GUILayout.Label(" " + mat.name);
				}
				else
				{
					GUI.color = Color.grey;
					GUILayout.Button("Material", GUILayout.Width(76f));
					GUI.color = Color.white;
					GUILayout.Label(" N/A");
				}
			}
			GUILayout.EndHorizontal();

			// Texture atlas information
			GUILayout.BeginHorizontal();
			{
				if (tex != null)
				{
					if (GUILayout.Button("Texture", GUILayout.Width(76f))) Selection.activeObject = tex;
					GUILayout.Label(" " + tex.width + "x" + tex.height);
				}
				else
				{
					GUI.color = Color.grey;
					GUILayout.Button("Texture", GUILayout.Width(76f));
					GUI.color = Color.white;
					GUILayout.Label(" N/A");
				}
			}
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			NGUISettings.atlasPadding = Mathf.Clamp(EditorGUILayout.IntField("Padding", NGUISettings.atlasPadding, GUILayout.Width(100f)), 0, 8);
			GUILayout.Label((NGUISettings.atlasPadding == 1 ? "pixel" : "pixels") + " in-between of sprites");
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			NGUISettings.atlasTrimming = EditorGUILayout.Toggle("Trim Alpha", NGUISettings.atlasTrimming, GUILayout.Width(100f));
			GUILayout.Label("Remove empty space");
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			NGUISettings.unityPacking = EditorGUILayout.Toggle("Unity Packer", NGUISettings.unityPacking, GUILayout.Width(100f));
			GUILayout.Label("if off, use a custom packer");
			GUILayout.EndHorizontal();

			if (!NGUISettings.unityPacking)
			{
				GUILayout.BeginHorizontal();
				NGUISettings.forceSquareAtlas = EditorGUILayout.Toggle("Force Square", NGUISettings.forceSquareAtlas, GUILayout.Width(100f));
				GUILayout.Label("if on, forces a square atlas texture");
				GUILayout.EndHorizontal();
			}

#if UNITY_IPHONE || UNITY_ANDROID
			GUILayout.BeginHorizontal();
			NGUISettings.allow4096 = EditorGUILayout.Toggle("4096x4096", NGUISettings.allow4096, GUILayout.Width(100f));
			GUILayout.Label("if off, limit atlases to 2048x2048");
			GUILayout.EndHorizontal();
#endif
			if (textures.Count > 0)
			{
				GUI.backgroundColor = Color.green;
				update = GUILayout.Button("Add/Update All");
				GUI.backgroundColor = Color.white;
			}
			else
			{
				NGUIEditorTools.DrawSeparator();
				GUILayout.Label("You can reveal more options by selecting\none or more textures in the Project View\nwindow.");
			}
		}
		else
		{
			NGUIEditorTools.DrawSeparator();
			GUILayout.Label("You can create a new atlas by selecting\none or more textures in the Project View\nwindow, then clicking \"Create\".");
		}

		Dictionary<string, int> spriteList = GetSpriteList(textures);

		if (spriteList.Count > 0)
		{
			NGUIEditorTools.DrawHeader("Sprites");
			GUILayout.Space(-7f);

			mScroll = GUILayout.BeginScrollView(mScroll);

			bool delete = false;
			int index = 0;
			foreach (KeyValuePair<string, int> iter in spriteList)
			{
				++index;
				NGUIEditorTools.HighlightLine(new Color(0.6f, 0.6f, 0.6f));
				GUILayout.BeginHorizontal();
				GUILayout.Label(index.ToString(), GUILayout.Width(24f));
				GUILayout.Label(iter.Key);

				if (iter.Value == 2)
				{
					GUI.color = Color.green;
					GUILayout.Label("Add", GUILayout.Width(27f));
					GUI.color = Color.white;
				}
				else if (iter.Value == 1)
				{
					GUI.color = Color.cyan;
					GUILayout.Label("Update", GUILayout.Width(45f));
					GUI.color = Color.white;
				}
				else
				{
					if (mDelNames.Contains(iter.Key))
					{
						GUI.backgroundColor = Color.red;

						if (GUILayout.Button("Delete", GUILayout.Width(60f)))
						{
							delete = true;
						}
						GUI.backgroundColor = Color.green;
						if (GUILayout.Button("X", GUILayout.Width(22f)))
						{
							mDelNames.Remove(iter.Key);
							delete = false;
						}
						GUI.backgroundColor = Color.white;
					}
					else
					{
						// If we have not yet selected a sprite for deletion, show a small "X" button
						if (GUILayout.Button("X", GUILayout.Width(22f))) mDelNames.Add(iter.Key);
					}
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();

			// If this sprite was marked for deletion, remove it from the atlas
			if (delete)
			{
				List<SpriteEntry> sprites = new List<SpriteEntry>();
				ExtractSprites(NGUISettings.atlas, sprites);

				for (int i = sprites.Count; i > 0; )
				{
					SpriteEntry ent = sprites[--i];

					if (mDelNames.Contains(ent.tex.name))
					{
						sprites.RemoveAt(i);
					}
				}
				UpdateAtlas(NGUISettings.atlas, sprites);
				mDelNames.Clear();
			}
			else if (update) UpdateAtlas(textures, true);
			else if (replace) UpdateAtlas(textures, false);
			return;
		}
	}

private void OnGUI()
        {
            //m_BluePrintList = Q_InventoryMainEditorWindow.inventoryItemList.bluePrints;
            GUILayout.Label("Currency Editor", labelStyle);
            GUILayout.Space(10);

            //if (inventoryItemList.currencies == null)
            //{
            //    Debug.Log("change");
            //    inventoryItemList.currencies = new List<Currency>();
            //    window.Repaint();
            //}
            using (var h = new EditorGUILayout.HorizontalScope())
            {
                using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos))
                {
                    scrollPos = scrollView.scrollPosition;
                    if (GUILayout.Button("Create New Currency"))
                    {
                        CreateNewCurrency();
                    }

                    GUILayout.Space(10);

                    if (inventoryItemList.currencies.Count > 0)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false)))
                        {
                            if (viewIndex > 1)
                                viewIndex--;
                            else if (viewIndex == 1)
                                viewIndex = inventoryItemList.currencies.Count;
                        }

                        GUILayout.Space(5);

                        if (GUILayout.Button("Next", GUILayout.ExpandWidth(false)))
                        {
                            if (viewIndex < inventoryItemList.currencies.Count)
                            {
                                viewIndex++;
                            }

                            else if (viewIndex == inventoryItemList.currencies.Count)
                            {
                                viewIndex = 1;
                            }
                        }


                        GUILayout.Space(180);

                        if (GUILayout.Button("Delete Currency", GUILayout.ExpandWidth(false)))
                        {
                            DeleteCurrency(viewIndex - 1);
                        }

                        GUILayout.EndHorizontal();

                        if (inventoryItemList.currencies.Count > 0)
                        {
                            GUILayout.BeginHorizontal();

                            viewIndex = Mathf.Clamp(EditorGUILayout.IntField("Current Currency", viewIndex, GUILayout.ExpandWidth(false)), 1, inventoryItemList.currencies.Count);
                            EditorGUILayout.LabelField("of   " + inventoryItemList.currencies.Count.ToString() + "  Currency", "", GUILayout.ExpandWidth(false));

                            GUILayout.EndHorizontal();

                            GUILayout.Space(10);
                            //数据显示
                            //name
                            EditorGUI.BeginChangeCheck();
                            inventoryItemList.currencies[viewIndex - 1].currencyName = EditorGUILayout.DelayedTextField("Currency Name", inventoryItemList.currencies[viewIndex - 1].currencyName as string);
                            if (EditorGUI.EndChangeCheck())
                            {
                                replacedetDatabase.Renamereplacedet(EditorPrefs.GetString("DatabasePath") + "/Currencies/" + inventoryItemList.currencies[viewIndex - 1].name + ".replacedet", inventoryItemList.currencies[viewIndex - 1].currencyName);
                                replacedetDatabase.Savereplacedets();
                            }
                            GUILayout.Space(5);
                            //icon
                            inventoryItemList.currencies[viewIndex - 1].icon = EditorGUILayout.ObjectField("Currency Icon", inventoryItemList.currencies[viewIndex - 1].icon, typeof(Sprite), false) as Sprite;
                            GUILayout.Space(5);

                            //exchangerate
                            inventoryItemList.currencies[viewIndex - 1].exchangeRate = Mathf.Clamp(EditorGUILayout.FloatField("Exchange Rate", inventoryItemList.currencies[viewIndex - 1].exchangeRate), 0.000001f, 9999999);
                            GUILayout.Space(5);
                            GUILayout.Space(20);
                        }

                    }

                    else
                    {
                        GUILayout.Space(50);
                        GUILayout.Label("Don't Have A Currency", normalCenterStyle);
                    }
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(inventoryItemList);
                if (viewIndex > 0)
                    EditorUtility.SetDirty(inventoryItemList.currencies[viewIndex - 1]);
            }
        }

19 View Source File : ComponentSelector.cs
License : Apache License 2.0
Project Creator : 365082218

static public void Draw<T> (string buttonName, T obj, OnSelectionCallback cb, params GUILayoutOption[] options) where T : MonoBehaviour
	{
		GUILayout.BeginHorizontal();
		bool show = GUILayout.Button(buttonName, "DropDownButton", GUILayout.Width(76f));
#if !UNITY_3_4
		GUILayout.BeginVertical();
		GUILayout.Space(5f);
#endif
		T o = EditorGUILayout.ObjectField(obj, typeof(T), false, options) as T;
#if !UNITY_3_4
		GUILayout.EndVertical();
#endif
		if (o != null && Selection.activeObject != o.gameObject && GUILayout.Button("Edit", GUILayout.Width(40f)))
		{
			Selection.activeObject = o.gameObject;
		}
		GUILayout.EndHorizontal();
		if (show) Show<T>(cb);
		else if (o != obj) cb(o);
	}

19 View Source File : TMP_BaseShaderGUI.cs
License : MIT License
Project Creator : BattleDawnNZ

protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true)
        {
            if (readState)
            {
                feature.ReadState(m_Material);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.BeginHorizontal();

            Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 20, GUILayout.Width(20f)));
            bool active = EditorGUI.Toggle(r, feature.Active);

            if (EditorGUI.EndChangeCheck())
            {
                m_Editor.RegisterPropertyChangeUndo(feature.undoLabel);
                feature.SetActive(active, m_Material);
            }

            r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
            r.width += 6;

            bool enabled = GUI.enabled;
            GUI.enabled = true;
            expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelreplacedle);
            r.width -= 10;
            EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
            GUI.enabled = enabled;

            GUILayout.EndHorizontal();

            EditorGUI.indentLevel += 1;
            EditorGUI.BeginDisabledGroup(!active);

            return expanded;
        }

19 View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 365082218

void OnGUI ()
	{
		// Load the saved preferences
		if (!mLoaded) { mLoaded = true; Load(); }

		EditorGUIUtility.LookLikeControls(80f);
		GameObject go = NGUIEditorTools.SelectedRoot();

		if (go == null)
		{
			GUILayout.Label("You must create a UI first.");
			
			if (GUILayout.Button("Open the New UI Wizard"))
			{
				EditorWindow.GetWindow<UICreateNewUIWizard>(false, "New UI", true);
			}
		}
		else
		{
			GUILayout.Space(4f);

			GUILayout.BeginHorizontal();
			ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas, GUILayout.Width(140f));
			GUILayout.Label("Texture atlas used by widgets", GUILayout.MinWidth(10000f));
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			ComponentSelector.Draw<UIFont>(NGUISettings.font, OnSelectFont, GUILayout.Width(140f));
			GUILayout.Label("Font used by labels", GUILayout.MinWidth(10000f));
			GUILayout.EndHorizontal();

			GUILayout.Space(-2f);
			NGUIEditorTools.DrawSeparator();

			GUILayout.BeginHorizontal();
			WidgetType wt = (WidgetType)EditorGUILayout.EnumPopup("Template", mType, GUILayout.Width(200f));
			GUILayout.Space(20f);
			GUILayout.Label("Select a widget template to use");
			GUILayout.EndHorizontal();

			if (mType != wt) { mType = wt; Save(); }

			switch (mType)
			{
				case WidgetType.Label:			CreateLabel(go); break;
				case WidgetType.Sprite:			CreateSprite(go, mSprite); break;
				case WidgetType.Texture:		CreateSimpleTexture(go); break;
				case WidgetType.Button:			CreateButton(go); break;
				case WidgetType.ImageButton:	CreateImageButton(go); break;
				case WidgetType.Checkbox:		CreateCheckbox(go); break;
				case WidgetType.ProgressBar:	CreateSlider(go, false); break;
				case WidgetType.Slider:			CreateSlider(go, true); break;
				case WidgetType.Input:			CreateInput(go); break;
				case WidgetType.PopupList:		CreatePopup(go, true); break;
				case WidgetType.PopupMenu:		CreatePopup(go, false); break;
				case WidgetType.ScrollBar:		CreateScrollBar(go); break;
			}
		}
	}

19 View Source File : BreadcrumbDrawer.cs
License : MIT License
Project Creator : BattleDawnNZ

public static void Draw(float breadcrumbAreaWidth, List<BreadCrumbreplacedle> labels, Action<int> navigateToBreadcrumbIndex)
        {
            GUILayout.BeginHorizontal(GUILayout.Width(breadcrumbAreaWidth));
            {
                var labelWidth = (int)(breadcrumbAreaWidth / labels.Count);

                for (var i = 0; i < labels.Count; i++)
                {
                    var label = labels[i];

                    var style = i == 0 ? k_BreadCrumbLeft : k_BreadCrumbMid;
                    var backgroundStyle = i == 0 ? k_BreadCrumbLeftBg : k_BreadCrumbMidBg;

                    if (i == labels.Count - 1)
                    {
                        if (i > 0)
                        {
                            // Only tint last breadcrumb if we are dug-in
                            DrawBreadcrumbreplacedelectedSubSequence(labelWidth, label, k_BreadCrumbMidSelected, k_BreadCrumbMidBgSelected);
                        }
                        else
                        {
                            DrawActiveBreadcrumb(labelWidth, label, style, backgroundStyle);
                        }
                    }
                    else
                    {
                        var previousContentColor = GUI.contentColor;

                        GUI.contentColor = new Color(previousContentColor.r,
                            previousContentColor.g,
                            previousContentColor.b,
                            previousContentColor.a * 0.6f);
                        var content = GetTextContent(labelWidth, label, style);
                        var rect = GetBreadcrumbLayoutRect(content, style);

                        if (Event.current.type == EventType.Repaint)
                        {
                            backgroundStyle.Draw(rect, GUIContent.none, 0);
                        }

                        if (GUI.Button(rect, content, style))
                        {
                            navigateToBreadcrumbIndex.Invoke(i);
                        }
                        GUI.contentColor = previousContentColor;
                    }
                }
            }
            GUILayout.EndHorizontal();
        }

19 View Source File : TransformInspector.cs
License : Apache License 2.0
Project Creator : 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 View Source File : TimelineWindow_TrackGui.cs
License : MIT License
Project Creator : BattleDawnNZ

void TracksGUI(Rect clientRect, WindowState state, TimelineModeGUIState trackState)
        {
            if (Event.current.type == EventType.Repaint && treeView != null)
            {
                state.spaceParreplacedioner.Clear();
            }

            if (state.IsEditingASubTimeline() && !state.IsEditingAnEmptyTimeline())
            {
                var headerRect = clientRect;
                headerRect.width = state.sequencerHeaderWidth;
                Graphics.DrawBackgroundRect(state, headerRect);

                var clipRect = clientRect;
                clipRect.xMin = headerRect.xMax;
                Graphics.DrawBackgroundRect(state, clipRect, subSequenceMode: true);
            }
            else
            {
                Graphics.DrawBackgroundRect(state, clientRect);
            }

            if (!state.IsEditingAnEmptyTimeline())
                m_TimeArea.DrawMajorTicks(sequenceContentRect, state.referenceSequence.frameRate);

            GUILayout.BeginVertical();
            {
                GUILayout.Space(5.0f);
                GUILayout.BeginHorizontal();

                if (this.state.editSequence.replacedet == null)
                    DrawNoSequenceGUI(state);
                else
                    DrawTracksGUI(clientRect, trackState);

                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            Graphics.DrawShadow(clientRect);
        }

19 View Source File : UIPopupListInspector.cs
License : Apache License 2.0
Project Creator : 365082218

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

		ComponentSelector.Draw<UIAtlas>(mList.atlas, OnSelectAtlas);
		ComponentSelector.Draw<UIFont>(mList.font, OnSelectFont);

		GUILayout.BeginHorizontal();
		UILabel lbl = EditorGUILayout.ObjectField("Text Label", mList.textLabel, typeof(UILabel), true) as UILabel;

		if (mList.textLabel != lbl)
		{
			RegisterUndo();
			mList.textLabel = lbl;
			if (lbl != null) lbl.text = mList.selection;
		}
		GUILayout.Space(44f);
		GUILayout.EndHorizontal();

		if (mList.atlas != null)
		{
			NGUIEditorTools.SpriteField("Background", mList.atlas, mList.backgroundSprite, OnBackground);
			NGUIEditorTools.SpriteField("Highlight", mList.atlas, mList.highlightSprite, OnHighlight);

			GUILayout.BeginHorizontal();
			GUILayout.Space(6f);
			GUILayout.Label("Options");
			GUILayout.EndHorizontal();

			string text = "";
			foreach (string s in mList.items) text += s + "\n";

			GUILayout.Space(-14f);
			GUILayout.BeginHorizontal();
			GUILayout.Space(84f);
			string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f));
			GUILayout.EndHorizontal();

			if (modified != text)
			{
				RegisterUndo();
				string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
				mList.items.Clear();
				foreach (string s in split) mList.items.Add(s);

				if (string.IsNullOrEmpty(mList.selection) || !mList.items.Contains(mList.selection))
				{
					mList.selection = mList.items.Count > 0 ? mList.items[0] : "";
				}
			}

			string sel = NGUIEditorTools.DrawList("Selection", mList.items.ToArray(), mList.selection);

			if (mList.selection != sel)
			{
				RegisterUndo();
				mList.selection = sel;
			}

			UIPopupList.Position pos = (UIPopupList.Position)EditorGUILayout.EnumPopup("Position", mList.position);

			if (mList.position != pos)
			{
				RegisterUndo();
				mList.position = pos;
			}

			float ts = EditorGUILayout.FloatField("Text Scale", mList.textScale);
			Color tc = EditorGUILayout.ColorField("Text Color", mList.textColor);
			Color bc = EditorGUILayout.ColorField("Background", mList.backgroundColor);
			Color hc = EditorGUILayout.ColorField("Highlight", mList.highlightColor);

			GUILayout.BeginHorizontal();
			bool isLocalized = EditorGUILayout.Toggle("Localized", mList.isLocalized, GUILayout.Width(100f));
			bool isAnimated = EditorGUILayout.Toggle("Animated", mList.isAnimated);
			GUILayout.EndHorizontal();

			if (mList.textScale != ts ||
				mList.textColor != tc ||
				mList.highlightColor != hc ||
				mList.backgroundColor != bc ||
				mList.isLocalized != isLocalized ||
				mList.isAnimated != isAnimated)
			{
				RegisterUndo();
				mList.textScale = ts;
				mList.textColor = tc;
				mList.backgroundColor = bc;
				mList.highlightColor = hc;
				mList.isLocalized = isLocalized;
				mList.isAnimated = isAnimated;
			}

			NGUIEditorTools.DrawSeparator();

			GUILayout.BeginHorizontal();
			GUILayout.Space(6f);
			GUILayout.Label("Padding", GUILayout.Width(76f));
			GUILayout.BeginVertical();
			GUILayout.Space(-12f);
			Vector2 padding = EditorGUILayout.Vector2Field("", mList.padding);
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
			
			if (mList.padding != padding)
			{
				RegisterUndo();
				mList.padding = padding;
			}

			EditorGUIUtility.LookLikeControls(100f);

			GameObject go = EditorGUILayout.ObjectField("Event Receiver", mList.eventReceiver,
				typeof(GameObject), true) as GameObject;

			string fn = EditorGUILayout.TextField("Function Name", mList.functionName);

			if (mList.eventReceiver != go || mList.functionName != fn)
			{
				RegisterUndo();
				mList.eventReceiver = go;
				mList.functionName = fn;
			}
		}
	}

19 View Source File : UISliderInspector.cs
License : Apache License 2.0
Project Creator : 365082218

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

		NGUIEditorTools.DrawSeparator();

		float sliderValue = EditorGUILayout.Slider("Value", slider.sliderValue, 0f, 1f);

		if (slider.sliderValue != sliderValue)
		{
			NGUIEditorTools.RegisterUndo("Slider Change", slider);
			slider.sliderValue = sliderValue;
			UnityEditor.EditorUtility.SetDirty(slider);
		}

		int steps = EditorGUILayout.IntSlider("Steps", slider.numberOfSteps, 0, 11);

		if (slider.numberOfSteps != steps)
		{
			NGUIEditorTools.RegisterUndo("Slider Change", slider);
			slider.numberOfSteps = steps;
			slider.ForceUpdate();
			UnityEditor.EditorUtility.SetDirty(slider);
		}

		NGUIEditorTools.DrawSeparator();

		Transform fg = EditorGUILayout.ObjectField("Foreground", slider.foreground, typeof(Transform), true) as Transform;
		Transform tb = EditorGUILayout.ObjectField("Thumb", slider.thumb, typeof(Transform), true) as Transform;
		UISlider.Direction dir = (UISlider.Direction)EditorGUILayout.EnumPopup("Direction", slider.direction);

		// If we're using a sprite for the foreground, ensure it's using a proper pivot.
		ValidatePivot(fg, "Foreground sprite", dir);

		NGUIEditorTools.DrawSeparator();

		GameObject er = EditorGUILayout.ObjectField("Event Recv.", slider.eventReceiver, typeof(GameObject), true) as GameObject;

		GUILayout.BeginHorizontal();
		string fn = EditorGUILayout.TextField("Function", slider.functionName);
		GUILayout.Space(18f);
		GUILayout.EndHorizontal();

		if (slider.foreground != fg ||
			slider.thumb != tb ||
			slider.direction != dir ||
			slider.eventReceiver != er ||
			slider.functionName != fn)
		{
			NGUIEditorTools.RegisterUndo("Slider Change", slider);
			slider.foreground = fg;
			slider.thumb = tb;
			slider.direction = dir;
			slider.eventReceiver = er;
			slider.functionName = fn;

			if (slider.thumb != null)
			{
				slider.thumb.localPosition = Vector3.zero;
				slider.sliderValue = -1f;
				slider.sliderValue = sliderValue;
			}
			else slider.ForceUpdate();

			UnityEditor.EditorUtility.SetDirty(slider);
		}
	}

19 View Source File : CheckResources.cs
License : Apache License 2.0
Project Creator : 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 View Source File : LuaConsole.cs
License : Apache License 2.0
Project Creator : 365082218

void OnGUI()
        {
            if (!initedStyle)
            {
                GUIStyle entryInfoTyle = "CN EntryInfo";
                textAreaStyle.richText = true;
                textAreaStyle.normal.textColor = entryInfoTyle.normal.textColor;
                initedStyle = true;
            }


            string[] statehints = new string[LuaState.statemap.Count];
            LuaState[] states = new LuaState[LuaState.statemap.Count];
            int n = 0;
            foreach(var k in LuaState.statemap.Values) {
                states[n] = k;
                statehints[n++] = k.Name;
            }

            stateIndex = EditorGUILayout.Popup(stateIndex,statehints);

            LuaState l = null;
            if (stateIndex >= 0 && stateIndex <states.Length)
				l = states[stateIndex];

            if (current != null && current != l)
            {
                current.logDelegate -= AddLog;
                current.errorDelegate -= AddError;
            }

            if(current!=l && l!=null) {
				l.logDelegate += AddLog;
				l.errorDelegate += AddError;
				current = l;
            }




            //Output Text Area
			scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.ExpandHeight(true));
			EditorGUILayout.TextArea(outputText, textAreaStyle, GUILayout.ExpandHeight(true));
            GUILayout.EndScrollView();

            //Filter Option Toggles
            GUILayout.BeginHorizontal();
            bool oldToggleLog = toggleLog;
            bool oldToggleErr = toggleErr;
            toggleLog = GUILayout.Toggle(oldToggleLog, "log", GUILayout.ExpandWidth(false));
            toggleErr = GUILayout.Toggle(oldToggleErr, "error", GUILayout.ExpandWidth(false));

            //Filter Input Field
            GUILayout.Space(10f);
            GUILayout.Label("filter:", GUILayout.ExpandWidth(false));
            string oldFilterPattern = filterText;
            filterText = GUILayout.TextField(oldFilterPattern, GUILayout.Width(200f));

            //Menu Buttons
            if (GUILayout.Button("clear", GUILayout.ExpandWidth(false)))
            {
                recordList.Clear();
                ConsoleFlush();
            }
            GUILayout.EndHorizontal();

            if (toggleLog != oldToggleLog || toggleErr != oldToggleErr || filterText != oldFilterPattern)
            {
                ConsoleFlush();
            }

            if (Event.current.type == EventType.Repaint)
            {
                inputAreaPosY = GUILayoutUtility.GetLastRect().yMax;
            }

            //Drag Spliter
            ResizeScrollView();

            //Input Area
            GUI.SetNextControlName("Input");
            inputText = EditorGUILayout.TextField(inputText, GUILayout.Height(inputAreaHeight));

            if (Event.current.isKey && Event.current.type == EventType.KeyUp)
            {
                bool refresh = false;
                if (Event.current.keyCode == KeyCode.Return)
                {
                    if (inputText != "")
                    {
                        if (history.Count == 0 || history[history.Count - 1] != inputText)
                        {
                            history.Add(inputText);
                        }
                        AddLog(inputText);
                        DoCommand(inputText);
                        inputText = "";
                        refresh = true;
                        historyIndex = history.Count;
                    }
                }
                else if (Event.current.keyCode == KeyCode.UpArrow)
                {
                    if (history.Count > 0)
                    {
                        historyIndex = historyIndex - 1;
                        if (historyIndex < 0)
                        {
                            historyIndex = 0;
                        }
                        else
                        {
                            inputText = history[historyIndex];
                            refresh = true;
                        }
                    }
                }
                else if (Event.current.keyCode == KeyCode.DownArrow)
                {
                    if (history.Count > 0)
                    {
                        historyIndex = historyIndex + 1;
                        if (historyIndex > history.Count - 1)
                        {
                            historyIndex = history.Count - 1;
                        }
                        else
                        {
                            inputText = history[historyIndex];
                            refresh = true;
                        }
                    }
                }

                if (refresh)
                {
                    Repaint();
                    EditorGUIUtility.editingTextField = false;
                    GUI.FocusControl("Input");
                }
            }
        }

19 View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218

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

		if (atlas.GetSprite(spriteName) == null)
			spriteName = "";

		if (GUILayout.Button(spriteName, "MiniPullDown", GUILayout.Width(120f)))
		{
			SpriteSelector.Show(atlas, spriteName, callback);
		}
		
		if (!string.IsNullOrEmpty(caption))
		{
			GUILayout.Space(20f);
			GUILayout.Label(caption);
		}
		GUILayout.EndHorizontal();
	}

19 View Source File : UIPanelTool.cs
License : Apache License 2.0
Project Creator : 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 View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 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 View Source File : SpriteSelector.cs
License : Apache License 2.0
Project Creator : 365082218

void OnGUI ()
	{
		EditorGUIUtility.LookLikeControls(80f);

		if (mAtlas == null)
		{
			GUILayout.Label("No Atlas selected.", "LODLevelNotifyText");
		}
		else
		{
			bool close = false;
			GUILayout.Label(mAtlas.name + " Sprites", "LODLevelNotifyText");
			NGUIEditorTools.DrawSeparator();

			GUILayout.BeginHorizontal();
			GUILayout.Space(84f);

			string before = NGUISettings.partialSprite;
			string after = EditorGUILayout.TextField("", before, "SearchTextField");
			NGUISettings.partialSprite = after;

			if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f)))
			{
				NGUISettings.partialSprite = "";
				GUIUtility.keyboardControl = 0;
			}
			GUILayout.Space(84f);
			GUILayout.EndHorizontal();

			Texture2D tex = mAtlas.texture as Texture2D;

			if (tex == null)
			{
				GUILayout.Label("The atlas doesn't have a texture to work with");
				return;
			}

			BetterList<string> sprites = mAtlas.GetListOfSprites(NGUISettings.partialSprite);
			
			float size = 80f;
			float padded = size + 10f;
			int columns = Mathf.FloorToInt(Screen.width / padded);
			if (columns < 1) columns = 1;

			int offset = 0;
			Rect rect = new Rect(10f, 0, size, size);

			GUILayout.Space(10f);
			mPos = GUILayout.BeginScrollView(mPos);

			while (offset < sprites.size)
			{
				GUILayout.BeginHorizontal();
				{
					int col = 0;
					rect.x = 10f;

					for (; offset < sprites.size; ++offset)
					{
						UIAtlas.Sprite sprite = mAtlas.GetSprite(sprites[offset]);
						if (sprite == null) continue;

						// Button comes first
						if (GUI.Button(rect, ""))
						{
							float delta = Time.realtimeSinceStartup - mClickTime;
							mClickTime = Time.realtimeSinceStartup;

							if (spriteName != sprite.name)
							{
								if (mSprite != null)
								{
									NGUIEditorTools.RegisterUndo("Atlas Selection", mSprite);
									mSprite.spriteName = sprite.name;
									mSprite.MakePixelPerfect();
									EditorUtility.SetDirty(mSprite.gameObject);
								}
								else if (mCallback != null)
								{
									mName = sprite.name;
									mCallback(sprite.name);
								}
							}
							else if (delta < 0.5f) close = true;
						}
						
						if (Event.current.type == EventType.Repaint)
						{
							// On top of the button we have a checkboard grid
							NGUIEditorTools.DrawTiledTexture(rect, NGUIEditorTools.backdropTexture);
	
							Rect uv = sprite.outer;
							if (mAtlas.coordinates == UIAtlas.Coordinates.Pixels)
								uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height);
	
							// Calculate the texture's scale that's needed to display the sprite in the clipped area
							float scaleX = rect.width / uv.width;
							float scaleY = rect.height / uv.height;
	
							// Stretch the sprite so that it will appear proper
							float aspect = (scaleY / scaleX) / ((float)tex.height / tex.width);
							Rect clipRect = rect;
	
							if (aspect != 1f)
							{
								if (aspect < 1f)
								{
									// The sprite is taller than it is wider
									float padding = size * (1f - aspect) * 0.5f;
									clipRect.xMin += padding;
									clipRect.xMax -= padding;
								}
								else
								{
									// The sprite is wider than it is taller
									float padding = size * (1f - 1f / aspect) * 0.5f;
									clipRect.yMin += padding;
									clipRect.yMax -= padding;
								}
							}
	
							GUI.DrawTextureWithTexCoords(clipRect, tex, uv);
	
							// Draw the selection
							if (spriteName == sprite.name)
							{
								NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f));
							}
						}

						if (++col >= columns)
						{
							++offset;
							break;
						}
						rect.x += padded;
					}
				}
				GUILayout.EndHorizontal();
				GUILayout.Space(padded);
				rect.y += padded;
			}
			GUILayout.EndScrollView();
			if (close) Close();
		}
	}

19 View Source File : TMP_BaseShaderGUI.cs
License : MIT License
Project Creator : ashishgopalhattimare

protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true)
        {
            if (readState)
            {
                feature.ReadState(m_Material);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.BeginHorizontal();

            Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 20, GUILayout.Width(20f)));
            bool active = EditorGUI.Toggle(r, feature.Active);

            if (EditorGUI.EndChangeCheck())
            {
                m_Editor.RegisterPropertyChangeUndo(feature.undoLabel);
                feature.SetActive(active, m_Material);
            }

            r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
            r.width += 6;

            bool enabled = GUI.enabled;
            GUI.enabled = true;
            expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelreplacedle);
            GUI.enabled = enabled;

            GUILayout.EndHorizontal();

            EditorGUI.indentLevel += 1;
            EditorGUI.BeginDisabledGroup(!active);

            return expanded;
        }

19 View Source File : UIAtlasInspector.cs
License : Apache License 2.0
Project Creator : 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;
					}
				}
			}
		}
	}

private void OnGUI()
        {
            //m_ItemAttributeList = Q_InventoryMainEditorWindow.inventoryItemList.attributes;
            GUILayout.Label("Attribute Editor", labelStyle);
            GUILayout.Space(10);

            //if(inventoryItemList.attributes == null)
            //{
            //    inventoryItemList.attributes = new List<ItemAttribute>();
            //    window.Repaint();
            //}
            if (GUILayout.Button("Create New Attribute"))
            {
                CreateNewAttribute();
            }

            GUILayout.Space(10);

            if (inventoryItemList.attributes.Count > 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false)))
                {
                    if (viewIndex > 1)
                        viewIndex--;
                    else if (viewIndex == 1)
                        viewIndex = inventoryItemList.attributes.Count;
                }

                GUILayout.Space(5);

                if (GUILayout.Button("Next", GUILayout.ExpandWidth(false)))
                {
                    if (viewIndex < inventoryItemList.attributes.Count)
                    {
                        viewIndex++;
                    }

                    else if (viewIndex == inventoryItemList.attributes.Count)
                    {
                        viewIndex = 1;
                    }
                }


                GUILayout.Space(180);

                if (GUILayout.Button("Delete Attribute", GUILayout.ExpandWidth(false)))
                {
                    DeleteAttribute(viewIndex - 1);
                }
                GUILayout.EndHorizontal();

                if (inventoryItemList.attributes.Count > 0)
                {

                    GUILayout.BeginHorizontal();

                    viewIndex = Mathf.Clamp(EditorGUILayout.IntField("Current Attribute", viewIndex, GUILayout.ExpandWidth(false)), 1, inventoryItemList.attributes.Count);
                    EditorGUILayout.LabelField("of   " + inventoryItemList.attributes.Count.ToString() + "  Attributes", "", GUILayout.ExpandWidth(false));

                    GUILayout.EndHorizontal();

                    GUILayout.Space(10);
                    //下面是各种物品数据的显示
                    //name
                    EditorGUI.BeginChangeCheck();
                    inventoryItemList.attributes[viewIndex - 1].attributeName = EditorGUILayout.DelayedTextField("Attribute Name", inventoryItemList.attributes[viewIndex - 1].attributeName as string);
                    if (EditorGUI.EndChangeCheck())
                    {
                        replacedetDatabase.Renamereplacedet(EditorPrefs.GetString("DatabasePath") + "/ItemAttributes/" + inventoryItemList.attributes[viewIndex - 1].name + ".replacedet", inventoryItemList.attributes[viewIndex - 1].attributeName);
                        replacedetDatabase.Savereplacedets();
                    }
                    GUILayout.Space(5);
                    //icon
                    inventoryItemList.attributes[viewIndex - 1].icon = EditorGUILayout.ObjectField("Attribute Icon", inventoryItemList.attributes[viewIndex - 1].icon, typeof(Sprite), false) as Sprite;

                }
            }

            else
            {
                GUILayout.Space(50);
                GUILayout.Label("Don't Have An Attribute", normalCenterStyle);
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(inventoryItemList);
                if (viewIndex > 0)
                    EditorUtility.SetDirty(inventoryItemList.attributes[viewIndex - 1]);
            }
        }

19 View Source File : UICameraTool.cs
License : Apache License 2.0
Project Creator : 365082218

void DrawRow (Camera cam)
	{
		if (cam != null) NGUIEditorTools.HighlightLine(new Color(0.6f, 0.6f, 0.6f));

		GUILayout.BeginHorizontal();
		{
			bool enabled = (cam == null || (NGUITools.GetActive(cam.gameObject) && cam.enabled));

			GUI.color = Color.white;

			if (cam != null)
			{
				if (enabled != EditorGUILayout.Toggle(enabled, GUILayout.Width(20f)))
				{
					cam.enabled = !enabled;
					EditorUtility.SetDirty(cam.gameObject);
				}
			}
			else
			{
				GUILayout.Space(30f);
			}

			bool highlight = (cam == null || Selection.activeGameObject == null) ? false :
				(0 != (cam.cullingMask & (1 << Selection.activeGameObject.layer)));

			if (enabled)
			{
				GUI.color = highlight ? new Color(0f, 0.8f, 1f) : Color.white;
			}
			else
			{
				GUI.color = highlight ? new Color(0f, 0.5f, 0.8f) : Color.grey;
			}

			string camName, camLayer;

			if (cam == null)
			{
				camName = "Camera's Name";
				camLayer = "Layer";
			}
			else
			{
				camName = cam.name + (cam.orthographic ? " (2D)" : " (3D)");
				camLayer = LayerMask.LayerToName(cam.gameObject.layer);
			}

#if UNITY_3_4
			if (GUILayout.Button(camName, EditorStyles.structHeadingLabel, GUILayout.MinWidth(100f)) && cam != null)
#else
			if (GUILayout.Button(camName, EditorStyles.label, GUILayout.MinWidth(100f)) && cam != null)
#endif
			{
				Selection.activeGameObject = cam.gameObject;
				EditorUtility.SetDirty(cam.gameObject);
			}
			GUILayout.Label(camLayer, GUILayout.Width(70f));

			GUI.color = enabled ? Color.white : new Color(0.7f, 0.7f, 0.7f);

			if (cam == null)
			{
				GUILayout.Label("EV", GUILayout.Width(26f));
			}
			else
			{
				UICamera uic = cam.GetComponent<UICamera>();
				bool ev = (uic != null && uic.enabled);

				if (ev != EditorGUILayout.Toggle(ev, GUILayout.Width(20f)))
				{
					if (uic == null) uic = cam.gameObject.AddComponent<UICamera>();
					uic.enabled = !ev;
				}
			}

			if (cam == null)
			{
				GUILayout.Label("Mask", GUILayout.Width(100f));
			}
			else
			{
				int mask = LayerMaskField(cam.cullingMask, GUILayout.Width(105f));

				if (cam.cullingMask != mask)
				{
					NGUIEditorTools.RegisterUndo("Camera Mask Change", cam);
					cam.cullingMask = mask;
				}
			}
		}
		GUILayout.EndHorizontal();
	}

19 View Source File : Q_InventoryItemEditorWindow.cs
License : GNU Affero General Public License v3.0
Project Creator : AugustToko

private void OnGUI()
        {
            using (var h = new EditorGUILayout.HorizontalScope())
            {
                using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos))
                {
                    scrollPos = scrollView.scrollPosition;
                    GUILayout.Label("Item Editor", labelStyle);

                    GUILayout.Space(20);
                    m_ObjectType = (ObjectType) EditorGUILayout.EnumPopup("Object Creating Type", m_ObjectType);
                    GUILayout.Space(10);

                    if (inventoryItemList != null)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false)))
                        {
                            ClearReorderableList();
                            if (viewIndex > 1)
                                viewIndex--;
                            else if (viewIndex == 1)
                                viewIndex = inventoryItemList.itemList.Count;
                            InitializeReorderableList();
                        }

                        GUILayout.Space(5);

                        if (GUILayout.Button("Next", GUILayout.ExpandWidth(false)))
                        {
                            ClearReorderableList();
                            if (viewIndex < inventoryItemList.itemList.Count)
                            {
                                viewIndex++;
                            }

                            else if (viewIndex == inventoryItemList.itemList.Count)
                            {
                                viewIndex = 1;
                            }

                            InitializeReorderableList();
                        }

                        GUILayout.Space(180);

                        if (GUILayout.Button("Add Item", GUILayout.ExpandWidth(false)))
                        {
                            AddItem();
                        }

                        if (inventoryItemList.itemList.Count > 0)
                        {
                            if (GUILayout.Button("Delete Item", GUILayout.ExpandWidth(false)))
                            {
                                DeleteItem(viewIndex - 1);
                            }
                        }

                        GUILayout.EndHorizontal();

                        //...........
                        if (inventoryItemList.itemList == null)
                            Debug.Log("Dont have item");

                        if (inventoryItemList.itemList.Count > 0)
                        {
                            GUILayout.Label("Normal Settings", tipLabelStyle);

                            GUILayout.BeginHorizontal();

                            viewIndex = Mathf.Clamp(
                                EditorGUILayout.IntField("Current Item", viewIndex, GUILayout.ExpandWidth(false)), 1,
                                inventoryItemList.itemList.Count);
                            EditorGUILayout.LabelField(
                                "of   " + inventoryItemList.itemList.Count.ToString() + "  items", "",
                                GUILayout.ExpandWidth(false));
                            GUILayout.EndHorizontal();
                            GUILayout.Space(10);
                            //下面是各种物品数据的显示
                            //ID
                            GUILayout.Label("Item ID:                         " +
                                            inventoryItemList.itemList[viewIndex - 1].ID.ToString());

                            //Name
                            EditorGUI.BeginChangeCheck();
                            inventoryItemList.itemList[viewIndex - 1].itemName =
                                EditorGUILayout.DelayedTextField("Item Name",
                                    inventoryItemList.itemList[viewIndex - 1].itemName as string);
                            if (EditorGUI.EndChangeCheck())
                            {
                                replacedetDatabase.Renamereplacedet(
                                    EditorPrefs.GetString("DatabasePath") + "/Items/" +
                                    inventoryItemList.itemList[viewIndex - 1].m_object.name + ".prefab",
                                    inventoryItemList.itemList[viewIndex - 1].itemName);
                                replacedetDatabase.Renamereplacedet(
                                    EditorPrefs.GetString("DatabasePath") + "/Items/ItemScriptObjects/" +
                                    inventoryItemList.itemList[viewIndex - 1].name + ".replacedet",
                                    inventoryItemList.itemList[viewIndex - 1].itemName);
                                replacedetDatabase.Savereplacedets();
                            }

                            GUILayout.Space(5);

                            //Description
                            GUILayout.Label("Item Description");
                            GUILayout.Space(5);
                            scrollPos2 = EditorGUILayout.BeginScrollView(scrollPos2, GUILayout.Height(100));
                            inventoryItemList.itemList[viewIndex - 1].description = EditorGUILayout.TextArea(
                                inventoryItemList.itemList[viewIndex - 1].description, GUILayout.ExpandHeight(true));
                            EditorGUILayout.EndScrollView();
                            GUILayout.Space(5);

                            //icon
                            EditorGUI.BeginChangeCheck();
                            inventoryItemList.itemList[viewIndex - 1].icon = EditorGUILayout.ObjectField("Item Icon",
                                inventoryItemList.itemList[viewIndex - 1].icon, typeof(Sprite), false) as Sprite;
                            if (EditorGUI.EndChangeCheck())
                            {
                                if (inventoryItemList.itemList[viewIndex - 1].m_object && inventoryItemList
                                        .itemList[viewIndex - 1].m_object.GetComponent<SpriteRenderer>())
                                {
                                    inventoryItemList.itemList[viewIndex - 1].m_object.GetComponent<SpriteRenderer>()
                                        .sprite = inventoryItemList.itemList[viewIndex - 1].icon;
                                    RefreshEditorProjectWindow();
                                }
                            }

                            //gameobject
                            inventoryItemList.itemList[viewIndex - 1].m_object =
                                EditorGUILayout.ObjectField("Item Object",
                                    inventoryItemList.itemList[viewIndex - 1].m_object, typeof(GameObject),
                                    false) as GameObject;

                            GUILayout.Space(10);

                            GUILayout.BeginHorizontal();
                            inventoryItemList.itemList[viewIndex - 1].isStackable = EditorGUILayout.Toggle(
                                "Is Stackable", inventoryItemList.itemList[viewIndex - 1].isStackable,
                                GUILayout.ExpandWidth(false));
                            GUILayout.EndHorizontal();
                            GUILayout.Space(5);
                            if (inventoryItemList.itemList[viewIndex - 1].isStackable)
                            {
                                inventoryItemList.itemList[viewIndex - 1].maxStackNumber = Mathf.Clamp(
                                    (int) EditorGUILayout.IntField("maxStackNumber",
                                        inventoryItemList.itemList[viewIndex - 1].maxStackNumber), 1, 999);
                                GUILayout.Space(10);
                            }

                            inventoryItemList.itemList[viewIndex - 1].rarity =
                                (Rarity) EditorGUILayout.EnumPopup("Item Rarity",
                                    inventoryItemList.itemList[viewIndex - 1].rarity);

                            GUILayout.Space(10);

                            inventoryItemList.itemList[viewIndex - 1].variety =
                                (Variety) EditorGUILayout.EnumPopup("Item Variety",
                                    inventoryItemList.itemList[viewIndex - 1].variety);

                            if (inventoryItemList.itemList[viewIndex - 1].variety == Variety.Consumable)
                            {
                                GUILayout.Space(10);
                                GUILayout.Label("Consumable Settings", tipLabelStyle);
                                inventoryItemList.itemList[viewIndex - 1].coolDown = Mathf.Clamp(
                                    (float) EditorGUILayout.FloatField("Cool Down",
                                        inventoryItemList.itemList[viewIndex - 1].coolDown), 0, 99999999);
                                //

                                if (m_ConsumbleList != null && m_ConsumbleSerializedObject != null)
                                {
                                    m_ConsumbleSerializedObject.ApplyModifiedProperties();
                                    m_ConsumbleSerializedObject.Update();
                                    m_ConsumbleList.DoLayoutList();
                                    m_ConsumbleSerializedObject.ApplyModifiedProperties();
                                }
                            }
                            else if (inventoryItemList.itemList[viewIndex - 1].variety == Variety.Equipment)
                            {
                                GUILayout.Space(10);
                                GUILayout.Label("Equipment Settings", tipLabelStyle);
                                inventoryItemList.itemList[viewIndex - 1].equipmentPart =
                                    (EquipmentPart) EditorGUILayout.EnumPopup("Equipment Part",
                                        inventoryItemList.itemList[viewIndex - 1].equipmentPart);

                                //
                                if (m_EquipmentList != null && m_EquipmentSerializedObject != null)
                                {
                                    m_EquipmentSerializedObject.ApplyModifiedProperties();
                                    m_EquipmentSerializedObject.Update();
                                    m_EquipmentList.DoLayoutList();
                                    m_EquipmentSerializedObject.ApplyModifiedProperties();
                                }
                            }

                            GUILayout.Space(10);
                            if (inventoryItemList.itemList[viewIndex - 1].variety == Variety.Equipment ||
                                inventoryItemList.itemList[viewIndex - 1].variety == Variety.Consumable)
                            {
                                inventoryItemList.itemList[viewIndex - 1].clipOnUse =
                                    EditorGUILayout.ObjectField("Clip",
                                        inventoryItemList.itemList[viewIndex - 1].clipOnUse, typeof(AudioClip),
                                        false) as AudioClip;
                                if (inventoryItemList.itemList[viewIndex - 1].clipOnUse)
                                {
                                    inventoryItemList.itemList[viewIndex - 1].playClipTimes =
                                        Mathf.Clamp(
                                            (int) EditorGUILayout.IntField("Clip Play Times",
                                                inventoryItemList.itemList[viewIndex - 1].playClipTimes), 1, 99);
                                }
                            }

                            GUILayout.Space(20);

                            GUILayout.Label("Price Settings", tipLabelStyle);
                            GUILayout.Space(10);

                            GUILayout.Label("Buy Price");
                            GUILayout.Space(5);

                            if (m_BuyPriceList != null && m_BuySerializedObject != null)
                            {
                                m_BuySerializedObject.ApplyModifiedProperties();
                                m_BuySerializedObject.Update();
                                m_BuyPriceList.DoLayoutList();
                                m_BuySerializedObject.ApplyModifiedProperties();
                            }

                            GUILayout.Label("Sell Price");
                            GUILayout.Space(5);

                            if (m_SellPriceList != null && m_SellSerializedObject != null)
                            {
                                m_SellSerializedObject.ApplyModifiedProperties();
                                m_SellSerializedObject.Update();
                                m_SellPriceList.DoLayoutList();
                                m_SellSerializedObject.ApplyModifiedProperties();
                            }


                            GUILayout.Space(10);
                            GUILayout.Space(20);
                        }
                        else
                        {
                            GUILayout.Space(50);
                            GUILayout.Label("This Inventory List is Empty.", normalCenterStyle);
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(inventoryItemList);
                if (viewIndex > 0)
                    EditorUtility.SetDirty(inventoryItemList.itemList[viewIndex - 1]);
            }

            //window.Repaint();
        }

19 View Source File : TransformInspector.cs
License : Apache License 2.0
Project Creator : 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 View Source File : PluginSettings.cs
License : MIT License
Project Creator : BattleDawnNZ

[SettingsProvider]
    private static SettingsProvider RiderPreferencesItem()
    {
      if (!RiderScriptEditor.IsRiderInstallation(RiderScriptEditor.CurrentEditor))
        return null;
      if (!RiderScriptEditorData.instance.shouldLoadEditorPlugin)
        return null;
      var provider = new SettingsProvider("Preferences/Rider", SettingsScope.User)
      {
        label = "Rider",
        keywords = new[] { "Rider" },
        guiHandler = (searchContext) =>
        {
          EditorGUIUtility.labelWidth = 200f;
          EditorGUILayout.BeginVertical();

          GUILayout.BeginVertical();
          LogEventsCollectorEnabled =
            EditorGUILayout.Toggle(new GUIContent("Preplaced Console to Rider:"), LogEventsCollectorEnabled);

          GUILayout.EndVertical();
          GUILayout.Label("");

          if (!string.IsNullOrEmpty(EditorPluginInterop.LogPath))
          {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Log file:");
            var previous = GUI.enabled;
            GUI.enabled = previous && SelectedLoggingLevel != LoggingLevel.OFF;
            var button = GUILayout.Button(new GUIContent("Open log"));
            if (button)
            {
              //UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(PluginEntryPoint.LogPath, 0);
              // works much faster than the commented code, when Rider is already started
              CodeEditor.CurrentEditor.OpenProject(EditorPluginInterop.LogPath, 0, 0);
            }

            GUI.enabled = previous;
            GUILayout.EndHorizontal();
          }

          var loggingMsg =
            @"Sets the amount of Rider Debug output. If you are about to report an issue, please select Verbose logging level and attach Unity console output to the issue.";
          SelectedLoggingLevel =
            (LoggingLevel) EditorGUILayout.EnumPopup(new GUIContent("Logging Level:", loggingMsg),
              SelectedLoggingLevel);


          EditorGUILayout.HelpBox(loggingMsg, MessageType.None);

          var githubRepo = "https://github.com/JetBrains/resharper-unity";
          var caption = $"<color=#0000FF>{githubRepo}</color>";
          LinkButton(caption: caption, url: githubRepo);

          GUILayout.FlexibleSpace();
          GUILayout.BeginHorizontal();

          GUILayout.FlexibleSpace();
          var replacedembly = EditorPluginInterop.EditorPluginreplacedembly;
          if (replacedembly != null)
          {
            var version = replacedembly.GetName().Version;
            GUILayout.Label("Plugin version: " + version, ourVersionInfoStyle);
          }
          
          GUILayout.EndHorizontal();

          EditorGUILayout.EndVertical();
        }
      };
      return provider;
    }

19 View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 365082218

void CreateScrollBar (GameObject go)
	{
		if (NGUISettings.atlas != null)
		{
			NGUIEditorTools.SpriteField("Background", "Sprite used for the background", NGUISettings.atlas, mScrollBG, OnScrollBG);
			NGUIEditorTools.SpriteField("Foreground", "Sprite used for the foreground (thumb)", NGUISettings.atlas, mScrollFG, OnScrollFG);

			GUILayout.BeginHorizontal();
			UIScrollBar.Direction dir = (UIScrollBar.Direction)EditorGUILayout.EnumPopup("Direction", mScrollDir, GUILayout.Width(200f));
			GUILayout.Space(20f);
			GUILayout.Label("Add colliders?", GUILayout.Width(90f));
			bool draggable = EditorGUILayout.Toggle(mScrollCL);
			GUILayout.EndHorizontal();

			if (mScrollCL != draggable || mScrollDir != dir)
			{
				mScrollCL = draggable;
				mScrollDir = dir;
				Save();
			}
		}

		if (ShouldCreate(go, NGUISettings.atlas != null))
		{
			int depth = NGUITools.CalculateNextDepth(go);
			go = NGUITools.AddChild(go);
			go.name = "Scroll Bar";

			UISprite bg = NGUITools.AddWidget<UISprite>(go);
			bg.type = UISprite.Type.Sliced;
			bg.name = "Background";
			bg.depth = depth;
			bg.atlas = NGUISettings.atlas;
			bg.spriteName = mScrollBG;
			bg.transform.localScale = new Vector3(400f + bg.border.x + bg.border.z, 14f + bg.border.y + bg.border.w, 1f);
			bg.MakePixelPerfect();

			UISprite fg = NGUITools.AddWidget<UISprite>(go);
			fg.type = UISprite.Type.Sliced;
			fg.name = "Foreground";
			fg.atlas = NGUISettings.atlas;
			fg.spriteName = mScrollFG;

			UIScrollBar sb = go.AddComponent<UIScrollBar>();
			sb.background = bg;
			sb.foreground = fg;
			sb.direction = mScrollDir;
			sb.barSize = 0.3f;
			sb.scrollValue = 0.3f;
			sb.ForceUpdate();

			if (mScrollCL)
			{
				NGUITools.AddWidgetCollider(bg.gameObject);
				NGUITools.AddWidgetCollider(fg.gameObject);
			}
			Selection.activeGameObject = go;
		}
	}

19 View Source File : AnimationTrackInspector.cs
License : MIT License
Project Creator : BattleDawnNZ

public static void ShowMotionOffsetEditModeToolbar(ref TimelineAnimationUtilities.OffsetEditMode motionOffset)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.FlexibleSpace();

            int newMotionOffsetMode = GUILayout.Toolbar((int)motionOffset, new[] { Styles.PositionIcon, Styles.RotationIcon });

            if (GUI.changed)
            {
                if ((int)motionOffset == newMotionOffsetMode) //untoggle the button
                    motionOffset = TimelineAnimationUtilities.OffsetEditMode.None;
                else
                    motionOffset = (TimelineAnimationUtilities.OffsetEditMode)newMotionOffsetMode;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(3);
        }

19 View Source File : ComponentSelector.cs
License : Apache License 2.0
Project Creator : 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 View Source File : TimelineWindow_Gui.cs
License : MIT License
Project Creator : BattleDawnNZ

void TimelineSectionGUI()
        {
            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Width(position.width - state.sequencerHeaderWidth));
                {
                    DoSequenceSelectorGUI();
                    DoBreadcrumbGUI();
                    OptionsGUI();
                }
                GUILayout.EndHorizontal();

                TimelineGUI();
            }
            GUILayout.EndVertical();
        }

19 View Source File : UIFontInspector.cs
License : Apache License 2.0
Project Creator : 365082218

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

		NGUIEditorTools.DrawSeparator();

        //Lindean
        if (mFont.dynamicFont != null)
        {
            mType = FontType.Dynamic;
        }

		if (mFont.replacement != null)
		{
			mType = FontType.Reference;
			mReplacement = mFont.replacement;
		}
		else if (mFont.dynamicFont_1 != null)
		{
			mType = FontType.Dynamic;
		}

		GUILayout.BeginHorizontal();
		FontType fontType = (FontType)EditorGUILayout.EnumPopup("Font Type", mType);
		GUILayout.Space(18f);
		GUILayout.EndHorizontal();

		if (mType != fontType)
		{
			if (fontType == FontType.Normal)
			{
				OnSelectFont(null);
			}
			else
			{
				mType = fontType;
			}

            //Lindean
			if (mType != FontType.Dynamic && mFont.dynamicFont_1 != null)
				mFont.dynamicFont_1 = null;
		}

        //Lindean
        if (mType == FontType.Dynamic)
        {
            //Lindean - Draw settings for dynamic font
            bool changed = false;
            Font f = EditorGUILayout.ObjectField("Font", mFont.dynamicFont, typeof(Font), false) as Font;
            if (f != mFont.dynamicFont)
            {
                mFont.dynamicFont = f;
                changed = true;
            }

            Material mat = EditorGUILayout.ObjectField("Material", mFont.dynamicFontMaterial_1, typeof(Material), false) as Material;
            if (mat != mFont.dynamicFontMaterial_1)
            {
                mFont.dynamicFontMaterial_1 = mat;
                changed = true;
            }
            if (mFont.dynamicFontMaterial_1 == null)
                GUILayout.Label("Warning: no coloring or clipping when using default font material");

            int i = EditorGUILayout.IntField("Size", mFont.dynamicFontSize);
            if (i != mFont.dynamicFontSize)
            {
                mFont.dynamicFontSize = i;
                changed = true;
            }

            FontStyle style = (FontStyle)EditorGUILayout.EnumPopup("Style", mFont.dynamicFontStyle);
            if (style != mFont.dynamicFontStyle)
            {
                mFont.dynamicFontStyle = style;
                changed = true;
            }

            if (changed)
            {
                //force access to material property as it refreshes the texture replacedignment
                Debug.Log("font changed...");
                Material fontMat = mFont.material;
                if (fontMat.mainTexture == null)
                    Debug.Log("font material texture issue...");
                UIFont.OnFontRebuilt(mFont);
            }

            NGUIEditorTools.DrawSeparator();

            // Font spacing
            GUILayout.BeginHorizontal();
            {
                EditorGUIUtility.LookLikeControls(0f);
                GUILayout.Label("Spacing", GUILayout.Width(60f));
                GUILayout.Label("X", GUILayout.Width(12f));
                int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
                GUILayout.Label("Y", GUILayout.Width(12f));
                int y = EditorGUILayout.IntField(mFont.verticalSpacing);
                EditorGUIUtility.LookLikeControls(80f);

                if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
                {
                    NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
                    mFont.horizontalSpacing = x;
                    mFont.verticalSpacing = y;
                }
            }
            GUILayout.EndHorizontal();
        }
        //Lindean

		if (mType == FontType.Reference)
		{
			ComponentSelector.Draw<UIFont>(mFont.replacement, OnSelectFont);

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

			if (mReplacement != mFont && mFont.replacement != mReplacement)
			{
				NGUIEditorTools.RegisterUndo("Font Change", mFont);
				mFont.replacement = mReplacement;
				UnityEditor.EditorUtility.SetDirty(mFont);
			}
			return;
		}
		else if (mType == FontType.Dynamic)
		{
#if UNITY_3_5
			EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
			NGUIEditorTools.DrawSeparator();
			Font fnt = EditorGUILayout.ObjectField("TTF Font", mFont.dynamicFont_1, typeof(Font), false) as Font;
			
			if (fnt != mFont.dynamicFont_1)
			{
				NGUIEditorTools.RegisterUndo("Font change", mFont);
				mFont.dynamicFont_1 = fnt;
			}

			GUILayout.BeginHorizontal();
			int size = EditorGUILayout.IntField("Size", mFont.dynamicFontSize_1, GUILayout.Width(120f));
			FontStyle style = (FontStyle)EditorGUILayout.EnumPopup(mFont.dynamicFontStyle_1);
			GUILayout.Space(18f);
			GUILayout.EndHorizontal();

			if (size != mFont.dynamicFontSize_1)
			{
				NGUIEditorTools.RegisterUndo("Font change", mFont);
				mFont.dynamicFontSize_1 = size;
			}

			if (style != mFont.dynamicFontStyle_1)
			{
				NGUIEditorTools.RegisterUndo("Font change", mFont);
				mFont.dynamicFontStyle_1 = style;
			}

			Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;

			if (mFont.material != mat)
			{
				NGUIEditorTools.RegisterUndo("Font Material", mFont);
				mFont.material = mat;
			}
#endif
		}
		else
		{
			NGUIEditorTools.DrawSeparator();

			ComponentSelector.Draw<UIAtlas>(mFont.atlas, OnSelectAtlas);

			if (mFont.atlas != null)
			{
				if (mFont.bmFont.isValid)
				{
					NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
				}
				EditorGUILayout.Space();
			}
			else
			{
				// No atlas specified -- set the material and texture rectangle directly
				Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;

				if (mFont.material != mat)
				{
					NGUIEditorTools.RegisterUndo("Font Material", mFont);
					mFont.material = mat;
				}
			}

			// For updating the font's data when importing from an external source, such as the texture packer
			bool resetWidthHeight = false;

			if (mFont.atlas != null || mFont.material != null)
			{
				Textreplacedet data = EditorGUILayout.ObjectField("Import Data", null, typeof(Textreplacedet), false) as Textreplacedet;

				if (data != null)
				{
					NGUIEditorTools.RegisterUndo("Import Font Data", mFont);
					BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes);
					mFont.MarkAsDirty();
					resetWidthHeight = true;
					Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters");
				}
			}

			if (mFont.bmFont.isValid)
			{
				Color green = new Color(0.4f, 1f, 0f, 1f);
				Texture2D tex = mFont.texture;

				if (tex != null)
				{
					if (mFont.atlas == null)
					{
						// Pixels are easier to work with than UVs
						Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false);

						// Automatically set the width and height of the rectangle to be the original font texture's dimensions
						if (resetWidthHeight)
						{
							pixels.width = mFont.texWidth;
							pixels.height = mFont.texHeight;
						}

						// Font sprite rectangle
						GUI.backgroundColor = green;
						pixels = EditorGUILayout.RectField("Pixel Rect", pixels);
						GUI.backgroundColor = Color.white;

						// Create a button that can make the coordinates pixel-perfect on click
						GUILayout.BeginHorizontal();
						{
							Rect corrected = NGUIMath.MakePixelPerfect(pixels);

							if (corrected == pixels)
							{
								GUI.color = Color.grey;
								GUILayout.Button("Make Pixel-Perfect");
								GUI.color = Color.white;
							}
							else if (GUILayout.Button("Make Pixel-Perfect"))
							{
								pixels = corrected;
								GUI.changed = true;
							}
						}
						GUILayout.EndHorizontal();

						// Convert the pixel coordinates back to UV coordinates
						Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height);

						if (mFont.uvRect != uvRect)
						{
							NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont);
							mFont.uvRect = uvRect;
						}
						//NGUIEditorTools.DrawSeparator();
						EditorGUILayout.Space();
					}
				}
			}
		}

		// The font must be valid at this point for the rest of the options to show up
		if (mFont.isDynamic || mFont.bmFont.isValid)
		{
			// Font spacing
			GUILayout.BeginHorizontal();
			{
				EditorGUIUtility.LookLikeControls(0f);
				GUILayout.Label("Spacing", GUILayout.Width(60f));
				GUILayout.Label("X", GUILayout.Width(12f));
				int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
				GUILayout.Label("Y", GUILayout.Width(12f));
				int y = EditorGUILayout.IntField(mFont.verticalSpacing);
				GUILayout.Space(18f);
				EditorGUIUtility.LookLikeControls(80f);

				if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
				{
					NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
					mFont.horizontalSpacing = x;
					mFont.verticalSpacing = y;
				}
			}
			GUILayout.EndHorizontal();

			if (mFont.atlas == null)
			{
				mView = View.Font;
				mUseShader = false;

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

				if (pixelSize != mFont.pixelSize)
				{
					NGUIEditorTools.RegisterUndo("Font Change", mFont);
					mFont.pixelSize = pixelSize;
				}
			}
			EditorGUILayout.Space();
		}

		// Preview option
		if (!mFont.isDynamic && mFont.atlas != null)
		{
			GUILayout.BeginHorizontal();
			{
				mView = (View)EditorGUILayout.EnumPopup("Preview", mView);
				GUILayout.Label("Shader", GUILayout.Width(45f));
				mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f));
			}
			GUILayout.EndHorizontal();
		}

		// Dynamic fonts don't support emoticons
		if (!mFont.isDynamic && mFont.bmFont.isValid)
		{
			if (mFont.atlas != null)
			{
				NGUIEditorTools.DrawHeader("Symbols and Emoticons");

				List<BMSymbol> symbols = mFont.symbols;

				for (int i = 0; i < symbols.Count; )
				{
					BMSymbol sym = symbols[i];

					GUILayout.BeginHorizontal();
					GUILayout.Label(sym.sequence, GUILayout.Width(40f));
					if (NGUIEditorTools.SimpleSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite))
						mSelectedSymbol = sym;

					if (GUILayout.Button("Edit", GUILayout.Width(40f)))
					{
						if (mFont.atlas != null)
						{
							EditorPrefs.SetString("NGUI Selected Sprite", sym.spriteName);
							NGUIEditorTools.Select(mFont.atlas.gameObject);
						}
					}

					GUI.backgroundColor = Color.red;

					if (GUILayout.Button("X", GUILayout.Width(22f)))
					{
						NGUIEditorTools.RegisterUndo("Remove symbol", mFont);
						mSymbolSequence = sym.sequence;
						mSymbolSprite = sym.spriteName;
						symbols.Remove(sym);
						mFont.MarkAsDirty();
					}
					GUI.backgroundColor = Color.white;
					GUILayout.EndHorizontal();
					GUILayout.Space(4f);
					++i;
				}

				if (symbols.Count > 0)
				{
					NGUIEditorTools.DrawSeparator();
				}

				GUILayout.BeginHorizontal();
				mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f));
				NGUIEditorTools.SimpleSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite);

				bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite);
				GUI.backgroundColor = isValid ? Color.green : Color.grey;

				if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid)
				{
					NGUIEditorTools.RegisterUndo("Add symbol", mFont);
					mFont.AddSymbol(mSymbolSequence, mSymbolSprite);
					mFont.MarkAsDirty();
					mSymbolSequence = "";
					mSymbolSprite = "";
				}
				GUI.backgroundColor = Color.white;
				GUILayout.EndHorizontal();

				if (symbols.Count == 0)
				{
					EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info);
				}
				else GUILayout.Space(4f);
			}
		}
	}

19 View Source File : TimelineWindow_Gui.cs
License : MIT License
Project Creator : BattleDawnNZ

void SequencerGUI()
        {
            var duration = state.editSequence.duration;

            DrawHeaderBackground();
            DurationGUI(TimelineItemArea.Header, duration);

            GUILayout.BeginHorizontal();
            {
                SequencerHeaderGUI();
                TimelineSectionGUI();
            }
            GUILayout.EndHorizontal();

            TrackViewsGUI();
            MarkerHeaderGUI();
            UserOverlaysGUI();

            DurationGUI(TimelineItemArea.Lines, duration);
            PlayRangeGUI(TimelineItemArea.Lines);
            TimeCursorGUI(TimelineItemArea.Lines);
            DrawHeaderBackgroundBottomFiller();

            SubTimelineRangeGUI();

            PlayRangeGUI(TimelineItemArea.Header);
            TimeCursorGUI(TimelineItemArea.Header);

            SplitterGUI();
        }

19 View Source File : TransformInspector.cs
License : Apache License 2.0
Project Creator : 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 View Source File : TimelineWindow_HeaderGui.cs
License : MIT License
Project Creator : BattleDawnNZ

void TransportToolbarGUI()
        {
            GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Width(sequenceHeaderRect.width));
            {
                using (new EditorGUI.DisabledScope(currentMode.PreviewState(state) == TimelineModeGUIState.Disabled))
                {
                    PreviewModeButtonGUI();
                }

                using (new EditorGUI.DisabledScope(currentMode.ToolbarState(state) == TimelineModeGUIState.Disabled))
                {
                    GotoBeginingSequenceGUI();
                    PreviousEventButtonGUI();
                    PlayButtonGUI();
                    NextEventButtonGUI();
                    GotoEndSequenceGUI();
                    GUILayout.Space(10.0f);
                    PlayRangeButtonGUI();
                    GUILayout.FlexibleSpace();
                    TimeCodeGUI();
                    ReferenceTimeGUI();
                }
            }
            GUILayout.EndHorizontal();
        }

19 View Source File : UIPanelInspector.cs
License : Apache License 2.0
Project Creator : 365082218

public override void OnInspectorGUI ()
	{
		UIPanel panel = target as UIPanel;
		BetterList<UIDrawCall> drawcalls = panel.drawCalls;
		EditorGUIUtility.LookLikeControls(80f);

		//NGUIEditorTools.DrawSeparator();
		EditorGUILayout.Space();

		float alpha = EditorGUILayout.Slider("Alpha", panel.alpha, 0f, 1f);

		if (alpha != panel.alpha)
		{
			NGUIEditorTools.RegisterUndo("Panel Alpha", panel);
			panel.alpha = alpha;
		}

		if (panel.showInPanelTool != EditorGUILayout.Toggle("Panel Tool", panel.showInPanelTool))
		{
			panel.showInPanelTool = !panel.showInPanelTool;
			EditorUtility.SetDirty(panel);
			EditorWindow.FocusWindowIfItsOpen<UIPanelTool>();
		}

		panel.isTop = EditorGUILayout.Toggle("IsTop",panel.isTop);
		panel.isLeft = EditorGUILayout.Toggle("IsLeft",panel.isLeft);
		GUILayout.BeginHorizontal();
		bool norms = EditorGUILayout.Toggle("Normals", panel.generateNormals, GUILayout.Width(100f));
		GUILayout.Label("Needed for lit shaders");
		GUILayout.EndHorizontal();

		if (panel.generateNormals != norms)
		{
			panel.generateNormals = norms;
			panel.UpdateDrawcalls();
			EditorUtility.SetDirty(panel);
		}

		GUILayout.BeginHorizontal();
		bool depth = EditorGUILayout.Toggle("Depth Preplaced", panel.depthPreplaced, GUILayout.Width(100f));
		GUILayout.Label("Doubles draw calls, saves fillrate");
		GUILayout.EndHorizontal();

		if (panel.depthPreplaced != depth)
		{
			panel.depthPreplaced = depth;
			panel.UpdateDrawcalls();
			EditorUtility.SetDirty(panel);
		}

		if (depth)
		{
			UICamera cam = UICamera.FindCameraForLayer(panel.gameObject.layer);

			if (cam == null || cam.GetComponent<Camera>().orthographic)
			{
				EditorGUILayout.HelpBox("Please note that depth preplaced will only save fillrate when used with 3D UIs, and only UIs drawn by the game camera. If you are using a separate camera for the UI, you will not see any benefit!", MessageType.Warning);
			}
		}

		GUILayout.BeginHorizontal();
		bool stat = EditorGUILayout.Toggle("Static", panel.widgetsAreStatic, GUILayout.Width(100f));
		GUILayout.Label("Check if widgets won't move");
		GUILayout.EndHorizontal();

		if (panel.widgetsAreStatic != stat)
		{
			panel.widgetsAreStatic = stat;
			panel.UpdateDrawcalls();
			EditorUtility.SetDirty(panel);
		}

		EditorGUILayout.LabelField("Widgets", panel.widgets.size.ToString());
		EditorGUILayout.LabelField("Draw Calls", drawcalls.size.ToString());

		UIPanel.DebugInfo di = (UIPanel.DebugInfo)EditorGUILayout.EnumPopup("Debug Info", panel.debugInfo);

		if (panel.debugInfo != di)
		{
			panel.debugInfo = di;
			EditorUtility.SetDirty(panel);
		}

		UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", panel.clipping);

		if (panel.clipping != clipping)
		{
			panel.clipping = clipping;
			EditorUtility.SetDirty(panel);
		}

		if (panel.clipping != UIDrawCall.Clipping.None)
		{
			Vector4 range = panel.clipRange;

			GUILayout.BeginHorizontal();
			GUILayout.Space(80f);
			Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y));
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			GUILayout.Space(80f);
			Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w));
			GUILayout.EndHorizontal();

			if (size.x < 0f) size.x = 0f;
			if (size.y < 0f) size.y = 0f;

			range.x = pos.x;
			range.y = pos.y;
			range.z = size.x;
			range.w = size.y;

			if (panel.clipRange != range)
			{
				NGUIEditorTools.RegisterUndo("Clipping Change", panel);
				panel.clipRange = range;
				EditorUtility.SetDirty(panel);
			}

			if (panel.clipping == UIDrawCall.Clipping.SoftClip)
			{
				GUILayout.BeginHorizontal();
				GUILayout.Space(80f);
				Vector2 soft = EditorGUILayout.Vector2Field("Softness", panel.clipSoftness);
				GUILayout.EndHorizontal();

				if (soft.x < 1f) soft.x = 1f;
				if (soft.y < 1f) soft.y = 1f;

				if (panel.clipSoftness != soft)
				{
					NGUIEditorTools.RegisterUndo("Clipping Change", panel);
					panel.clipSoftness = soft;
					EditorUtility.SetDirty(panel);
				}
			}

#if UNITY_ANDROID || UNITY_IPHONE
			if (PlayerSettings.targetGlesGraphics == TargetGlesGraphics.OpenGLES_1_x)
			{
				EditorGUILayout.HelpBox("Clipping requires shader support!\n\nOpen File -> Build Settings -> Player Settings -> Other Settings, then set:\n\n- Graphics Level: OpenGL ES 2.0.", MessageType.Error);
			}
#endif
		}

		if (clipping == UIDrawCall.Clipping.HardClip)
		{
			EditorGUILayout.HelpBox("Hard clipping has been removed due to major performance issues on certain Android devices. Alpha clipping will be used instead.", MessageType.Warning);
		}

		if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(panel.transform.lossyScale))
		{
			EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error);
			
			if (GUILayout.Button("Auto-fix"))
			{
				NGUIEditorTools.FixUniform(panel.gameObject);
			}
		}

		foreach (UIDrawCall dc in drawcalls)
		{
			NGUIEditorTools.DrawSeparator();
			EditorGUILayout.ObjectField("Material", dc.material, typeof(Material), false);
			EditorGUILayout.LabelField("Triangles", dc.triangles.ToString());

			if (clipping != UIDrawCall.Clipping.None && !dc.isClipped)
			{
				EditorGUILayout.HelpBox("You must switch this material's shader to Unlit/Transparent Colored or Unlit/Premultiplied Colored in order for clipping to work.",
					MessageType.Warning);
			}
		}
	}

19 View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218

static public IntVector IntPair (string prefix, string leftCaption, string rightCaption, int x, int y)
	{
		GUILayout.BeginHorizontal();

		if (string.IsNullOrEmpty(prefix))
		{
			GUILayout.Space(82f);
		}
		else
		{
			GUILayout.Label(prefix, GUILayout.Width(74f));
		}

		EditorGUIUtility.LookLikeControls(48f);

		IntVector retVal;
		retVal.x = EditorGUILayout.IntField(leftCaption, x, GUILayout.MinWidth(30f));
		retVal.y = EditorGUILayout.IntField(rightCaption, y, GUILayout.MinWidth(30f));

		EditorGUIUtility.LookLikeControls(80f);

		GUILayout.EndHorizontal();
		return retVal;
	}

19 View Source File : CheckResources.cs
License : Apache License 2.0
Project Creator : 365082218

void OnGUI ()
		{
				if (GUILayout.Button ("Refresh"))
						CheckResources ();
				GUILayout.BeginHorizontal ();
				GUILayout.Label ("Materials " + ActiveMaterials.Count);
				GUILayout.Label ("Textures " + ActiveTextures.Count + " - " + FormatSizeString (TotalTextureMemory));
				GUILayout.Label ("Meshes " + ActiveMeshDetails.Count + " - " + TotalMeshVertices + " verts");
				GUILayout.EndHorizontal ();
				ActiveInspectType = (InspectType)GUILayout.Toolbar ((int)ActiveInspectType, inspectToolbarStrings);
		
				ctrlPressed = Event.current.control || Event.current.command;
		
				switch (ActiveInspectType) {
				case InspectType.Textures:
						ListTextures ();
						break;
				case InspectType.Materials:
						ListMaterials ();
						break;
				case InspectType.Meshes:
						ListMeshes ();
						break;	
			
			
				}
		}

19 View Source File : TransformInspector.cs
License : Apache License 2.0
Project Creator : 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 View Source File : CheckResources.cs
License : Apache License 2.0
Project Creator : 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 View Source File : NGUIEditorTools.cs
License : Apache License 2.0
Project Creator : 365082218

static public void AdvancedSpriteField (UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
		params GUILayoutOption[] options)
	{
		// Give the user a warning if there are no sprites in the atlas
		if (atlas.spriteList.Count == 0)
		{
			EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
			return;
		}

		// Sprite selection drop-down list
		GUILayout.BeginHorizontal();
		{
			if (GUILayout.Button("Sprite", "DropDownButton", GUILayout.Width(76f)))
			{
				SpriteSelector.Show(atlas, spriteName, callback);
			}

			if (editable)
			{
				string sn = GUILayout.TextField(spriteName);

				if (sn != spriteName)
				{
					UIAtlas.Sprite sp = atlas.GetSprite(spriteName);

					if (sp != null)
					{
						NGUIEditorTools.RegisterUndo("Edit Sprite Name", atlas);
						sp.name = sn;
						spriteName = sn;
					}
				}
			}
			else
			{
				GUILayout.BeginHorizontal();
				GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
				GUILayout.Space(18f);
				GUILayout.EndHorizontal();

				if (GUILayout.Button("Edit", GUILayout.Width(40f)))
				{
					EditorPrefs.SetString("NGUI Selected Sprite", spriteName);
					Select(atlas.gameObject);
				}
			}
		}
		GUILayout.EndHorizontal();
	}

19 View Source File : UICreateWidgetWizard.cs
License : Apache License 2.0
Project Creator : 365082218

void CreateSprite (GameObject go, string field)
	{
		if (NGUISettings.atlas != null)
		{
			NGUIEditorTools.SpriteField("Sprite", "Sprite that will be created", NGUISettings.atlas, field, OnSprite);

			if (!string.IsNullOrEmpty(field))
			{
				GUILayout.BeginHorizontal();
				NGUISettings.pivot = (UIWidget.Pivot)EditorGUILayout.EnumPopup("Pivot", NGUISettings.pivot, GUILayout.Width(200f));
				GUILayout.Space(20f);
				GUILayout.Label("Initial pivot point used by the sprite");
				GUILayout.EndHorizontal();
			}
		}

		if (ShouldCreate(go, NGUISettings.atlas != null))
		{
			UISprite sprite = NGUITools.AddWidget<UISprite>(go);
			sprite.name = sprite.name + " (" + field + ")";
			sprite.atlas = NGUISettings.atlas;
			sprite.spriteName = field;
			sprite.pivot = NGUISettings.pivot;
			sprite.MakePixelPerfect();
			Selection.activeGameObject = sprite.gameObject;
		}
	}

See More Examples