// Token: 0x060006C2 RID: 1730 RVA: 0x00037834 File Offset: 0x00035A34 public void MarkAsChanged() { INGUIFont replacement = this.replacement; if (replacement != null) { replacement.MarkAsChanged(); } this.mSprite = null; UILabel[] array = NGUITools.FindActive <UILabel>(); int i = 0; int num = array.Length; while (i < num) { UILabel uilabel = array[i]; if (uilabel.enabled && NGUITools.GetActive(uilabel.gameObject) && NGUITools.CheckIfRelated(this, uilabel.bitmapFont)) { INGUIFont bitmapFont = uilabel.bitmapFont; uilabel.bitmapFont = null; uilabel.bitmapFont = bitmapFont; } i++; } int j = 0; int count = this.symbols.Count; while (j < count) { this.symbols[j].MarkAsChanged(); j++; } }
static public void Draw(INGUIFont font, OnSelectionCallback cb, bool editButton, params GUILayoutOption[] options) { if (font is UIFont) { Draw(font as UIFont, cb, editButton, options); } else { Draw(font as NGUIFont, cb, editButton, options); } }
// Token: 0x060006C6 RID: 1734 RVA: 0x00037AE0 File Offset: 0x00035CE0 public void AddSymbol(string sequence, string spriteName) { INGUIFont replacement = this.replacement; if (replacement != null) { replacement.AddSymbol(sequence, spriteName); return; } this.GetSymbol(sequence, true).spriteName = spriteName; this.MarkAsChanged(); }
/// <summary> /// Helper function that determines whether the font uses the specified one, taking replacements into account. /// </summary> public bool References(INGUIFont font) { if (font == null) { return(false); } if (font == this as INGUIFont) { return(true); } var rep = replacement; return((rep != null) ? rep.References(font) : false); }
// Token: 0x060006C1 RID: 1729 RVA: 0x00037808 File Offset: 0x00035A08 public bool References(INGUIFont font) { if (font == null) { return(false); } if (font == this) { return(true); } INGUIFont replacement = this.replacement; return(replacement != null && replacement.References(font)); }
void OnSelectFont(Object obj) { // Legacy font support if (obj != null && obj is GameObject) { obj = (obj as GameObject).GetComponent <UIFont>(); } // Undo doesn't work correctly in this case... so I won't bother. //NGUIEditorTools.RegisterUndo("Font Change"); //NGUIEditorTools.RegisterUndo("Font Change", mFont); mFont.replacement = obj as INGUIFont; mReplacement = mFont.replacement; NGUITools.SetDirty(mFont as Object); }
// Token: 0x060006C8 RID: 1736 RVA: 0x00037B54 File Offset: 0x00035D54 public void RenameSymbol(string before, string after) { INGUIFont replacement = this.replacement; if (replacement != null) { replacement.RenameSymbol(before, after); return; } BMSymbol symbol = this.GetSymbol(before, false); if (symbol != null) { symbol.sequence = after; } this.MarkAsChanged(); }
// Token: 0x060006C7 RID: 1735 RVA: 0x00037B14 File Offset: 0x00035D14 public void RemoveSymbol(string sequence) { INGUIFont replacement = this.replacement; if (replacement != null) { replacement.RemoveSymbol(sequence); return; } BMSymbol symbol = this.GetSymbol(sequence, false); if (symbol != null) { this.symbols.Remove(symbol); } this.MarkAsChanged(); }
// Token: 0x06000297 RID: 663 RVA: 0x0001A31C File Offset: 0x0001851C protected virtual void OnEnable() { if (EventDelegate.IsValid(this.onChange)) { this.eventReceiver = null; this.functionName = null; } INGUIFont font = this.font; if (this.textScale != 0f) { this.fontSize = ((font != null) ? Mathf.RoundToInt((float)font.defaultSize * this.textScale) : 16); this.textScale = 0f; } if (this.trueTypeFont == null && font != null && font.isDynamic && font.replacement == null) { this.trueTypeFont = font.dynamicFont; this.bitmapFont = null; } }
// Token: 0x060006C5 RID: 1733 RVA: 0x00037A38 File Offset: 0x00035C38 public BMSymbol MatchSymbol(string text, int offset, int textLength) { INGUIFont replacement = this.replacement; if (replacement != null) { return(replacement.MatchSymbol(text, offset, textLength)); } int count = this.mSymbols.Count; if (count == 0) { return(null); } textLength -= offset; for (int i = 0; i < count; i++) { BMSymbol bmsymbol = this.mSymbols[i]; int length = bmsymbol.length; if (length != 0 && textLength >= length) { bool flag = true; for (int j = 0; j < length; j++) { if (text[offset + j] != bmsymbol.sequence[j]) { flag = false; break; } } if (flag && bmsymbol.Validate(this.atlas)) { return(bmsymbol); } } } return(null); }
/// <summary> /// Draw the font preview window. /// </summary> public override void OnPreviewGUI(Rect rect, GUIStyle background) { mFont = target as INGUIFont; if (mFont == null) { return; } Texture2D tex = mFont.texture; if (mView != View.Nothing && tex != null) { Material m = (mUseShader ? mFont.material : null); if (mView == View.Font && mFont.atlas != null && mFont.sprite != null) { NGUIEditorTools.DrawSprite(tex, rect, mFont.sprite, Color.white, m); } else { NGUIEditorTools.DrawTexture(tex, rect, new Rect(0f, 0f, 1f, 1f), Color.white, m); } } }
void OnEnable() { mFont = target as INGUIFont; }
public override void OnInspectorGUI() { NGUIEditorTools.SetLabelWidth(80f); GUILayout.Space(6f); if (mFont.replacement != null) { mType = FontType.Reference; mReplacement = mFont.replacement; } else if (mFont.dynamicFont != null) { mType = FontType.Dynamic; } GUI.changed = false; GUILayout.BeginHorizontal(); mType = (FontType)EditorGUILayout.EnumPopup("Font Type", mType); NGUIEditorTools.DrawPadding(); GUILayout.EndHorizontal(); if (GUI.changed) { if (mType == FontType.Bitmap) { OnSelectFont(null); } if (mType != FontType.Dynamic && mFont.dynamicFont != null) { mFont.dynamicFont = null; } } if (mType == FontType.Reference) { ComponentSelector.Draw(mFont.replacement, OnSelectFont, true); GUILayout.Space(6f); EditorGUILayout.HelpBox("You can have one font simply point to " + "another one. This is useful if you want to be " + "able to quickly replace the contents of one " + "font with another one, for example for " + "swapping an SD font with an HD one, or " + "replacing an English font with a Chinese " + "one. All the labels referencing this font " + "will update their references to the new one.", MessageType.Info); if (mReplacement != mFont && mFont.replacement != mReplacement) { NGUIEditorTools.RegisterUndo("Font Change", mFont as Object); mFont.replacement = mReplacement; NGUITools.SetDirty(mFont as Object); } return; } else if (mType == FontType.Dynamic) { #if UNITY_3_5 EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error); #else Font fnt = EditorGUILayout.ObjectField("TTF Font", mFont.dynamicFont, typeof(Font), false) as Font; if (fnt != mFont.dynamicFont) { NGUIEditorTools.RegisterUndo("Font change", mFont as Object); mFont.dynamicFont = fnt; } Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material; if (mFont.material != mat) { NGUIEditorTools.RegisterUndo("Font Material", mFont as Object); mFont.material = mat; } GUILayout.BeginHorizontal(); int size = EditorGUILayout.IntField("Default Size", mFont.defaultSize, GUILayout.Width(120f)); FontStyle style = (FontStyle)EditorGUILayout.EnumPopup(mFont.dynamicFontStyle); NGUIEditorTools.DrawPadding(); GUILayout.EndHorizontal(); if (size != mFont.defaultSize) { NGUIEditorTools.RegisterUndo("Font change", mFont as Object); mFont.defaultSize = size; } if (style != mFont.dynamicFontStyle) { NGUIEditorTools.RegisterUndo("Font change", mFont as Object); mFont.dynamicFontStyle = style; } #endif } else { ComponentSelector.Draw(mFont.atlas, OnSelectAtlas, true); if (mFont.atlas != null) { if (mFont.bmFont.isValid) { NGUIEditorTools.DrawAdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false); } } 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 as Object); mFont.material = mat; } } if (!mFont.isDynamic) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.IntField("Default Size", mFont.defaultSize, GUILayout.Width(120f)); EditorGUI.EndDisabledGroup(); } EditorGUILayout.Space(); // 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) { TextAsset data = EditorGUILayout.ObjectField("Import Data", null, typeof(TextAsset), false) as TextAsset; if (data != null) { NGUIEditorTools.RegisterUndo("Import Font Data", mFont as Object); BMFontReader.Load(mFont.bmFont, (mFont as Object).name, data.bytes); mFont.MarkAsChanged(); resetWidthHeight = true; Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters"); } } if (mFont is UIFont && mFont.bmFont.isValid) { EditorGUILayout.HelpBox("Legacy font type should be upgraded in order to maintain compatibility with Unity 2018 and newer.", MessageType.Warning, true); if (GUILayout.Button("Upgrade")) { var path = EditorUtility.SaveFilePanelInProject("Save As", (mFont as Object).name + ".asset", "asset", "Save atlas as...", NGUISettings.currentPath); if (!string.IsNullOrEmpty(path)) { NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path); var asset = ScriptableObject.CreateInstance <NGUIFont>(); asset.bmFont = mFont.bmFont; asset.symbols = mFont.symbols; asset.atlas = mFont.atlas; asset.spriteName = mFont.spriteName; asset.uvRect = mFont.uvRect; asset.defaultSize = mFont.defaultSize; var fontName = path.Replace(".asset", ""); fontName = fontName.Substring(path.LastIndexOfAny(new char[] { '/', '\\' }) + 1); asset.name = fontName; AssetDatabase.CreateAsset(asset, path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); asset = AssetDatabase.LoadAssetAtPath <NGUIFont>(path); NGUISettings.ambigiousFont = asset; Selection.activeObject = asset; if (asset != null) { mFont.replacement = asset; mFont.MarkAsChanged(); } } } } if (mFont.bmFont.isValid) { Texture2D tex = mFont.texture; if (tex != null && 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 pixels = EditorGUILayout.RectField("Pixel Rect", pixels); // 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 as Object); mFont.uvRect = uvRect; } //NGUIEditorTools.DrawSeparator(); EditorGUILayout.Space(); } } } // Dynamic fonts don't support emoticons if (!mFont.isDynamic && mFont.bmFont.isValid) { if (mFont.atlas != null) { if (NGUIEditorTools.DrawHeader("Symbols and Emoticons")) { NGUIEditorTools.BeginContents(); 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.DrawSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite, GUILayout.MinWidth(100f))) { mSelectedSymbol = sym; } if (GUILayout.Button("Edit", GUILayout.Width(40f))) { if (mFont.atlas != null) { NGUISettings.atlas = mFont.atlas; NGUISettings.selectedSprite = sym.spriteName; NGUIEditorTools.Select(mFont.atlas as Object); } } GUI.backgroundColor = Color.red; if (GUILayout.Button("X", GUILayout.Width(22f))) { NGUIEditorTools.RegisterUndo("Remove symbol", mFont as Object); mSymbolSequence = sym.sequence; mSymbolSprite = sym.spriteName; symbols.Remove(sym); mFont.MarkAsChanged(); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(4f); ++i; } if (symbols.Count > 0) { GUILayout.Space(6f); } GUILayout.BeginHorizontal(); mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f)); NGUIEditorTools.DrawSpriteField(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 as Object); mFont.AddSymbol(mSymbolSequence, mSymbolSprite); mFont.MarkAsChanged(); 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); } NGUIEditorTools.EndContents(); } } } if (mFont.bmFont != null && mFont.bmFont.isValid) { if (NGUIEditorTools.DrawHeader("Modify")) { NGUIEditorTools.BeginContents(); UISpriteData sd = mFont.sprite; bool disable = (sd != null && (sd.paddingLeft != 0 || sd.paddingBottom != 0)); EditorGUI.BeginDisabledGroup(disable || mFont.packedFontShader); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20f); EditorGUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); NGUISettings.foregroundColor = EditorGUILayout.ColorField("Foreground", NGUISettings.foregroundColor); NGUISettings.backgroundColor = EditorGUILayout.ColorField("Background", NGUISettings.backgroundColor); GUILayout.EndVertical(); mCurve = EditorGUILayout.CurveField("", mCurve, GUILayout.Width(40f), GUILayout.Height(40f)); GUILayout.EndHorizontal(); if (GUILayout.Button("Add a Shadow")) { ApplyEffect(Effect.Shadow, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Add a Soft Outline")) { ApplyEffect(Effect.Outline, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Rebalance Colors")) { ApplyEffect(Effect.Rebalance, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Alpha")) { ApplyEffect(Effect.AlphaCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Foreground")) { ApplyEffect(Effect.ForegroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Background")) { ApplyEffect(Effect.BackgroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } GUILayout.Space(10f); if (GUILayout.Button("Add Transparent Border (+1)")) { ApplyEffect(Effect.Border, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Remove Border (-1)")) { ApplyEffect(Effect.Crop, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } EditorGUILayout.EndVertical(); GUILayout.Space(20f); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); if (disable) { GUILayout.Space(3f); EditorGUILayout.HelpBox("The sprite used by this font has been trimmed and is not suitable for modification. " + "Try re-adding this sprite with 'Trim Alpha' disabled.", MessageType.Warning); } NGUIEditorTools.EndContents(); } } // The font must be valid at this point for the rest of the options to show up if (mFont.isDynamic || mFont.bmFont.isValid) { if (mFont.atlas == null) { mView = View.Font; mUseShader = false; } } // 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(); } }
// Token: 0x060006FD RID: 1789 RVA: 0x000394C8 File Offset: 0x000376C8 public void MarkAsChanged() { INGUIAtlas replacement = this.replacement; if (replacement != null) { replacement.MarkAsChanged(); } UISprite[] array = NGUITools.FindActive <UISprite>(); int i = 0; int num = array.Length; while (i < num) { UISprite uisprite = array[i]; if (NGUITools.CheckIfRelated(this, uisprite.atlas)) { INGUIAtlas atlas = uisprite.atlas; uisprite.atlas = null; uisprite.atlas = atlas; } i++; } NGUIFont[] array2 = Resources.FindObjectsOfTypeAll <NGUIFont>(); int j = 0; int num2 = array2.Length; while (j < num2) { NGUIFont nguifont = array2[j]; if (nguifont.atlas != null && NGUITools.CheckIfRelated(this, nguifont.atlas)) { INGUIAtlas atlas2 = nguifont.atlas; nguifont.atlas = null; nguifont.atlas = atlas2; } j++; } UIFont[] array3 = Resources.FindObjectsOfTypeAll <UIFont>(); int k = 0; int num3 = array3.Length; while (k < num3) { UIFont uifont = array3[k]; if (NGUITools.CheckIfRelated(this, uifont.atlas)) { INGUIAtlas atlas3 = uifont.atlas; uifont.atlas = null; uifont.atlas = atlas3; } k++; } UILabel[] array4 = NGUITools.FindActive <UILabel>(); int l = 0; int num4 = array4.Length; while (l < num4) { UILabel uilabel = array4[l]; if (uilabel.atlas != null && NGUITools.CheckIfRelated(this, uilabel.atlas)) { INGUIAtlas atlas4 = uilabel.atlas; INGUIFont bitmapFont = uilabel.bitmapFont; uilabel.bitmapFont = null; uilabel.bitmapFont = bitmapFont; } l++; } }
public override void OnInspectorGUI() { NGUIEditorTools.SetLabelWidth(80f); GUILayout.Space(6f); var type = mFont.type; if (type == NGUIFontType.Reference) { mReplacement = mFont.replacement; } GUI.changed = false; GUILayout.BeginHorizontal(); type = (NGUIFontType)EditorGUILayout.EnumPopup("Font Type", type); GUILayout.EndHorizontal(); if (GUI.changed) { NGUIEditorTools.RegisterUndo("Font Change", mFont as Object); mFont.type = type; NGUITools.SetDirty(mFont as Object); } if (type == NGUIFontType.Reference) { ComponentSelector.Draw(mFont.replacement, OnSelectFont, true); GUILayout.Space(6f); EditorGUILayout.HelpBox("Reference fonts will have their font data come from another one. " + "This allows you to have your labels reference a font that has all the emoticons, that also points to a secondary font containing the actual glyph data " + "that can be easily swapped at run-time with a font containing glyphs of another language.", MessageType.Info); if (mReplacement != mFont && mFont.replacement != mReplacement) { NGUIEditorTools.RegisterUndo("Font Change", mFont as Object); mFont.replacement = mReplacement; NGUITools.SetDirty(mFont as Object); } } if (type == NGUIFontType.Dynamic) { #if UNITY_3_5 EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error); #else Font fnt = EditorGUILayout.ObjectField("TTF Font", mFont.dynamicFont, typeof(Font), false) as Font; if (fnt != mFont.dynamicFont) { NGUIEditorTools.RegisterUndo("Font change", mFont as Object); mFont.dynamicFont = fnt; } var mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material; if (mFont.material != mat) { NGUIEditorTools.RegisterUndo("Font Material", mFont as Object); mFont.material = mat; } #endif } if (type == NGUIFontType.Bitmap) { ComponentSelector.Draw(mFont.atlas, OnSelectAtlas, true); if (mFont.atlas != null) { if (mFont.bmFont.isValid) { NGUIEditorTools.DrawAdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false); } } else { // No atlas specified -- set the material and texture rectangle directly var mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material; if (mFont.material != mat) { NGUIEditorTools.RegisterUndo("Font Material", mFont as Object); mFont.material = mat; } } } if (type != NGUIFontType.Reference) { GUI.changed = false; //EditorGUI.BeginDisabledGroup(mFont.isDynamic); var size = EditorGUILayout.IntField("Default Size", mFont.defaultSize, GUILayout.Width(120f)); //EditorGUI.EndDisabledGroup(); GUILayout.BeginHorizontal(); int space = EditorGUILayout.IntField("Space Width", mFont.spaceWidth, GUILayout.Width(120f)); if (space == 0) { GUILayout.Label("(default)"); } GUILayout.EndHorizontal(); if (GUI.changed) { NGUIEditorTools.RegisterUndo("Font change", mFont as Object); mFont.spaceWidth = space; mFont.defaultSize = size; var labels = NGUITools.FindActive <UILabel>(); foreach (UILabel lbl in labels) { if (lbl.font == null) { continue; } var font = lbl.font; if (NGUITools.CheckIfRelated(font, mFont)) { lbl.font = null; lbl.font = font; NGUITools.SetDirty(lbl); } } } EditorGUILayout.Space(); } if (type == NGUIFontType.Dynamic || type == NGUIFontType.Reference) { var font = mFont as NGUIFont; if (font != null) { if (NGUIEditorTools.DrawHeader("Symbol Atlas")) { NGUIEditorTools.BeginContents(); ComponentSelector.Draw(font.symbolAtlas, OnSelectSymbolAtlas, true); NGUIEditorTools.EndContents(); } EditorGUILayout.Space(); } } // For updating the font's data when importing from an external source, such as the texture packer bool resetWidthHeight = false; if (type == NGUIFontType.Bitmap && (mFont.atlas != null || mFont.material != null)) { if (NGUIEditorTools.DrawHeader("Import")) { NGUIEditorTools.BeginContents(); var data = EditorGUILayout.ObjectField("Import Data", null, typeof(TextAsset), false) as TextAsset; if (data != null) { NGUIEditorTools.RegisterUndo("Import Font Data", mFont as Object); BMFontReader.Load(mFont.bmFont, (mFont as Object).name, data.bytes); mFont.MarkAsChanged(); resetWidthHeight = true; Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters"); } NGUIEditorTools.EndContents(); } EditorGUILayout.Space(); } if (mFont is UIFont && mFont.bmFont.isValid) { EditorGUILayout.HelpBox("Legacy font type should be upgraded in order to maintain compatibility with Unity 2018 and newer.", MessageType.Warning, true); if (GUILayout.Button("Upgrade")) { var path = EditorUtility.SaveFilePanelInProject("Save As", (mFont as Object).name + ".asset", "asset", "Save font as...", NGUISettings.currentPath); if (!string.IsNullOrEmpty(path)) { NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path); var asset = ScriptableObject.CreateInstance <NGUIFont>(); asset.bmFont = mFont.bmFont; asset.symbols = mFont.symbols; asset.atlas = mFont.atlas; asset.spriteName = mFont.spriteName; asset.uvRect = mFont.uvRect; asset.defaultSize = mFont.defaultSize; var fontName = path.Replace(".asset", ""); fontName = fontName.Substring(path.LastIndexOfAny(new char[] { '/', '\\' }) + 1); asset.name = fontName; var existing = AssetDatabase.LoadMainAssetAtPath(path); if (existing != null) { EditorUtility.CopySerialized(asset, existing); } else { AssetDatabase.CreateAsset(asset, path); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); asset = AssetDatabase.LoadAssetAtPath <NGUIFont>(path); NGUISettings.ambigiousFont = asset; Selection.activeObject = asset; if (asset != null) { mFont.replacement = asset; mFont.MarkAsChanged(); } } } } if (type == NGUIFontType.Bitmap && mFont.bmFont.isValid) { Texture2D tex = mFont.texture; if (tex != null && 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 pixels = EditorGUILayout.RectField("Pixel Rect", pixels); // 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 as Object); mFont.uvRect = uvRect; } //NGUIEditorTools.DrawSeparator(); EditorGUILayout.Space(); } } var nguiFont = mFont as NGUIFont; var symbolAtlas = (nguiFont != null) ? nguiFont.symbolAtlas : null; if (symbolAtlas == null && type != NGUIFontType.Reference) { symbolAtlas = mFont.atlas; } if (symbolAtlas != null && NGUIEditorTools.DrawHeader("Symbols and Emoticons")) { NGUIEditorTools.BeginContents(); var symbols = mFont.symbols; for (int i = 0; i < symbols.Count;) { var sym = symbols[i]; GUILayout.BeginHorizontal(); GUILayout.Label(sym.sequence, GUILayout.Width(40f)); if (NGUIEditorTools.DrawSpriteField(symbolAtlas, sym.spriteName, ChangeSymbolSprite, GUILayout.MinWidth(100f))) { mSelectedSymbol = sym; } var col = GUILayout.Toggle(sym.colored, new GUIContent(""), GUILayout.Width(16f)); if (col != sym.colored) { sym.colored = col; mFont.MarkAsChanged(); } if (GUILayout.Button("Edit", GUILayout.Width(40f)) && symbolAtlas != null) { NGUISettings.atlas = symbolAtlas; NGUISettings.selectedSprite = sym.spriteName; NGUIEditorTools.Select(symbolAtlas as Object); } GUI.backgroundColor = Color.red; if (GUILayout.Button("X", GUILayout.Width(22f))) { NGUIEditorTools.RegisterUndo("Remove symbol", mFont as Object); mSymbolSequence = sym.sequence; mSymbolSprite = sym.spriteName; symbols.Remove(sym); mFont.MarkAsChanged(); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); //GUILayout.Space(4f); ++i; } if (symbols.Count > 0) { if (Event.current.type == EventType.Repaint) { Texture2D tex = NGUIEditorTools.blankTexture; Rect rect = GUILayoutUtility.GetLastRect(); GUI.color = new Color(0f, 0f, 0f, 0.25f); GUI.DrawTexture(new Rect(20f, rect.yMin + 28f, Screen.width - 30f, 1f), tex); GUI.color = Color.white; } GUILayout.Space(10f); } GUILayout.BeginHorizontal(); mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f)); NGUIEditorTools.DrawSpriteField(symbolAtlas, 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 as Object); var sym = mFont.AddSymbol(mSymbolSequence, mSymbolSprite); sym.colored = mSymbolColored; mFont.MarkAsChanged(); mSymbolSequence = ""; mSymbolSprite = ""; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); NGUIEditorTools.SetLabelWidth(42f); GUILayout.BeginHorizontal(); mSymbolColored = EditorGUILayout.Toggle("Tinted", mSymbolColored, GUILayout.Width(60f)); GUILayout.Label("- affected by label's color by default"); GUILayout.EndHorizontal(); NGUIEditorTools.SetLabelWidth(80f); 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); } if (nguiFont != null) { if (Event.current.type == EventType.Repaint) { Texture2D tex = NGUIEditorTools.blankTexture; Rect rect = GUILayoutUtility.GetLastRect(); GUI.color = new Color(0f, 0f, 0f, 0.25f); GUI.DrawTexture(new Rect(20f, rect.yMin + 6f, Screen.width - 30f, 1f), tex); GUI.color = Color.white; } GUILayout.Space(6f); GUI.changed = false; GUILayout.BeginHorizontal(); GUILayout.Label("Scale", GUILayout.Width(40f)); var scale = EditorGUILayout.FloatField(nguiFont.symbolScale, GUILayout.Width(50f)); GUILayout.Label("- scaling multiplier"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Offset", GUILayout.Width(40f)); var offset = EditorGUILayout.IntField(nguiFont.symbolOffset, GUILayout.Width(50f)); GUILayout.Label("- vertical offset"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Height", GUILayout.Width(40f)); var height = EditorGUILayout.IntField(nguiFont.symbolMaxHeight, GUILayout.Width(50f)); GUILayout.Label("- maximum sprite height"); GUILayout.EndHorizontal(); if (GUI.changed) { NGUIEditorTools.RegisterUndo("Change symbol values", mFont as Object); nguiFont.symbolScale = scale; nguiFont.symbolOffset = offset; nguiFont.symbolMaxHeight = height; nguiFont.MarkAsChanged(); } } NGUIEditorTools.EndContents(); } if (type == NGUIFontType.Bitmap && mFont.bmFont != null && mFont.bmFont.isValid) { if (NGUIEditorTools.DrawHeader("Modify")) { NGUIEditorTools.BeginContents(); UISpriteData sd = mFont.sprite; bool disable = (sd != null && (sd.paddingLeft != 0 || sd.paddingBottom != 0)); EditorGUI.BeginDisabledGroup(disable || mFont.packedFontShader); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20f); EditorGUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); NGUISettings.foregroundColor = EditorGUILayout.ColorField("Foreground", NGUISettings.foregroundColor); NGUISettings.backgroundColor = EditorGUILayout.ColorField("Background", NGUISettings.backgroundColor); GUILayout.EndVertical(); mCurve = EditorGUILayout.CurveField("", mCurve, GUILayout.Width(40f), GUILayout.Height(40f)); GUILayout.EndHorizontal(); if (GUILayout.Button("Add a Shadow")) { ApplyEffect(Effect.Shadow, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Add a Soft Outline")) { ApplyEffect(Effect.Outline, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Rebalance Colors")) { ApplyEffect(Effect.Rebalance, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Alpha")) { ApplyEffect(Effect.AlphaCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Foreground")) { ApplyEffect(Effect.ForegroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Background")) { ApplyEffect(Effect.BackgroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } GUILayout.Space(10f); if (GUILayout.Button("Add Transparent Border (+1)")) { ApplyEffect(Effect.Border, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Remove Border (-1)")) { ApplyEffect(Effect.Crop, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } EditorGUILayout.EndVertical(); GUILayout.Space(20f); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); if (disable) { GUILayout.Space(3f); EditorGUILayout.HelpBox("The sprite used by this font has been trimmed and is not suitable for modification. " + "Try re-adding this sprite with 'Trim Alpha' disabled.", MessageType.Warning); } NGUIEditorTools.EndContents(); } } if (mFont.atlas == null) { mView = View.Font; mUseShader = false; } // Preview option if (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(); } }
// Token: 0x060007AF RID: 1967 RVA: 0x0003FB38 File Offset: 0x0003DD38 public void UpdateLabel() { if (this.label != null) { if (this.mDoInit) { this.Init(); } bool isSelected = this.isSelected; string value = this.value; bool flag = string.IsNullOrEmpty(value) && string.IsNullOrEmpty(Input.compositionString); this.label.color = ((flag && !isSelected) ? this.mDefaultColor : this.activeTextColor); string text; if (flag) { text = (isSelected ? "" : this.mDefaultText); this.label.alignment = this.mAlignment; } else { if (this.inputType == UIInput.InputType.Password) { text = ""; string str = "*"; INGUIFont bitmapFont = this.label.bitmapFont; if (bitmapFont != null && bitmapFont.bmFont != null && bitmapFont.bmFont.GetGlyph(42) == null) { str = "x"; } int i = 0; int length = value.Length; while (i < length) { text += str; i++; } } else { text = value; } int num = isSelected ? Mathf.Min(text.Length, this.cursorPosition) : 0; string str2 = text.Substring(0, num); if (isSelected) { str2 += Input.compositionString; } text = str2 + text.Substring(num, text.Length - num); if (isSelected && this.label.overflowMethod == UILabel.Overflow.ClampContent && this.label.maxLineCount == 1) { int num2 = this.label.CalculateOffsetToFit(text); if (num2 == 0) { UIInput.mDrawStart = 0; this.label.alignment = this.mAlignment; } else if (num < UIInput.mDrawStart) { UIInput.mDrawStart = num; this.label.alignment = NGUIText.Alignment.Left; } else if (num2 < UIInput.mDrawStart) { UIInput.mDrawStart = num2; this.label.alignment = NGUIText.Alignment.Left; } else { num2 = this.label.CalculateOffsetToFit(text.Substring(0, num)); if (num2 > UIInput.mDrawStart) { UIInput.mDrawStart = num2; this.label.alignment = NGUIText.Alignment.Right; } } if (UIInput.mDrawStart != 0) { text = text.Substring(UIInput.mDrawStart, text.Length - UIInput.mDrawStart); } } else { UIInput.mDrawStart = 0; this.label.alignment = this.mAlignment; } } this.label.text = text; if (isSelected) { int num3 = this.mSelectionStart - UIInput.mDrawStart; int num4 = this.mSelectionEnd - UIInput.mDrawStart; if (this.mBlankTex == null) { this.mBlankTex = new Texture2D(2, 2, TextureFormat.ARGB32, false); for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { this.mBlankTex.SetPixel(k, j, Color.white); } } this.mBlankTex.Apply(); } if (num3 != num4) { if (this.mHighlight == null) { this.mHighlight = this.label.cachedGameObject.AddWidget(int.MaxValue); this.mHighlight.name = "Input Highlight"; this.mHighlight.mainTexture = this.mBlankTex; this.mHighlight.fillGeometry = false; this.mHighlight.pivot = this.label.pivot; this.mHighlight.SetAnchor(this.label.cachedTransform); } else { this.mHighlight.pivot = this.label.pivot; this.mHighlight.mainTexture = this.mBlankTex; this.mHighlight.MarkAsChanged(); this.mHighlight.enabled = true; } } if (this.mCaret == null) { this.mCaret = this.label.cachedGameObject.AddWidget(int.MaxValue); this.mCaret.name = "Input Caret"; this.mCaret.mainTexture = this.mBlankTex; this.mCaret.fillGeometry = false; this.mCaret.pivot = this.label.pivot; this.mCaret.SetAnchor(this.label.cachedTransform); } else { this.mCaret.pivot = this.label.pivot; this.mCaret.mainTexture = this.mBlankTex; this.mCaret.MarkAsChanged(); this.mCaret.enabled = true; } if (num3 != num4) { this.label.PrintOverlay(num3, num4, this.mCaret.geometry, this.mHighlight.geometry, this.caretColor, this.selectionColor); this.mHighlight.enabled = this.mHighlight.geometry.hasVertices; } else { this.label.PrintOverlay(num3, num4, this.mCaret.geometry, null, this.caretColor, this.selectionColor); if (this.mHighlight != null) { this.mHighlight.enabled = false; } } this.mNextBlink = RealTime.time + 0.5f; this.mLastAlpha = this.label.finalAlpha; return; } this.Cleanup(); } }