//============================================================================== /** * @brief Set TextClipping to GUIStyle and return it. * * @param style If null then create new GUIStyle. Otherwise return direct it. * @param clipping TextClipping * * @return Builded GUIStyle */ //============================================================================== public static GUIStyle Clipping(this GUIStyle style, TextClipping clipping = default(TextClipping)) { GUIStyle s = GetOrCreate(style); s.clipping = clipping; return(s); }
public override Object Perform(Object obj) { Debug.WriteLine("Adding text clipping"); bool isSemanticText = GetArgumentBoolean(SemanticOperationNamedArguments.SemanticText, false); Object contextObject = GetArgumentObject(SemanticOperationNamedArguments.Text); String context = (contextObject != null) ? contextObject.ToString() : null; // TODO use html context -- need methods to strip tags to set regular context from it. Object htmlContextObject = GetArgumentObject(SemanticOperationNamedArguments.HtmlContext); String htmlContext = (htmlContextObject != null) ? htmlContextObject.ToString() : null; if (context != null) { Document sourceDocument = ResolveSourceDocument(); //We will do something smarter here later when we have interest vectors. TextClipping textClipping = new TextClipping(sessionScope.MetaMetadataRepository.GetMMByName(DocumentParserTagNames.TextTag)); //textClipping.setText(createGist(context)); textClipping.Media.Text = new MetadataString(context); //textClipping.Context = new MetadataString(context); textClipping.SourceDoc = sourceDocument; sourceDocument.AddClipping(textClipping); } return(null); }
public static GUIStyle Clipping(this GUIStyle current, TextClipping clipping, bool asCopy = true) { if (asCopy) { current = new GUIStyle(current); } current.clipping = clipping; return(current); }
public static string ToUssString(TextClipping clipping) { switch (clipping) { case TextClipping.Clip: return("clip"); case TextClipping.Overflow: return("overflow"); } return(""); }
void Start() { hp = 5; score = 0; canetonValue = 10000; PlayerPrefs.SetInt("score", score); textLife = GameObject.Find("Vie chiffre").GetComponent <Text>(); textScore = GameObject.Find("Score chiffre").GetComponent <Text>(); textHighScore = GameObject.Find("HighScore chiffre").GetComponent <Text>(); UpdateUI(); }
private void Initialize(GUIContent content, GUIStyle backgroundStyle, Color color, FontStyle fontStyle = Defaults.Style, TextAnchor alignment = Defaults.Alignment, TextClipping clipping = Defaults.Clipping, bool wordWrap = Defaults.WordWrap, int fontSize = Defaults.FontSize) { this.content = content; this.backgroundStyle = new GUIStyle(backgroundStyle); this.color = color; this.fontStyle = fontStyle; this.fontSize = fontSize; this.alignment = alignment; this.clipping = clipping; this.wordWrap = wordWrap; }
protected TextNode(TextNode other) : base(other) { text = other.text; tooltip = other.tooltip; font = other.font; fontStyle = other.fontStyle; fontSize = other.fontSize; alignment = other.alignment; overflow = other.overflow; richText = other.richText; m_style = new GUIStyle(other.m_style); }
public override void Reset() { base.Reset(); text = string.Empty; tooltip = string.Empty; alignment = TextAnchor.MiddleLeft; font = null; fontSize = 10; richText = true; overflow = TextClipping.Clip; fontStyle = FontStyle.Normal; }
public OxLabel(string text, GUIStyle style, Color color, TextAnchor anchor, TextClipping clipping, string texture) : base(new Vector2(0, 0), new Vector2(0, 0), texture) { selectable = false; this.text = text; labelStyle = style; textColor = color; if (textColor == null) { textColor = Color.white; } textAnchor = anchor; textClipping = clipping; }
void OnGUI() { Rect r = new Rect(10, Screen.height - 35, 150, 25); GUILayout.BeginArea(r); GUILayout.Box("Local input is on"); GUILayout.EndArea(); if (showError) { float a = 1; float delta = Time.unscaledTime - errorTime; if (delta < 0.15f) { a = delta / 0.15f; } else if (delta > 2.7f) { a = (3f - delta) / 0.3f; } float heightRatio = 1f * Screen.height / 1080f; GUIStyle label = GUI.skin.label; int fs = label.fontSize; TextClipping clip = label.clipping; bool wrap = label.wordWrap; TextAnchor align = label.alignment; label.fontSize = (int)(heightRatio * 32); label.clipping = TextClipping.Overflow; label.wordWrap = false; label.alignment = TextAnchor.MiddleCenter; Vector2 size = new Vector2(100, 17.5f) * heightRatio; r = new Rect(Screen.width / 2 - size.x, 0.5f * Screen.height - size.y, size.x * 2, size.y * 2); GUI.color = new Color(0, 0, 0, a); GUI.Label(r, error); r.x--; r.y--; warningColor.a = a; GUI.color = warningColor; GUI.Label(r, error); label.fontSize = fs; label.clipping = clip; label.wordWrap = wrap; label.alignment = align; } }
public void DrawText(TextStylePainterParameters painterParams) { Rect layout = painterParams.layout; string text = painterParams.text; Font font = painterParams.font; int fontSize = painterParams.fontSize; FontStyle fontStyle = painterParams.fontStyle; Color fontColor = painterParams.fontColor; TextAnchor anchor = painterParams.anchor; bool wordWrap = painterParams.wordWrap; float wordWrapWidth = painterParams.wordWrapWidth; bool richText = painterParams.richText; TextClipping clipping = painterParams.clipping; this.DrawText_Internal(layout, text, font, fontSize, fontStyle, fontColor * this.m_OpacityColor, anchor, wordWrap, wordWrapWidth, richText, clipping); }
public void DrawText(TextStylePainterParameters painterParams) { Rect screenRect = painterParams.rect; string text = painterParams.text; Font font = painterParams.font; int fontSize = painterParams.fontSize; FontStyle fontStyle = painterParams.fontStyle; Color fontColor = painterParams.fontColor * UIElementsUtility.editorPlayModeTintColor; TextAnchor anchor = painterParams.anchor; bool wordWrap = painterParams.wordWrap; float wordWrapWidth = painterParams.wordWrapWidth; bool richText = painterParams.richText; TextClipping clipping = painterParams.clipping; DrawText(screenRect, text, font, fontSize, fontStyle, fontColor * m_OpacityColor, anchor, wordWrap, wordWrapWidth, richText, clipping); }
public static GUIStyle BuildStyle(bool wordWrap, bool bold, bool italic, TextAnchor alignment, Color textColor, bool useRichText, int fontSize, TextClipping clipping = TextClipping.Clip) { FontStyle fontStyle = FontStyle.Normal; if (bold && italic) { fontStyle = FontStyle.BoldAndItalic; } else if (bold) { fontStyle = FontStyle.Bold; } else if (italic) { fontStyle = FontStyle.Italic; } var defaultLabel = GUI.skin.label; if (textColor == default) { textColor = defaultLabel.normal.textColor; } var style = new GUIStyle(defaultLabel) { wordWrap = wordWrap, fontStyle = fontStyle, fontSize = fontSize, alignment = alignment, richText = useRichText, normal = { textColor = textColor }, clipping = clipping }; return(style); }
private extern static void INTERNAL_CALL_DrawText_Internal(StylePainter self, ref Rect screenRect, string text, Font font, int fontSize, FontStyle fontStyle, ref Color fontColor, TextAnchor anchor, bool wordWrap, float wordWrapWidth, bool richText, TextClipping textClipping);
internal void DrawText_Internal(Rect screenRect, string text, Font font, int fontSize, FontStyle fontStyle, Color fontColor, TextAnchor anchor, bool wordWrap, float wordWrapWidth, bool richText, TextClipping textClipping) { INTERNAL_CALL_DrawText_Internal(this, ref screenRect, text, font, fontSize, fontStyle, ref fontColor, anchor, wordWrap, wordWrapWidth, richText, textClipping); }
public static void Label(string label, bool wordWrap = true, bool bold = false, bool italic = false, TextAnchor alignment = TextAnchor.UpperLeft, Color textColor = default, bool useRichText = true, int fontSize = 0, TextClipping clipping = TextClipping.Clip, params GUILayoutOption[] options) { var style = BuildStyle(wordWrap, bold, italic, alignment, textColor, useRichText, fontSize, clipping); EditorGUILayout.LabelField(label, style, options); }
private static extern void DrawText_Injected(ref Rect screenRect, string text, Font font, int fontSize, FontStyle fontStyle, ref Color fontColor, TextAnchor anchor, bool wordWrap, float wordWrapWidth, bool richText, TextClipping textClipping);
public Config(string content, Color color, FontStyle fontStyle = Defaults.Style, TextAnchor alignment = Defaults.Alignment, TextClipping clipping = Defaults.Clipping, bool wordWrap = Defaults.WordWrap, int fontSize = Defaults.FontSize) { Initialize(new GUIContent(content), Defaults.BackgroundStyle, color, fontStyle, alignment, clipping, wordWrap, fontSize); }
public static GUIStyle GetGuiStyle ( GUI_Item_Type type, GUI_Color colorNormal = GUI_Color.White, GUI_Color colorHover = GUI_Color.White, GUI_Color colorActive = GUI_Color.White, TextAnchor align = TextAnchor.MiddleCenter, FontStyle fontStyle = FontStyle.Normal, bool wordWrap = false, TextClipping clipping = TextClipping.Overflow ) { if (!isInitStyles) { isInitStyles = SetGUIStyles(); } switch (type) { case GUI_Item_Type.TITLEBUTTON: TitleButton.normal.textColor = GetGuiColor(colorNormal); TitleButton.hover.textColor = GetGuiColor(colorHover); TitleButton.active.textColor = GetGuiColor(colorActive); TitleButton.fontStyle = fontStyle; TitleButton.alignment = align; TitleButton.wordWrap = wordWrap; TitleButton.clipping = clipping; return(TitleButton); case GUI_Item_Type.TITLETEXT: SimpleSkin.label.normal.textColor = GetGuiColor(colorNormal); SimpleSkin.label.fontStyle = fontStyle; SimpleSkin.label.alignment = align; SimpleSkin.label.wordWrap = wordWrap; SimpleSkin.label.clipping = clipping; return(SimpleSkin.label); case GUI_Item_Type.NORMALBUTTON: SimpleSkin.button.normal.textColor = GetGuiColor(colorNormal); SimpleSkin.button.hover.textColor = GetGuiColor(colorHover); SimpleSkin.button.active.textColor = GetGuiColor(colorActive); SimpleSkin.button.fontStyle = fontStyle; SimpleSkin.button.alignment = align; SimpleSkin.button.wordWrap = wordWrap; SimpleSkin.button.clipping = clipping; return(SimpleSkin.button); case GUI_Item_Type.TOGGLEBUTTON: ToggleButton.normal.textColor = GetGuiColor(colorNormal); ToggleButton.hover.textColor = GetGuiColor(colorHover); ToggleButton.active.textColor = GetGuiColor(colorActive); ToggleButton.fontStyle = fontStyle; ToggleButton.alignment = align; ToggleButton.wordWrap = wordWrap; ToggleButton.clipping = clipping; return(ToggleButton); case GUI_Item_Type.TAB: Tab.normal.textColor = GetGuiColor(colorNormal); Tab.hover.textColor = GetGuiColor(colorHover); Tab.active.textColor = GetGuiColor(colorActive); Tab.fontStyle = fontStyle; Tab.alignment = align; Tab.wordWrap = wordWrap; Tab.clipping = clipping; return(Tab); case GUI_Item_Type.LABEL: Label.normal.textColor = GetGuiColor(colorNormal); Label.fontStyle = fontStyle; Label.alignment = align; Label.wordWrap = wordWrap; Label.clipping = clipping; return(Label); case GUI_Item_Type.TEXTFIELD: TextField.normal.textColor = GetGuiColor(colorNormal); TextField.fontStyle = fontStyle; TextField.alignment = align; TextField.wordWrap = wordWrap; TextField.clipping = clipping; return(TextField); case GUI_Item_Type.TEXTAREA: TextArea.normal.textColor = GetGuiColor(colorNormal); TextArea.fontStyle = fontStyle; TextArea.alignment = align; TextArea.wordWrap = wordWrap; TextArea.clipping = clipping; return(TextArea); case GUI_Item_Type.TITLEBOX: return(TitleBox); case GUI_Item_Type.DROPDOWN: return(DropDown); } return(Label); }
protected override fsResult DoDeserialize(Dictionary <string, fsData> data, ref GUIStyle model) { fsResult result = fsResult.Success; GUIStyleState t0 = model.active; result += DeserializeMember(data, null, "active", out t0); model.active = t0; TextAnchor t2 = model.alignment; result += DeserializeMember(data, null, "alignment", out t2); model.alignment = t2; RectOffset t3 = model.border; result += DeserializeMember(data, null, "border", out t3); model.border = t3; TextClipping t4 = model.clipping; result += DeserializeMember(data, null, "clipping", out t4); model.clipping = t4; Vector2 t5 = model.contentOffset; result += DeserializeMember(data, null, "contentOffset", out t5); model.contentOffset = t5; float t6 = model.fixedHeight; result += DeserializeMember(data, null, "fixedHeight", out t6); model.fixedHeight = t6; float t7 = model.fixedWidth; result += DeserializeMember(data, null, "fixedWidth", out t7); model.fixedWidth = t7; GUIStyleState t8 = model.focused; result += DeserializeMember(data, null, "focused", out t8); model.focused = t8; Font t9 = model.font; result += DeserializeMember(data, null, "font", out t9); model.font = t9; int t10 = model.fontSize; result += DeserializeMember(data, null, "fontSize", out t10); model.fontSize = t10; FontStyle t11 = model.fontStyle; result += DeserializeMember(data, null, "fontStyle", out t11); model.fontStyle = t11; GUIStyleState t12 = model.hover; result += DeserializeMember(data, null, "hover", out t12); model.hover = t12; ImagePosition t13 = model.imagePosition; result += DeserializeMember(data, null, "imagePosition", out t13); model.imagePosition = t13; RectOffset t16 = model.margin; result += DeserializeMember(data, null, "margin", out t16); model.margin = t16; string t17 = model.name; result += DeserializeMember(data, null, "name", out t17); model.name = t17; GUIStyleState t18 = model.normal; result += DeserializeMember(data, null, "normal", out t18); model.normal = t18; GUIStyleState t19 = model.onActive; result += DeserializeMember(data, null, "onActive", out t19); model.onActive = t19; GUIStyleState t20 = model.onFocused; result += DeserializeMember(data, null, "onFocused", out t20); model.onFocused = t20; GUIStyleState t21 = model.onHover; result += DeserializeMember(data, null, "onHover", out t21); model.onHover = t21; GUIStyleState t22 = model.onNormal; result += DeserializeMember(data, null, "onNormal", out t22); model.onNormal = t22; RectOffset t23 = model.overflow; result += DeserializeMember(data, null, "overflow", out t23); model.overflow = t23; RectOffset t24 = model.padding; result += DeserializeMember(data, null, "padding", out t24); model.padding = t24; bool t25 = model.richText; result += DeserializeMember(data, null, "richText", out t25); model.richText = t25; bool t26 = model.stretchHeight; result += DeserializeMember(data, null, "stretchHeight", out t26); model.stretchHeight = t26; bool t27 = model.stretchWidth; result += DeserializeMember(data, null, "stretchWidth", out t27); model.stretchWidth = t27; bool t28 = model.wordWrap; result += DeserializeMember(data, null, "wordWrap", out t28); model.wordWrap = t28; return(result); }
public static GUIStyle EditedTextProperties(this GUIStyle style, TextAnchor textAnchor, TextClipping textClipping, bool richText, bool wordWrap) { style.alignment = textAnchor; style.clipping = textClipping; style.richText = richText; style.wordWrap = wordWrap; return(style); }
/* void FixedUpdate () * { * if ( resetFlag ) * { * ResetOrientation (); * resetFlag = false; * } * CheckSetPose (); * * rb.useGravity = UseGravity; * CheckConstraints (); * * if ( MotorsEnabled ) * { * if ( useTwist ) * { * // just set linear and angular velocities, ignoring forces * rb.velocity = LinearVelocity; * // rb.velocity = clampMaxSpeed ? Vector3.ClampMagnitude ( LinearVelocity, maxSpeedMS ) : LinearVelocity; * // new: flip angular velocity to generate CCW rotations * // Vector3 angVel = -AngularVelocity; * // if ( ConstrainTorqueX ) * // angVel.z = 0; * // if ( ConstrainTorqueY ) * // angVel.x = 0; * // if ( ConstrainTorqueZ ) * // angVel.y = 0; * // rb.angularVelocity = angVel; * rb.angularVelocity = -AngularVelocity; * * } else * { * * // add force * if ( clampForce ) * force = Vector3.ClampMagnitude ( force, maxForce ); * rb.AddRelativeForce ( force, forceMode ); * * // add torque. but first clamp it * if ( maxTorqueDegrees != 0 ) * maxTorqueRadians = maxTorqueDegrees * Mathf.Deg2Rad; * * if ( clampTorque ) * torque = Vector3.ClampMagnitude ( torque, maxTorqueRadians ); * // rb.AddRelativeTorque ( newTorque, torqueMode ); * rb.AddRelativeTorque ( -torque, torqueMode ); * * // update acceleration * LinearAcceleration = ( rb.velocity - lastVelocity ) / Time.deltaTime; * lastVelocity = rb.velocity; * LinearVelocity = rb.velocity; * // new: flip angular velocity to match flipped torque * // rb.angularVelocity = angVel; * // AngularVelocity = -angVel; * AngularVelocity = -rb.angularVelocity; * } * } * curSpeed = rb.velocity.magnitude; * }*/ void OnGUI() { string info = ""; Vector2 size; Rect r; GUIStyle label = GUI.skin.label; TextClipping clipping = label.clipping; label.clipping = TextClipping.Overflow; bool wrap = label.wordWrap; label.wordWrap = false; int fontSize = label.fontSize; label.fontSize = (int)(22f * Screen.height / 1080); if (showTelemetry) { info = @"Force: " + Force.ToRos().ToString() + "\nTorque: " + Torque.ToRos().ToString() + "\nPosition: " + Position.ToRos().ToString() + "\nRPY: " + (-Rotation.eulerAngles).ToRos().ToString() + "\nLinear Vel.: " + LinearVelocity.ToRos().ToString() + "\nAngular Vel.: " + AngularVelocity.ToRos().ToString() + "\nGravity " + (UseGravity ? "on" : "off") + "\nLocal input " + (inputCtrl.localInput ? "on" : "off"); if (ConstrainForceX) { info += "\nX Movement constrained"; } if (ConstrainForceY) { info += "\nY Movement constrained"; } if (ConstrainForceZ) { info += "\nZ Movement constrained"; } if (ConstrainTorqueX) { info += "\nX Rotation constrained"; } if (ConstrainTorqueY) { info += "\nY Rotation constrained"; } if (ConstrainTorqueZ) { info += "\nZ Rotation constrained"; } // GUIStyle label = GUI.skin.label; // TextClipping clipping = label.clipping; // label.clipping = TextClipping.Overflow; // bool wrap = label.wordWrap; // label.wordWrap = false; // int fontSize = label.fontSize; // label.fontSize = (int) ( 22f * Screen.height / 1080 ); size = label.CalcSize(new GUIContent(info)); r = new Rect(10, 10, size.x + 10, size.y); GUI.Box(r, ""); GUI.Box(r, ""); r.x += 5; GUILayout.BeginArea(r); GUILayout.Label(info); GUILayout.EndArea(); } // telemetry // show axis arrows if (drawArrows) { bool showMovement = ConstrainForceX || ConstrainForceY || ConstrainForceZ || drawArrowsAlways; bool showRotation = ConstrainTorqueX || ConstrainTorqueY || ConstrainTorqueZ || drawArrowsAlways; // x arrow Camera cam = Camera.main; float screenRatio = 1f * Screen.height / 1080; Vector2 texSize = new Vector2(48, 8) * screenRatio; Vector2 texSize2 = new Vector2(16, 16) * screenRatio; float arrowMag = texSize.magnitude + 14; Vector3 pos = transform.position; Vector2 screenPos = cam.WorldToScreenPoint(pos); screenPos.y = Screen.height - screenPos.y; Vector2 top = cam.WorldToScreenPoint(pos + Up * 0.5f); top.y = Screen.height - top.y; Vector2 tip = cam.WorldToScreenPoint(pos + XAxis * 0.75f); tip.y = Screen.height - tip.y; Vector2 toTip = (tip - screenPos).normalized; Rect texRect = new Rect(screenPos - texSize, texSize * 2); // Rect texRect2 = new Rect ( screenPos + ( top - screenPos ).normalized * arrowMag - texSize2, texSize2 * 2 ); Rect texRect2 = new Rect(screenPos + toTip * arrowMag - texSize2, texSize2 * 2); float angle = Vector2.Angle(Vector2.right, toTip); if (tip.y > screenPos.y) { angle = -angle; } GUIUtility.RotateAroundPivot(-angle, screenPos); GUI.color = axisColors [0]; if (showMovement && !ConstrainForceX) { GUI.DrawTexture(texRect, axisArrows [0]); } GUIUtility.RotateAroundPivot(angle, screenPos); if (showRotation && !ConstrainTorqueX) { GUI.DrawTexture(texRect2, axisArrows [1]); } // GUI.DrawTexture ( new Rect ( tip.x - 2, tip.y - 2, 4, 4 ), dot ); // y arrow tip = cam.WorldToScreenPoint(pos + YAxis * 0.75f); tip.y = Screen.height - tip.y; toTip = (tip - screenPos).normalized; angle = Vector2.Angle(Vector2.right, toTip); if (tip.y > screenPos.y) { angle = -angle; } GUIUtility.RotateAroundPivot(-angle, screenPos); GUI.color = axisColors [1]; if (showMovement && !ConstrainForceY) { GUI.DrawTexture(texRect, axisArrows [0]); } GUIUtility.RotateAroundPivot(angle, screenPos); texRect2.position = screenPos + toTip * arrowMag - texSize2; if (showRotation && !ConstrainTorqueY) { GUI.DrawTexture(texRect2, axisArrows [1]); } // GUI.DrawTexture ( new Rect ( tip.x - 2, tip.y - 2, 4, 4 ), dot ); // z arrow tip = cam.WorldToScreenPoint(pos + Up * 0.5f); tip.y = Screen.height - tip.y; toTip = (tip - screenPos).normalized; angle = Vector2.Angle(Vector2.right, toTip); if (tip.y > screenPos.y) { angle = -angle; } GUIUtility.RotateAroundPivot(-angle, screenPos); GUI.color = axisColors [2]; if (showMovement && !ConstrainForceZ) { GUI.DrawTexture(texRect, axisArrows [0]); } GUIUtility.RotateAroundPivot(angle, screenPos); texRect2.position = screenPos + toTip * arrowMag - texSize2; if (showRotation && !ConstrainTorqueZ) { GUI.DrawTexture(texRect2, axisArrows [1]); } // GUI.DrawTexture ( new Rect ( tip.x - 2, tip.y - 2, 4, 4 ), dot ); // GUI.color = Color.black; // GUI.DrawTexture ( new Rect ( screenPos.x - 2, screenPos.y - 2, 4, 4 ), dot ); } // axis arrows GUI.color = Color.white; // show controls legend if (showLegend) { info = @"F10: Legend on/off H: Control on/off WSAD/Arrows: Move around Space/C: Thrust up/down Q/E: Turn around G: Reset Quad orientation Scroll wheel: zoom in/out RMB (drag): Rotate camera RMB: Reset camera MMB: Toggle patrol/follow F5: Cycle quality settings /: Path display on/off Esc: Reload menu Ctrl-Q: Quit"; label.alignment = TextAnchor.MiddleLeft; size = label.CalcSize(new GUIContent(info)); r = new Rect(Screen.width - size.x - 20, 150, size.x + 10, size.y); GUI.Box(r, ""); GUI.Box(r, ""); r.x += 5; GUILayout.BeginArea(r); GUILayout.Label(info); GUILayout.EndArea(); } else { label.alignment = TextAnchor.MiddleLeft; info = "F10: Legend on/off"; size = label.CalcSize(new GUIContent(info)); r = new Rect(Screen.width - size.x - 20, 150, size.x + 10, size.y); GUI.Box(r, ""); GUI.Box(r, ""); r.x += 5; GUILayout.BeginArea(r); GUILayout.Label(info); GUILayout.EndArea(); } label.clipping = clipping; label.wordWrap = wrap; label.fontSize = fontSize; }
public void DrawText(Rect screenRect, string text, Font font, int fontSize, FontStyle fontStyle, Color fontColor, TextAnchor anchor, bool wordWrap, float wordWrapWidth, bool richText, TextClipping clipping) { this.DrawText_Internal(screenRect, text, font, fontSize, fontStyle, fontColor * this.m_OpacityColor, anchor, wordWrap, wordWrapWidth, richText, clipping); }
public static GUIStyle SetClipping(this GUIStyle self, TextClipping clipping) { self.clipping = clipping; return(self); }
internal static void DrawText(Rect screenRect, string text, Font font, int fontSize, FontStyle fontStyle, Color fontColor, TextAnchor anchor, bool wordWrap, float wordWrapWidth, bool richText, TextClipping textClipping) { ImmediateStylePainter.DrawText_Injected(ref screenRect, text, font, fontSize, fontStyle, ref fontColor, anchor, wordWrap, wordWrapWidth, richText, textClipping); }
public void DeSerializate(XmlElement root) { string _name = ""; DeSerializeField(root, "name", ref _name); style.name = _name; int _fontSize = 0; DeSerializeField(root, "fontSize", ref _fontSize); style.fontSize = _fontSize; FontStyle _fontStyle = FontStyle.Bold; DeSerializeField(root, "fontStyle", ref _fontStyle); style.fontStyle = _fontStyle; TextAnchor _alignment = TextAnchor.LowerCenter; DeSerializeField(root, "alignment", ref _alignment); style.alignment = _alignment; bool _wordWrap = false; DeSerializeField(root, "wordWrap", ref _wordWrap); style.wordWrap = _wordWrap; bool _richText = false; DeSerializeField(root, "richText", ref _richText); style.richText = _richText; TextClipping _clipping = TextClipping.Clip; DeSerializeField(root, "clipping", ref _clipping); style.clipping = _clipping; ImagePosition _imagePosition = ImagePosition.ImageAbove; DeSerializeField(root, "imagePosition", ref _imagePosition); style.imagePosition = _imagePosition; Vector2 _contentOffset = Vector2.zero; DeSerializeField(root, "contentOffset", ref _contentOffset); style.contentOffset = _contentOffset; float _fixedWidth = 0; DeSerializeField(root, "fixedWidth", ref _fixedWidth); style.fixedWidth = _fixedWidth; float _fixedHeight = 0; DeSerializeField(root, "fixedHeight", ref _fixedHeight); style.fixedHeight = _fixedHeight; bool _stretchWidth = false; DeSerializeField(root, "stretchWidth", ref _stretchWidth); style.stretchWidth = _stretchWidth; bool _stretchHeight = false; DeSerializeField(root, "stretchHeight", ref _stretchHeight); style.stretchHeight = _stretchHeight; XmlElement statesE = root.SelectSingleNode("GUIStyleStates") as XmlElement; states.Clear(); for (int i = 0; i < statesE.ChildNodes.Count; i++) { XmlElement stateE = statesE.ChildNodes[i] as XmlElement; GUIStyleStateSerializer d = default(GUIStyleStateSerializer); switch (stateE.Name) { case "normal": d = new GUIStyleStateSerializer(stateE.Name, style.normal); break; case "onNormal": d = new GUIStyleStateSerializer(stateE.Name, style.onNormal); break; case "hover": d = new GUIStyleStateSerializer(stateE.Name, style.hover); break; case "onHover": d = new GUIStyleStateSerializer(stateE.Name, style.onHover); break; case "onFocused": d = new GUIStyleStateSerializer(stateE.Name, style.onFocused); break; case "focused": d = new GUIStyleStateSerializer(stateE.Name, style.focused); break; case "active": d = new GUIStyleStateSerializer(stateE.Name, style.active); break; case "onActive": d = new GUIStyleStateSerializer(stateE.Name, style.onActive); break; } d.DeSerializate(stateE); states.Add(d); } XmlElement offsetsE = root.SelectSingleNode("RectOffsets") as XmlElement; offsets.Clear(); for (int i = 0; i < offsetsE.ChildNodes.Count; i++) { XmlElement stateE = offsetsE.ChildNodes[i] as XmlElement; RectOffsetSerializer d = default(RectOffsetSerializer); switch (stateE.Name) { case "margin": d = new RectOffsetSerializer(stateE.Name, style.margin); break; case "padding": d = new RectOffsetSerializer(stateE.Name, style.padding); break; case "overflow": d = new RectOffsetSerializer(stateE.Name, style.overflow); break; case "border": d = new RectOffsetSerializer(stateE.Name, style.border); break; } d.DeSerializate(stateE); offsets.Add(d); } }
public Config(GUIContent content, GUIStyle backgroundStyle, FontStyle fontStyle = Defaults.Style, TextAnchor alignment = Defaults.Alignment, TextClipping clipping = Defaults.Clipping, bool wordWrap = Defaults.WordWrap, int fontSize = Defaults.FontSize) { Initialize(content, backgroundStyle, Defaults.Color, fontStyle, alignment, clipping, wordWrap, fontSize); }
internal static extern void DrawText(Rect screenRect, string text, Font font, int fontSize, FontStyle fontStyle, Color fontColor, TextAnchor anchor, bool wordWrap, float wordWrapWidth, bool richText, TextClipping textClipping);
public void Draw(NodeEditor editor, bool showComments, bool selected, Vector2 drawOffset) { GUI.skin.box.alignment = TextAnchor.UpperCenter; const float nodeDrawWidth = 100; const float headerHeight = 18; const float nodeDrawHeightPerChannel = 21; //Figure out node width: Rect drawPos = Position; int inChannelNum = GetInputChannels().Count(); int outChannelNum = GetOutputChannels().Count(); if (inChannelNum > 0 && outChannelNum > 0) { drawPos.width = nodeDrawWidth * 1.36f; } else { drawPos.width = nodeDrawWidth; } int maxChannels = inChannelNum > outChannelNum ? inChannelNum : outChannelNum; drawPos.height = headerHeight + (maxChannels * nodeDrawHeightPerChannel); var windowName = new GUIContent(DisplayName); float minWidth; float maxWidth; //GUI.skin.window.CalcMinMaxWidth (windowName, out minWidth, out maxWidth); WindowStyle.CalcMinMaxWidth(windowName, out minWidth, out maxWidth); // Texel - Window style changes windowName.text = windowName.text.Trim("~"[0]); // Texel - Trim padding character drawPos.width = maxWidth > drawPos.width ? maxWidth : drawPos.width; Position = drawPos; var drawPosOffset = drawPos; drawPosOffset.x += drawOffset.x; drawPosOffset.y += drawOffset.y; float boxOffset = 0f; // For calculating the box vertical offset // This area is potentially shared by the comments, so comments would be drawn below errors. // Also made excessively large, to fail more elegantly. switch (CurrentState) { case (NodeState.Valid): GUI.color = Color.white; break; case (NodeState.NotConnected): GUI.color = new Color(0.8f, 0.8f, 1f); break; case (NodeState.CircularReferenceInGraph): GUI.color = new Color(0.8f, 0.8f, 0f); break; case (NodeState.Error): { GUI.color = Color.red; //GUILayout.BeginArea(new Rect(drawPos.x, drawPos.yMax, 300, 200)); foreach (var error in ErrorMessages) { var content = new GUIContent(error); float wMin, wMax; GUI.skin.box.CalcMinMaxWidth(content, out wMin, out wMax); var height = GUI.skin.box.CalcHeight(content, wMax); GUI.Box(new Rect(drawPosOffset.x, drawPosOffset.yMax + boxOffset, wMax, height), content); boxOffset += height; } break; } } GUI.backgroundColor = Color.gray; // Texel - Blend, rather then hard set if (selected) { GUI.backgroundColor = Color.Lerp(GUI.backgroundColor, Color.green, 0.5f); // Texel - Blend, rather then hard set } // Texel - Special case, for nodes which don't have any inputs if (maxChannels > 0) { GUI.Box(drawPosOffset, windowName, WindowStyle); } else { if (selected) { GUI.Box(drawPosOffset, GUIContent.none, WindowStyle); } GUIStyle empty = GUIStyle.none; empty.clipping = TextClipping.Overflow; GUI.Box(drawPosOffset, windowName, empty); } //Do custom layout to stop unity throwing errors for some strange reason // Texel - Seperated draw size from actual size, using blank style for real buttons // CandyFace - Left side IO var nodeIoSize = new Vector2(15f, nodeDrawHeightPerChannel * (2f / 3f)); var nodeIoDrawSize = new Vector2(15f, 15f); GUI.backgroundColor = Color.white; var currentDrawPosition = new Vector2(drawPosOffset.x, drawPosOffset.y); currentDrawPosition.y += headerHeight; TextAnchor oldTextAnchor = GUI.skin.label.alignment; TextClipping oldTextClipping = GUI.skin.label.clipping; bool oldWordWrap = GUI.skin.label.wordWrap; GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.skin.label.clipping = TextClipping.Overflow; GUI.skin.label.wordWrap = false; foreach (var channel in GetOutputChannels()) { var absoluteIOVisualPos = new Rect( currentDrawPosition.x - (nodeIoDrawSize.x * 0.950f), currentDrawPosition.y - 8 + nodeIoDrawSize.y / 2 + 2, nodeIoDrawSize.x, nodeIoDrawSize.y); var absoluteIODrawPos = new Rect( currentDrawPosition.x - (nodeIoSize.x * 1.10f), currentDrawPosition.y, nodeIoSize.x + 2, nodeIoSize.y + 5); GUI.Box(absoluteIOVisualPos, "", GUI.skin.box); if (GUI.Button(absoluteIODrawPos, "", GUIStyle.none)) { editor.SelectedOutputChannel = new OutputChannelReference(UniqueNodeIdentifier, channel.ChannelId); } var relativeIODrawPos = absoluteIODrawPos; relativeIODrawPos.x -= drawPosOffset.x; relativeIODrawPos.y -= drawPosOffset.y; channel.Position = relativeIODrawPos; var labelDrawPos = new Rect(currentDrawPosition.x + (nodeIoSize.x * 0.5f), currentDrawPosition.y, drawPosOffset.width / 2f, nodeDrawHeightPerChannel); GUI.Label(labelDrawPos, channel.DisplayName); currentDrawPosition.y += nodeDrawHeightPerChannel; } //Right side graph IO currentDrawPosition = new Vector2(drawPosOffset.x + (drawPosOffset.width / 2f), drawPosOffset.y); currentDrawPosition.y += headerHeight; GUI.skin.label.alignment = TextAnchor.UpperRight; GUI.skin.label.clipping = TextClipping.Overflow; GUI.skin.label.wordWrap = false; foreach (var channel in GetInputChannels()) { var absoluteIOVisualPos = new Rect( drawPosOffset.xMax - (nodeIoSize.x * 0.2f) + 3, currentDrawPosition.y - 8 + nodeIoDrawSize.y / 2 + 2, nodeIoDrawSize.x, nodeIoDrawSize.y); var absoluteIODrawPos = new Rect( drawPosOffset.xMax - (nodeIoSize.x * 0.050f), currentDrawPosition.y, nodeIoSize.x + 4, nodeIoSize.y + 6); GUI.Box(absoluteIOVisualPos, "", GUI.skin.box); if (GUI.Button(absoluteIODrawPos, "", GUIStyle.none)) { editor.SelectedInputChannel = new InputChannelReference(UniqueNodeIdentifier, channel.ChannelId); } var relativeIODrawPos = absoluteIODrawPos; relativeIODrawPos.x -= drawPosOffset.x; relativeIODrawPos.y -= drawPosOffset.y; channel.Position = relativeIODrawPos; var labelDrawPos = new Rect(currentDrawPosition.x, currentDrawPosition.y, (drawPosOffset.width / 2f) - (nodeIoSize.x * 0.5f), nodeDrawHeightPerChannel); GUI.Label(labelDrawPos, channel.DisplayName); currentDrawPosition.y += nodeDrawHeightPerChannel; } GUI.color = Color.white; GUI.skin.label.alignment = oldTextAnchor; GUI.skin.label.clipping = oldTextClipping; GUI.skin.label.wordWrap = oldWordWrap; //TODO: Preview shader at node //GUI.Box(new Rect(currentDrawPosition.x-50, currentDrawPosition.y, nodeDrawWidth,100), "", GUI.skin.box); if (showComments && Comment != "") { // Texel - Comment Field var oldColor = GUI.color; GUI.color = Vector4.Scale(GUI.color, new Vector4(0.95f, 0.95f, 0.95f, 0.7f)); var oldAnchor = GUI.skin.box.alignment; GUI.skin.box.alignment = TextAnchor.UpperLeft; var oldState = GUI.skin.box.normal; // Draw the text GUI.skin.box.normal.textColor = Color.white; //var oldWrap = GUI.skin.box.wordWrap; GUI.skin.box.wordWrap = true; var content = new GUIContent(Comment); float wMin, wMax; GUI.skin.box.CalcMinMaxWidth(content, out wMin, out wMax); var aWidth = Mathf.Min(drawPosOffset.width * 1.5f, wMax); var height = GUI.skin.box.CalcHeight(content, aWidth); GUI.Box(new Rect(drawPosOffset.x, drawPosOffset.yMax + boxOffset, aWidth, height), content); GUI.skin.box.alignment = oldAnchor; GUI.skin.box.normal = oldState; GUI.skin.box.normal.textColor = Color.white; GUI.color = oldColor; } GUI.backgroundColor = Color.white; }