public void UpdateStyle(SubStyle style) { styles = new List <SubStyle>() { style }; }
public void NewMessage(OSDMessage.Type type, string msg, SubStyle style, int duration = -1) { NewMessage(type, msg, new List <SubStyle>() { style }, duration); }
public void NewMessage(OSDMessage.Type type, string msg, SubStyle style, int duration = -1) { if (!OSDEnabled) { return; } NewMessage(type, msg, new List <SubStyle>() { style }, duration); }
public void Blend(SubStyle sub, InstantGuiElement element, float blend) //done after base style apply { //removing a blended texture if necessary if ((!sub.enabled || sub.texture == null) && element.blendGuiTexture != null) { GameObject.DestroyImmediate(element.blendGuiTexture.gameObject); } //setting texture if (sub.texture != null) { if (!element.blendGuiTexture) { GameObject obj = new GameObject(element.transform.name + "_blendTexture"); obj.transform.parent = element.transform; //obj.hideFlags = HideFlags.HideInHierarchy; element.blendGuiTexture = obj.AddComponent <GUITexture>(); } if (element.blendGuiTexture.texture != sub.texture) { element.blendGuiTexture.texture = sub.texture; } element.blendGuiTexture.transform.localPosition = new Vector3(0, 0, element.transform.localPosition.z + 0.005f); element.blendGuiTexture.pixelInset = InstantGui.Invert(element.absolute.ToRect(InstantGui.scale)); if (borders != null) { element.blendGuiTexture.border = borders; } element.blendGuiTexture.color = new Color(element.blendGuiTexture.color.r, element.blendGuiTexture.color.g, element.blendGuiTexture.color.b, blend * 0.5f); if (element.mainGuiTexture != null) { element.mainGuiTexture.color = new Color(element.mainGuiTexture.color.r, element.mainGuiTexture.color.g, element.mainGuiTexture.color.b, (1 - blend * blend) * 0.5f); } } if (element.guiTexts != null && element.guiTexts.Length > 0) { element.textMaterial.color = element.textMaterial.color * (1 - blend) + sub.textColor * blend; } }
static public void DrawSubStyle(SubStyle sub, string name) { int toggleSize = 16; int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; Rect rect = GUILayoutUtility.GetRect(50, 16, "TextField"); rect.x += indent * indentPixels; rect.width -= indent * indentPixels; sub.enabled = EditorGUI.Toggle(rect, sub.enabled); rect.x += toggleSize; rect.width -= toggleSize; //rect.y+=2; EditorGUI.LabelField(rect, name); if (sub.enabled) { //texture rect = GUILayoutUtility.GetRect(50, 16, "TextField"); rect.x += (indent + 1) * indentPixels; rect.width -= (indent + 1) * indentPixels; sub.texture = (Texture)EditorGUI.ObjectField(rect, "Texture:", sub.texture, typeof(Texture), false); EditorGUI.indentLevel = 2; Vector2 textOffset = DrawVector2("Text Offset", new Vector2(sub.textOffsetX, sub.textOffsetY)); sub.textOffsetX = (int)(textOffset.x); sub.textOffsetY = (int)(textOffset.y); EditorGUI.indentLevel = 0; EditorGUIUtility.LookLikeControls(120, 15); rect = GUILayoutUtility.GetRect(50, 16, "TextField"); rect.x += (indent + 1) * indentPixels; rect.width -= (indent + 1) * indentPixels; sub.textColor = EditorGUI.ColorField(rect, "Text Color:", sub.textColor); } EditorGUI.indentLevel = indent; }
public virtual void ApplyStyle() //re-written { //trying to load style if styleSet assigned (usually after scene loading) if (!customStyle && styleSet != null) { style = styleSet.FindStyle(styleName); } //clearing if no style assigned if (style == null) { InstantGuiStyle.Clear(this); } else { //calculating style SubStyle subStyle = style.main; if (style.disabled.enabled && disabled) { subStyle = style.disabled; } if (style.active.enabled && (check || pressed)) { subStyle = style.active; } //calculating pointed blend if (style.pointed.enabled && !disabled && !pressed && !check) { if (pointed) { pointedBlend = Mathf.Min(pointedBlend + Time.deltaTime * style.blendSpeed, 1); } else { pointedBlend = Mathf.Max(pointedBlend - Time.deltaTime * style.blendSpeed, 0); } //setting pointed time and blend to zero if in editor #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { pointedTime = 0; unpointedTime = 0; pointedBlend = 0; } #endif } //apply style if (pointedBlend < 0.001f || disabled || pressed || check) { style.Unblend(this); style.Apply(subStyle, this); } else if (pointedBlend > 0.999f) { style.Unblend(this); style.Apply(style.pointed, this); } else //blended { style.Apply(subStyle, this); style.Blend(style.pointed, this, pointedBlend); } } //recursive for (int i = 0; i < childElements.Count; i++) { childElements[i].ApplyStyle(); } }
public OSDMessage(Type type, string msg, SubStyle style, int duration = -1) : this(type, msg, new List <SubStyle>() { style }, duration) { }
static public void DrawSubStyle ( SubStyle sub , string name ) { int toggleSize = 16; int indent= EditorGUI.indentLevel; EditorGUI.indentLevel = 0; Rect rect = GUILayoutUtility.GetRect (50, 16, "TextField"); rect.x+=indent*indentPixels; rect.width-=indent*indentPixels; sub.enabled = EditorGUI.Toggle(rect, sub.enabled); rect.x+=toggleSize; rect.width-=toggleSize; //rect.y+=2; EditorGUI.LabelField(rect,name); if (sub.enabled) { //texture rect = GUILayoutUtility.GetRect (50, 16, "TextField"); rect.x+=(indent+1)*indentPixels; rect.width-=(indent+1)*indentPixels; sub.texture = (Texture)EditorGUI.ObjectField(rect, "Texture:", sub.texture, typeof(Texture), false); EditorGUI.indentLevel = 2; Vector2 textOffset = DrawVector2("Text Offset", new Vector2(sub.textOffsetX, sub.textOffsetY)); sub.textOffsetX = (int)(textOffset.x); sub.textOffsetY = (int)(textOffset.y); EditorGUI.indentLevel = 0; EditorGUIUtility.LookLikeControls(120, 15); rect = GUILayoutUtility.GetRect (50, 16, "TextField"); rect.x+=(indent+1)*indentPixels; rect.width-=(indent+1)*indentPixels; sub.textColor = EditorGUI.ColorField(rect, "Text Color:", sub.textColor); } EditorGUI.indentLevel = indent; }
public static string SSAtoSubStyles(string s, out List <SubStyle> styles) { int pos = 0; string sout = ""; styles = new List <SubStyle>(); SubStyle bold = new SubStyle(SubStyles.BOLD); SubStyle italic = new SubStyle(SubStyles.ITALIC); SubStyle underline = new SubStyle(SubStyles.UNDERLINE); SubStyle strikeout = new SubStyle(SubStyles.STRIKEOUT); SubStyle color = new SubStyle(SubStyles.COLOR); //SubStyle fontname = new SubStyle(SubStyles.FONTNAME); //SubStyle fontsize = new SubStyle(SubStyles.FONTSIZE); s = s.LastIndexOf(",,") == -1 ? s : s.Substring(s.LastIndexOf(",,") + 2).Replace("\\N", "\n").Trim(); for (int i = 0; i < s.Length; i++) { if (s[i] == '{') { continue; } if (s[i] == '\\' && s[i - 1] == '{') { int codeLen = s.IndexOf('}', i) - i; if (codeLen == -1) { continue; } string code = s.Substring(i, codeLen).Trim(); switch (code[1]) { case 'c': if (code.Length == 2) { if (color.from == -1) { break; } color.len = pos - color.from; if ((Color)color.value != Color.Transparent) { styles.Add(color); } color = new SubStyle(SubStyles.COLOR); } else { color.from = pos; color.value = Color.Transparent; if (code.Length < 7) { break; } int colorEnd = code.LastIndexOf("&"); if (colorEnd < 6) { break; } string hexColor = code.Substring(4, colorEnd - 4); int red = int.Parse(hexColor.Substring(hexColor.Length - 2, 2), System.Globalization.NumberStyles.HexNumber); int green = 0; int blue = 0; if (hexColor.Length - 2 > 0) { hexColor = hexColor.Substring(0, hexColor.Length - 2); green = int.Parse(hexColor.Substring(hexColor.Length - 2, 2), System.Globalization.NumberStyles.HexNumber); } if (hexColor.Length - 2 > 0) { hexColor = hexColor.Substring(0, hexColor.Length - 2); blue = int.Parse(hexColor.Substring(hexColor.Length - 2, 2), System.Globalization.NumberStyles.HexNumber); } color.value = new Color(red, green, blue); } break; case 'b': if (code[2] == '0') { if (bold.from == -1) { break; } bold.len = pos - bold.from; styles.Add(bold); bold = new SubStyle(SubStyles.BOLD); } else { bold.from = pos; //bold.value = code.Substring(2, code.Length-2); } break; case 'u': if (code[2] == '0') { if (underline.from == -1) { break; } underline.len = pos - underline.from; styles.Add(underline); underline = new SubStyle(SubStyles.UNDERLINE); } else { underline.from = pos; } break; case 's': if (code[2] == '0') { if (strikeout.from == -1) { break; } strikeout.len = pos - strikeout.from; styles.Add(strikeout); strikeout = new SubStyle(SubStyles.STRIKEOUT); } else { strikeout.from = pos; } break; case 'i': if (code[2] == '0') { if (italic.from == -1) { break; } italic.len = pos - italic.from; styles.Add(italic); italic = new SubStyle(SubStyles.ITALIC); } else { italic.from = pos; } break; } i += codeLen; continue; } sout += s[i]; pos++; } // Non-Closing Codes int soutPostLast = sout.Length; if (bold.from != -1) { bold.len = soutPostLast - bold.from; styles.Add(bold); } if (italic.from != -1) { italic.len = soutPostLast - italic.from; styles.Add(italic); } if (strikeout.from != -1) { strikeout.len = soutPostLast - strikeout.from; styles.Add(strikeout); } if (underline.from != -1) { underline.len = soutPostLast - underline.from; styles.Add(underline); } if (color.from != -1 && (Color)color.value != Color.Transparent) { color.len = soutPostLast - color.from; styles.Add(color); } return(sout); }
public RectOffset pointOffset;// = new RectOffset(0,0,0,0); /* public InstantGuiStyle() { main = new SubStyle(); pointed = result.pointed.Clone(); active = result.active.Clone(); result.disabled = result.disabled.Clone(); result.relative = result.relative.Clone(); result.offset = result.offset.Clone(); result.pointOffset = new RectOffset(result.pointOffset.left, result.pointOffset.right, result.pointOffset.top, result.pointOffset.bottom); result.borders = new RectOffset(result.borders.left, result.borders.right, result.borders.top, result.borders.bottom); return result; } */ public void Apply (SubStyle sub, InstantGuiElement element) { //getting number of texts that should be in element int textsLength=0; if (element.text.Length==0) textsLength = 0; else switch (textEffect) { case InstantGuiTextEffect.simple: textsLength = 1; break; case InstantGuiTextEffect.shadow: textsLength = 2; break; case InstantGuiTextEffect.stroke: textsLength = 5; break; } //should a texture ot text be removed? bool removeTexture=false; bool removeTexts=false; if (!sub.enabled) { removeTexture = true; removeTexts = true; } if (!sub.texture) removeTexture = true; if (element.guiTexts.Length != textsLength) removeTexts = true; //if text Length changed. No text included if (font!=element.currentFont) removeTexts = true; //if font changed for (int i=0; i<element.guiTexts.Length; i++) if (!element.guiTexts[i]) removeTexts = true; //if any of guitexts array do not exists //removing if (removeTexture && element.mainGuiTexture!=null) { GameObject.DestroyImmediate(element.mainGuiTexture.gameObject); } if (removeTexts) { for(int i=element.guiTexts.Length-1; i>=0 ; i--) if (element.guiTexts[i]!=null) GameObject.DestroyImmediate(element.guiTexts[i].gameObject); //creating new array element.guiTexts = new GUIText[textsLength]; } if (!sub.enabled || (!sub.texture && element.text.Length==0)) return; //setting texture if (sub.texture!=null) { if (element.mainGuiTexture==null) { GameObject obj = new GameObject (element.transform.name + "_mainTexture"); obj.transform.parent = element.transform; obj.hideFlags = HideFlags.HideInHierarchy; element.mainGuiTexture = obj.AddComponent<GUITexture>(); } if (element.mainGuiTexture.texture != sub.texture) element.mainGuiTexture.texture = sub.texture; element.mainGuiTexture.transform.localPosition = new Vector3(0,0,element.transform.localPosition.z); element.mainGuiTexture.pixelInset = InstantGui.Invert(element.absolute.ToRect(InstantGui.scale)); if (borders!=null) element.mainGuiTexture.border = borders; } //proportional if (proportional && element.mainGuiTexture!=null) { Rect newInset = element.mainGuiTexture.pixelInset; if (1.0f * element.mainGuiTexture.pixelInset.width / element.mainGuiTexture.pixelInset.height < proportionalAspect) { newInset.width = element.mainGuiTexture.pixelInset.height*proportionalAspect; newInset.x -= (newInset.width-element.mainGuiTexture.pixelInset.width)*0.5f; } else { newInset.height = element.mainGuiTexture.pixelInset.width*(1.0f/proportionalAspect); newInset.y -= (newInset.height-element.mainGuiTexture.pixelInset.height)*0.5f; } element.mainGuiTexture.pixelInset = newInset; } //setting text if (element.text.Length!=0) { //on font change - remove materials if (!font) font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"); if (font != element.currentFont) { //element.textMaterial=null; //if (element.guiTexts.Length > 1) element.textEffectMaterial=null; for (int i=0;i<element.guiTexts.Length;i++) if (element.guiTexts[i]!=null) GameObject.DestroyImmediate(element.guiTexts[i].gameObject); element.currentFont = font; } //creating texts for (int i=0;i<element.guiTexts.Length;i++) { if (element.guiTexts[i]==null) { GameObject obj = new GameObject (element.transform.name + "_text" + i.ToString()); obj.transform.parent = element.transform; obj.hideFlags = HideFlags.HideInHierarchy; element.guiTexts[i] = obj.AddComponent<GUIText>(); //setting materials if (i==0) { element.textMaterial = new Material (font.material); element.guiTexts[i].material = element.textMaterial; } else if (i>0 && i==element.guiTexts.Length-1) //on the last one effect text { element.textEffectMaterial = new Material (font.material); for (int j=1;j<element.guiTexts.Length;j++) element.guiTexts[j].material = element.textEffectMaterial; } } } //setting text params for (int i=0;i<element.guiTexts.Length;i++) { if (i==0) element.textMaterial.color = sub.textColor; else element.textEffectMaterial.color = textEffectColor; element.guiTexts[i].transform.localPosition = new Vector3(0,0,element.transform.localPosition.z+0.01f - i*0.001f); //setting text if (element.guiTexts[i].text != element.text && !element.password) element.guiTexts[i].text = element.text; else if (element.password) { element.guiTexts[i].text = ""; for (int j=0;j<element.text.Length;j++) element.guiTexts[i].text += "*"; } if (element.guiTexts[i].font != font) element.guiTexts[i].font = font; if (element.guiTexts[i].fontSize != fontSize) element.guiTexts[i].fontSize = fontSize; Vector2 pixelOffset = element.absolute.GetCenter(); switch (textAligment) { case InstantGuiTextAligment.center: element.guiTexts[i].anchor = TextAnchor.MiddleCenter; break; case InstantGuiTextAligment.text: pixelOffset.y = element.absolute.top; pixelOffset.x = element.absolute.left; element.guiTexts[i].anchor = TextAnchor.UpperLeft; break; case InstantGuiTextAligment.heading: pixelOffset.y = element.absolute.top; element.guiTexts[i].anchor = TextAnchor.UpperCenter; break; case InstantGuiTextAligment.above: pixelOffset.y = element.absolute.top; element.guiTexts[i].anchor = TextAnchor.LowerCenter; break; case InstantGuiTextAligment.label: pixelOffset.x = element.absolute.left; element.guiTexts[i].anchor = TextAnchor.MiddleRight; break; case InstantGuiTextAligment.rightLabel: pixelOffset.x = element.absolute.right; element.guiTexts[i].anchor = TextAnchor.MiddleLeft; break; } pixelOffset += new Vector2(textOffsetX+sub.textOffsetX, textOffsetY+sub.textOffsetY); element.guiTexts[i].pixelOffset = InstantGui.Invert(pixelOffset); } //aligning text effect if (textEffect==InstantGuiTextEffect.shadow) { element.guiTexts[1].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(textEffectSize*0.75f,-textEffectSize); } else if (textEffect==InstantGuiTextEffect.stroke) { element.guiTexts[1].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(textEffectSize,textEffectSize); element.guiTexts[2].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(-textEffectSize,textEffectSize); element.guiTexts[3].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(-textEffectSize,-textEffectSize); element.guiTexts[4].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(textEffectSize,-textEffectSize); } } }
public void Blend ( SubStyle sub , InstantGuiElement element , float blend ) //done after base style apply { //removing a blended texture if necessary if ((!sub.enabled || sub.texture==null) && element.blendGuiTexture!=null) GameObject.DestroyImmediate(element.blendGuiTexture.gameObject); //setting texture if (sub.texture!=null) { if (!element.blendGuiTexture) { GameObject obj = new GameObject (element.transform.name + "_blendTexture"); obj.transform.parent = element.transform; //obj.hideFlags = HideFlags.HideInHierarchy; element.blendGuiTexture = obj.AddComponent<GUITexture>(); } if (element.blendGuiTexture.texture != sub.texture) element.blendGuiTexture.texture = sub.texture; element.blendGuiTexture.transform.localPosition = new Vector3(0,0,element.transform.localPosition.z+0.005f); element.blendGuiTexture.pixelInset = InstantGui.Invert(element.absolute.ToRect(InstantGui.scale)); if (borders!=null) element.blendGuiTexture.border = borders; element.blendGuiTexture.color = new Color(element.blendGuiTexture.color.r, element.blendGuiTexture.color.g, element.blendGuiTexture.color.b, blend*0.5f); if (element.mainGuiTexture!=null) element.mainGuiTexture.color = new Color(element.mainGuiTexture.color.r, element.mainGuiTexture.color.g, element.mainGuiTexture.color.b, (1-blend*blend)*0.5f); } if (element.guiTexts!=null && element.guiTexts.Length > 0) element.textMaterial.color = element.textMaterial.color*(1-blend) + sub.textColor*blend; }
public RectOffset pointOffset; // = new RectOffset(0,0,0,0); /* * public InstantGuiStyle() * { * main = new SubStyle(); * pointed = result.pointed.Clone(); * active = result.active.Clone(); * result.disabled = result.disabled.Clone(); * result.relative = result.relative.Clone(); * result.offset = result.offset.Clone(); * result.pointOffset = new RectOffset(result.pointOffset.left, result.pointOffset.right, result.pointOffset.top, result.pointOffset.bottom); * result.borders = new RectOffset(result.borders.left, result.borders.right, result.borders.top, result.borders.bottom); * return result; * } */ public void Apply(SubStyle sub, InstantGuiElement element) { //getting number of texts that should be in element int textsLength = 0; if (element.text.Length == 0) { textsLength = 0; } else { switch (textEffect) { case InstantGuiTextEffect.simple: textsLength = 1; break; case InstantGuiTextEffect.shadow: textsLength = 2; break; case InstantGuiTextEffect.stroke: textsLength = 5; break; } } //should a texture ot text be removed? bool removeTexture = false; bool removeTexts = false; if (!sub.enabled) { removeTexture = true; removeTexts = true; } if (!sub.texture) { removeTexture = true; } if (element.guiTexts.Length != textsLength) { removeTexts = true; //if text Length changed. No text included } if (font != element.currentFont) { removeTexts = true; //if font changed } for (int i = 0; i < element.guiTexts.Length; i++) { if (!element.guiTexts[i]) { removeTexts = true; //if any of guitexts array do not exists } } //removing if (removeTexture && element.mainGuiTexture != null) { GameObject.DestroyImmediate(element.mainGuiTexture.gameObject); } if (removeTexts) { for (int i = element.guiTexts.Length - 1; i >= 0; i--) { if (element.guiTexts[i] != null) { GameObject.DestroyImmediate(element.guiTexts[i].gameObject); } } //creating new array element.guiTexts = new GUIText[textsLength]; } if (!sub.enabled || (!sub.texture && element.text.Length == 0)) { return; } //setting texture if (sub.texture != null) { if (element.mainGuiTexture == null) { GameObject obj = new GameObject(element.transform.name + "_mainTexture"); obj.transform.parent = element.transform; obj.hideFlags = HideFlags.HideInHierarchy; element.mainGuiTexture = obj.AddComponent <GUITexture>(); } if (element.mainGuiTexture.texture != sub.texture) { element.mainGuiTexture.texture = sub.texture; } element.mainGuiTexture.transform.localPosition = new Vector3(0, 0, element.transform.localPosition.z); element.mainGuiTexture.pixelInset = InstantGui.Invert(element.absolute.ToRect(InstantGui.scale)); if (borders != null) { element.mainGuiTexture.border = borders; } } //proportional if (proportional && element.mainGuiTexture != null) { Rect newInset = element.mainGuiTexture.pixelInset; if (1.0f * element.mainGuiTexture.pixelInset.width / element.mainGuiTexture.pixelInset.height < proportionalAspect) { newInset.width = element.mainGuiTexture.pixelInset.height * proportionalAspect; newInset.x -= (newInset.width - element.mainGuiTexture.pixelInset.width) * 0.5f; } else { newInset.height = element.mainGuiTexture.pixelInset.width * (1.0f / proportionalAspect); newInset.y -= (newInset.height - element.mainGuiTexture.pixelInset.height) * 0.5f; } element.mainGuiTexture.pixelInset = newInset; } //setting text if (element.text.Length != 0) { //on font change - remove materials if (!font) { font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"); } if (font != element.currentFont) { //element.textMaterial=null; //if (element.guiTexts.Length > 1) element.textEffectMaterial=null; for (int i = 0; i < element.guiTexts.Length; i++) { if (element.guiTexts[i] != null) { GameObject.DestroyImmediate(element.guiTexts[i].gameObject); } } element.currentFont = font; } //creating texts for (int i = 0; i < element.guiTexts.Length; i++) { if (element.guiTexts[i] == null) { GameObject obj = new GameObject(element.transform.name + "_text" + i.ToString()); obj.transform.parent = element.transform; obj.hideFlags = HideFlags.HideInHierarchy; element.guiTexts[i] = obj.AddComponent <GUIText>(); //setting materials if (i == 0) { element.textMaterial = new Material(font.material); element.guiTexts[i].material = element.textMaterial; } else if (i > 0 && i == element.guiTexts.Length - 1) //on the last one effect text { element.textEffectMaterial = new Material(font.material); for (int j = 1; j < element.guiTexts.Length; j++) { element.guiTexts[j].material = element.textEffectMaterial; } } } } //setting text params for (int i = 0; i < element.guiTexts.Length; i++) { if (i == 0) { element.textMaterial.color = sub.textColor; } else { element.textEffectMaterial.color = textEffectColor; } element.guiTexts[i].transform.localPosition = new Vector3(0, 0, element.transform.localPosition.z + 0.01f - i * 0.001f); //setting text if (element.guiTexts[i].text != element.text && !element.password) { element.guiTexts[i].text = element.text; } else if (element.password) { element.guiTexts[i].text = ""; for (int j = 0; j < element.text.Length; j++) { element.guiTexts[i].text += "*"; } } if (element.guiTexts[i].font != font) { element.guiTexts[i].font = font; } if (element.guiTexts[i].fontSize != fontSize) { element.guiTexts[i].fontSize = fontSize; } Vector2 pixelOffset = element.absolute.GetCenter(); switch (textAligment) { case InstantGuiTextAligment.center: element.guiTexts[i].anchor = TextAnchor.MiddleCenter; break; case InstantGuiTextAligment.text: pixelOffset.y = element.absolute.top; pixelOffset.x = element.absolute.left; element.guiTexts[i].anchor = TextAnchor.UpperLeft; break; case InstantGuiTextAligment.heading: pixelOffset.y = element.absolute.top; element.guiTexts[i].anchor = TextAnchor.UpperCenter; break; case InstantGuiTextAligment.above: pixelOffset.y = element.absolute.top; element.guiTexts[i].anchor = TextAnchor.LowerCenter; break; case InstantGuiTextAligment.label: pixelOffset.x = element.absolute.left; element.guiTexts[i].anchor = TextAnchor.MiddleRight; break; case InstantGuiTextAligment.rightLabel: pixelOffset.x = element.absolute.right; element.guiTexts[i].anchor = TextAnchor.MiddleLeft; break; } pixelOffset += new Vector2(textOffsetX + sub.textOffsetX, textOffsetY + sub.textOffsetY); element.guiTexts[i].pixelOffset = InstantGui.Invert(pixelOffset); } //aligning text effect if (textEffect == InstantGuiTextEffect.shadow) { element.guiTexts[1].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(textEffectSize * 0.75f, -textEffectSize); } else if (textEffect == InstantGuiTextEffect.stroke) { element.guiTexts[1].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(textEffectSize, textEffectSize); element.guiTexts[2].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(-textEffectSize, textEffectSize); element.guiTexts[3].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(-textEffectSize, -textEffectSize); element.guiTexts[4].pixelOffset = element.guiTexts[0].pixelOffset + new Vector2(textEffectSize, -textEffectSize); } } }