/// <summary> /// Draws the help window with the specified parameters /// </summary> private void DrawHelpWindow(Texture helpImage, string helpText, ref Vector2 helpTextScrollbarPosition, ref AnimBool showHelpWindowVariable) { int currentIndent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); // the image VTextEditorGUIHelper.DrawBorderedImage(helpImage, HELP_IMAGE_WIDTH); float imgHeight = (float)helpImage.height / helpImage.width * HELP_IMAGE_WIDTH; float borderOffset = 6.0f; // there is a 3-pixel space to each side when put the image into a border (like we do) // the help text helpTextScrollbarPosition = GUILayout.BeginScrollView(helpTextScrollbarPosition, "box", GUILayout.Height(imgHeight + borderOffset)); EditorGUILayout.LabelField(helpText, VTextEditorGUIHelper.HelpTextStyle); GUILayout.EndScrollView(); // close button if (GUILayout.Button(new GUIContent("x", "Close help"), GUILayout.ExpandWidth(false))) { showHelpWindowVariable.target = false; } GUILayout.Space(5); // space 5 pixel GUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorGUI.indentLevel = currentIndent; }
/// <summary> /// draw the ui for this component /// /// returns true if this aspect of the VText should be updated (mesh, layout, physics, etc) /// </summary> public override bool DrawUI() { EditorGUIUtility.labelWidth = LABEL_WIDTH; bool updateAdditionalComponents = false; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("E X P E R I M E N T A L !!!!!"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); Object newObject = EditorGUILayout.ObjectField("Reference objects:", _referenceObjects.objectReferenceValue, typeof(GameObject), true); if (newObject != _referenceObjects.objectReferenceValue) { _referenceObjects.objectReferenceValue = newObject; updateAdditionalComponents = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showAdditionalComponentsInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showAdditionalComponentsInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Additional components:") + "\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowWarning("Be careful! This is experimental and can lead to Unity-Editor crashes!") + "\n\n" + "This allows you to add arbitrary components (like scripts) to each letter of your text. To do so you have to create a " + "<b>reference object</b> in your scene and add all components you want for your letters to this <b>reference</b> object. " + "Then you can fill out each exposed variable on this object to fit your needs. <b>It is absolutely fine to disable the reference object and all" + "of its components in the scene.</b> \n" + "Now you can drag and drop the <b>reference object</b> into the 'Reference objects' field. When your text is rebuilded it will copy " + "all components from your <b>reference object</b> and add them to each letter. Even the specified values of the components are copied. \n\n" + "Because some components are generated by VText or by Unity itself it is not possible to copy or replace all available components. The following " + "component types (or sub-types of them) will <b>NOT</b> be deleted, overwritten or added: \n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("- Transform") + "\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("- Renderer") + "\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("- Meshfilter") + "\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("- RigidBody") + "\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("- Collider") + "\n\n" + "We actually know that it will " + VTextEditorGUIHelper.ConvertStringToHelpWindowWarning("crash") + " if you add a VTextInterface or " + "a script which references a VTextInterface. Furthermor some of the Unity-internal components (like <b>AudioSource</b>) will throw errors " + "when we copy all available variables of that component because some of them are deprecated or completely out of order ... but still available " + "except the issue that Unity will throw errors if you use them. \n" + "We are working on these issues and maybe we can find solutions :)."; DrawHelpWindow(_additionalComponentsInfoHelpImage, txt, ref _additionalComponentsInfoHelpTextScrollPosition, ref _showAdditionalComponentsInfo); } EditorGUILayout.EndFadeGroup(); return(updateAdditionalComponents); }
/// <summary> /// Draws the circular bending parameters. /// </summary> public bool DrawCircularBendingParameters() { #region CIRCULAR BENDING EditorGUIUtility.labelWidth = CIRCULAR_BENDING_LABEL_WIDTH; bool updateLayout = false; GUILayout.BeginHorizontal(); bool isCircle = EditorGUILayout.Toggle(new GUIContent("Circular bending:", "Enable/Disable circular bending"), _isCircular.boolValue); if (isCircle != _isCircular.boolValue) { _isCircular.boolValue = isCircle; updateLayout = true; } if (_isCircular.boolValue != _showCircularBendingOptions.value) { _showCircularBendingOptions.target = _isCircular.boolValue; } VTextEditorGUIHelper.DrawHelpButton(ref _showCircularBendingInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showCircularBendingOptions.faded)) { EditorGUI.indentLevel++; GUILayout.BeginHorizontal(); float start = EditorGUILayout.FloatField(new GUIContent("Start angle:", "The start angle"), _startAngle.floatValue); if (start != _startAngle.floatValue) { _startAngle.floatValue = start; updateLayout = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); float end = EditorGUILayout.FloatField(new GUIContent("End angle:", "The end angle"), _endAngle.floatValue); if (end != _endAngle.floatValue) { _endAngle.floatValue = end; updateLayout = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); float radius = EditorGUILayout.FloatField(new GUIContent("Radius:", "The size of the circle"), _circleRadius.floatValue); if (radius != _circleRadius.floatValue) { _circleRadius.floatValue = radius; updateLayout = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); EditorGUILayout.EndHorizontal(); bool animR = EditorGUILayout.Toggle(new GUIContent("Animate radius:", "Change the radius along the text."), _animateRadius.boolValue); if (animR != _animateRadius.boolValue) { _animateRadius.boolValue = animR; updateLayout = true; } if (_animateRadius.boolValue != _showCircularBendingAnimateRadiusOptions.value) { _showCircularBendingAnimateRadiusOptions.target = _animateRadius.boolValue; } if (EditorGUILayout.BeginFadeGroup(_showCircularBendingAnimateRadiusOptions.faded)) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); AnimationCurve cR = _radiusCurve.animationCurveValue; AnimationCurve ncR = EditorGUILayout.CurveField("Radius curve:", cR, GUILayout.MinWidth(ANIMATION_CURVE_EDITOR_MIN_WIDTH)); if (!ncR.Equals(cR)) { _radiusCurve.animationCurveValue = ncR; updateLayout = true; } if (GUILayout.Button(new GUIContent(_resetIcon, "Reset curve"), GUILayout.Width(20), GUILayout.Height(VTextEditorGUIHelper.HELP_BUTTON_HEIGHT))) { _radiusCurve.animationCurveValue = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0)); updateLayout = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(_showCircularBendingInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Circular bending:") + "\n\n" + "This allows you to bend your text perfectly around a circle. The following parameters can be used to change the bending: \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Start angle: ") + "Use this parameter to define the position of the first " + "letter of your text on the circle. This is specified in degree. You can also use values larger than 360 or less then 0 if you want " + "to bend your text more than one time around the circle.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("End angle: ") + "This defines the position of the last letter of your text on the circle. " + "It is defined in degree and you can also use values larger than 360 or less then 0 if you want to bend your text more than one time " + "around the circle. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Radius: ") + "This defines the radius of the circle and therefor how far the letters are " + "away from the center of the circle (esp. the position of the VText object). \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Animate radius: ") + "This section allows you to change the <b>radius of the circle</b> along " + "the text. The <b>curves</b> x values should be between <b>0</b> and <b>1</b> where 0 means the beginning of the text and 1 its ending. \n" + "The <b>curves</b> y values are multiplied by the specified <b>radius</b> of the circle. \n" + "Use the <b>Reset</b> button to reset your curve to its default values which results in a fixed radius (defined by the <b>radius</b> parameter) " + "for the circle. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowWarning("Tip: ") + "This allows you to bend your text like a spiral for instance. Furthermore you can " + "combine it with the <b>curve bending in XY direction</b> to achieve a tornado-like effect for your text (set the <b>end angle</b> to a value larger " + "than 360 degree (and/or modify the <b>start angle</b> accordingly) to make the text bend a couple of times around the circle."; DrawHelpWindow(_circularBendingInfoHelpImage, txt, ref _circularBendingInfoHelpTextScrollPosition, ref _showCircularBendingInfo); } EditorGUILayout.EndFadeGroup(); return(updateLayout); #endregion // CIRCULAR BENDING }
/// <summary> /// Draws the bending parameters. /// </summary> public bool DrawBendingCurves() { EditorGUIUtility.labelWidth = CURVE_BENDING_LABEL_WIDTH; bool updateLayout = false; #region CURVE BENDING XZ EditorGUILayout.BeginHorizontal(); AnimationCurve cxz = _curveXZ.animationCurveValue; AnimationCurve ncxz = EditorGUILayout.CurveField(new GUIContent("Bend XZ:", "Bend the text around the Y-axis"), cxz, GUILayout.MinWidth(ANIMATION_CURVE_EDITOR_MIN_WIDTH)); if (!ncxz.Equals(cxz)) { _curveXZ.animationCurveValue = ncxz; updateLayout = true; } if (GUILayout.Button(new GUIContent("Align to curve", "Align letters to curve"), _orientXZ.boolValue ? VTextEditorGUIHelper.ToggleButtonStyleToggled : VTextEditorGUIHelper.ToggleButtonStyleNormal, GUILayout.Width(ALIGN_TO_CURVE_BUTTON_WIDTH))) { _orientXZ.boolValue = !_orientXZ.boolValue; updateLayout = true; } if (GUILayout.Button(new GUIContent(_resetIcon, "Reset curve"), GUILayout.Width(20), GUILayout.Height(VTextEditorGUIHelper.HELP_BUTTON_HEIGHT))) { _curveXZ.animationCurveValue = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0)); _orientXZ.boolValue = false; updateLayout = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showCurveBendingXZInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showCurveBendingXZInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Curve bending (in XZ direction):") + "\n\n" + "This bends your text according to the specified curve in xz direction. Your text will stay on the ground (more specific it will not " + "change the y-values of the letters. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Curve: ") + "The bending curve. The x-values of the <b>curve</b> should be between <b>0</b> " + "and <b>1</b> where 0 is the beginning of the text and 1 is the end of the text. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Align to curve: ") + "If you enable this option the letters of the text will be " + "rotated accordingly to the curves direction. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Reset: ") + "This will reset the <b>curve</b> to its original values with no bending at all and " + "sets the <b>Align to curve</b> parameter to false."; DrawHelpWindow(_curveBendingXZInfoHelpImage, txt, ref _curveBendingXZInfoHelpTextScrollPosition, ref _showCurveBendingXZInfo); } EditorGUILayout.EndFadeGroup(); #endregion // CURVE BENDING XZ #region CURVE BENDING XY EditorGUILayout.BeginHorizontal(); AnimationCurve cxy = _curveXY.animationCurveValue; AnimationCurve ncxy = EditorGUILayout.CurveField(new GUIContent("Bend XY:", "Bend the text around the Z-axis"), cxy, GUILayout.MinWidth(ANIMATION_CURVE_EDITOR_MIN_WIDTH)); if (!ncxy.Equals(cxy)) { _curveXY.animationCurveValue = ncxy; updateLayout = true; } if (GUILayout.Button(new GUIContent("Align to curve", "Align letters to curve"), _orientXY.boolValue ? VTextEditorGUIHelper.ToggleButtonStyleToggled : VTextEditorGUIHelper.ToggleButtonStyleNormal, GUILayout.Width(ALIGN_TO_CURVE_BUTTON_WIDTH))) { _orientXY.boolValue = !_orientXY.boolValue; updateLayout = true; } if (GUILayout.Button(new GUIContent(_resetIcon, "Reset curve"), GUILayout.Width(20), GUILayout.Height(VTextEditorGUIHelper.HELP_BUTTON_HEIGHT))) { _curveXY.animationCurveValue = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0)); _orientXY.boolValue = false; updateLayout = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showCurveBendingXYInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showCurveBendingXYInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Curve bending (in XY direction):") + "\n\n" + "This bends your text according to the specified curve in xy direction. The letters of your text will move up and down depending on the " + "specified curve. The z-position of the letters will stay the same. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Curve: ") + "The bending curve. The x-values of the <b>curve</b> should be between <b>0</b> " + "and <b>1</b> where 0 is the beginning of the text and 1 is the end of the text. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Align to curve: ") + "If you enable this option the letters of the text will be " + "rotated accordingly to the curves direction. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Reset: ") + "This will reset the <b>curve</b> to its original values with no bending at all and " + "sets the <b>Align to curve</b> parameter to false."; DrawHelpWindow(_curveBendingXYInfoHelpImage, txt, ref _curveBendingXYInfoHelpTextScrollPosition, ref _showCurveBendingXYInfo); } EditorGUILayout.EndFadeGroup(); #endregion // CURVE BENDING XY return(updateLayout); }
/// <summary> /// Draws the common parameters. /// </summary> /// <returns><c>true</c>, if common parameters was drawn, <c>false</c> otherwise.</returns> private bool DrawCommonParameters() { bool updateLayout = false; #region HORIZONTAL EditorGUIUtility.labelWidth = LABEL_WIDTH; GUILayout.BeginHorizontal(); bool nHorizontal = EditorGUILayout.Toggle(new GUIContent("Horizontal:", "Text direction (horizontal or vertical)"), _lHorizontal.boolValue); if (nHorizontal != _lHorizontal.boolValue) { _lHorizontal.boolValue = nHorizontal; updateLayout = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showHorizontalInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showHorizontalInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Horizontal:") + "\n\n" + "If this is set to true then the text is layouted horizontally. Otherwise the text is layouted vertically."; DrawHelpWindow(_horizontalInfoHelpImage, txt, ref _horizontalInfoHelpTextScrollPosition, ref _showHorizontalInfo); } EditorGUILayout.EndFadeGroup(); #endregion // HORIZONTAL #region MAJOR GUILayout.BeginHorizontal(); int nMajor = (int)(VTextLayout.align)EditorGUILayout.EnumPopup(new GUIContent("Major:", "Major layout mode"), (VTextLayout.align)System.Enum.GetValues(typeof(VTextLayout.align)).GetValue(_lMajor.enumValueIndex)); if (_lMajor.enumValueIndex != nMajor) { _lMajor.enumValueIndex = nMajor; updateLayout = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showMajorInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showMajorInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Major:") + "\n\n" + "This defines the alignment of the text. It is called <i>'Major'</i> because it depends on the general layout of your text " + "(see the <b>Horizontal</b> parameter). If it is layouted horizontally this parameter means the alignment in X-direction. " + "If the text is layouted vertically it means the alignment in Y-direction.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Base: ") + "This aligns the baseline of the text to the parent's transform. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Start: ") + "This aligns the position of the first letter of the text to the " + "parent's transform. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Center: ") + "The center of each line is aligned to its parent's transform. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("End: ") + "The end of each line is aligned to its parent's transform."; DrawHelpWindow(_majorInfoHelpImage, txt, ref _majorInfoHelpTextScrollPosition, ref _showMajorInfo); } EditorGUILayout.EndFadeGroup(); #endregion // MAJOR #region MINOR GUILayout.BeginHorizontal(); int nMinor = (int)(VTextLayout.align)EditorGUILayout.EnumPopup(new GUIContent("Minor:", "Minor layout mode"), (VTextLayout.align)System.Enum.GetValues(typeof(VTextLayout.align)).GetValue(_lMinor.enumValueIndex)); if (_lMinor.enumValueIndex != nMinor) { _lMinor.enumValueIndex = nMinor; updateLayout = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showMinorInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showMinorInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Minor:") + "\n\n" + "This defines the alignment of the text. It is called <i>'Minor'</i> because it depends on the general layout of your text " + "(see the <b>Horizontal</b> parameter). The alignment direction is the " + VTextEditorGUIHelper.ConvertStringToHelpWindowWarning("opposite") + " to the <i>'Major'</i> alignment. So if your text is layouted horizontally then this describes the alignment in y-direction. If your text is " + "layouted vertically then this parameter describes the alignment in x-direction\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Base: ") + "This aligns the baseline of the text to the parent's transform. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Start: ") + "This aligns the position of the first letter of the text to the " + "parent's transform. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Center: ") + "The center of each line is aligned to its parent's transform. \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("End: ") + "The end of each line is aligned to its parent's transform."; DrawHelpWindow(_minorInfoHelpImage, txt, ref _minorInfoHelpTextScrollPosition, ref _showMinorInfo); } EditorGUILayout.EndFadeGroup(); #endregion // MINOR #region LINE SPACE GUILayout.BeginHorizontal(); float nSpacing = EditorGUILayout.FloatField(new GUIContent("Line space:", "The space between two lines"), _lSpacing.floatValue); if (nSpacing != _lSpacing.floatValue) { _lSpacing.floatValue = nSpacing; updateLayout = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showLineSpaceInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showLineSpaceInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Line space:") + "\n\n" + "This parameter defines the distance of the <b>base line</b> of one line to the <b>base line</b> of the next line. \n" + "This means that a line space of 0 will put all lines on top of each other. In this way you can create overlapping texts too. \n" + "A value of 1 means the “<i>normal</i>” line space as they are defined by the font. A value of 2 for instance doubles the distance " + "between two lines."; DrawHelpWindow(_lineSpaceInfoHelpImage, txt, ref _lineSpaceInfoHelpTextScrollPosition, ref _showLineSpaceInfo); } EditorGUILayout.EndFadeGroup(); #endregion // LINE SPACE #region LETTER SPACE GUILayout.BeginHorizontal(); float nGlyphSpacing = EditorGUILayout.FloatField(new GUIContent("Letter space:", "The space between two letters"), _gSpacing.floatValue); if (nGlyphSpacing != _gSpacing.floatValue) { _gSpacing.floatValue = nGlyphSpacing; updateLayout = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showGlyphSpaceInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showGlyphSpaceInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Letter space:") + "\n\n" + "This parameter defines the additional distance between two letters of the text. \n" + "A letter space of 0 will generate the distance which is provided by the choosen font (most likely no extra space between letters)."; DrawHelpWindow(_glyphSpaceInfoHelpImage, txt, ref _glyphSpaceInfoHelpTextScrollPosition, ref _showGlyphSpaceInfo); } EditorGUILayout.EndFadeGroup(); #endregion // LETTER SPACE return(updateLayout); }
/// <summary> /// draw the ui for this component /// /// returns true if this aspect of the VText should be updated (mesh, layout, physics, etc) /// </summary> public override bool DrawUI() { bool updateMesh = false; EditorGUIUtility.labelWidth = LABEL_WIDTH; #region FONT EditorGUILayout.BeginHorizontal(); FillFonts(_vtextInterface.parameter.Fontname); int fc = EditorGUILayout.Popup("Font:", _currentFontIndex, _fontNames); if (fc != _currentFontIndex) { // Debug.Log("fontChoice " + fc); _currentFontIndex = fc; if (fc > 0) { _vtextInterface.parameter.Fontname = _fontNames[fc]; _pFontname.stringValue = _fontNames[fc]; } else { _vtextInterface.parameter.Fontname = string.Empty; _pFontname.stringValue = string.Empty; } updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showFontInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showFontInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Font:") + "\n\n" + "Here you can select the font which is used to generate the 3D Text.\n" + "You can simply add additional fonts (TrueType or OTF fonts) by copying it into the" + "<b><i>Assets/StreamingAssets/Fonts</i></b> folder.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowWarning("Be careful") + " when deleting or renaming fonts " + "in this folder. If the fonts you are deleting or renaming are in use then the corresponding VText objects set their " + "<b>Font</b> parameter to <i>'None'</i>. This will result in a not visible text the next time you rebuild the VText object (for " + "instance at the start of the game)."; DrawHelpWindow(_fontInfoHelpImage, txt, ref _fontInfoHelpTextScrollPosition, ref _showFontInfo); } EditorGUILayout.EndFadeGroup(); #endregion // FONT #region SIZE GUILayout.BeginHorizontal(); float nSize = EditorGUILayout.FloatField(new GUIContent("Size:", "The size of the text"), _lSize.floatValue); if (nSize != _lSize.floatValue) { _lSize.floatValue = nSize; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showSizeInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showSizeInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Size:") + "\n\n" + "This parameter defines the size of the generated text in meters."; DrawHelpWindow(_sizeInfoHelpImage, txt, ref _sizeInfoHelpTextScrollPosition, ref _showSizeInfo); } EditorGUILayout.EndFadeGroup(); #endregion // SIZE #region MATERIALS // face material GUILayout.BeginHorizontal(); Object faceMat = _style.GetArrayElementAtIndex(0).objectReferenceValue; Object nFaceMat = EditorGUILayout.ObjectField("Face material:", faceMat, typeof(Material), false); if (nFaceMat != faceMat) { _style.GetArrayElementAtIndex(0).objectReferenceValue = nFaceMat; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showFaceMaterialInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showFaceMaterialInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Face material:") + "\n\n" + "The material here is used for the front- and (if defined) backfaces of the generated 3D text."; DrawHelpWindow(_faceMaterialHelpImage, txt, ref _faceMaterialHelpTextScrollPosition, ref _showFaceMaterialInfo); } EditorGUILayout.EndFadeGroup(); // side material GUILayout.BeginHorizontal(); Object sideMat = _style.GetArrayElementAtIndex(1).objectReferenceValue; Object nSideMat = EditorGUILayout.ObjectField("Side material:", sideMat, typeof(Material), false); if (nSideMat != sideMat) { _style.GetArrayElementAtIndex(1).objectReferenceValue = nSideMat; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showSideMaterialInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showSideMaterialInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Side material:") + "\n\n" + "The material here is used for the sides of the generated 3D text if it has any <b>depth</b>. You can change the depth of the 3D text in the " + VTextEditorGUIHelper.ConvertStringToHelpWindowCategoryLink("Mesh") + " category."; DrawHelpWindow(_sideMaterialHelpImage, txt, ref _sideMaterialHelpTextScrollPosition, ref _showSideMaterialInfo); } EditorGUILayout.EndFadeGroup(); // bevel material GUILayout.BeginHorizontal(); Object currentBevelMaterial = _style.GetArrayElementAtIndex(2).objectReferenceValue; Object newBevelMaterial = EditorGUILayout.ObjectField("Bevel material:", currentBevelMaterial, typeof(Material), false); if (newBevelMaterial != currentBevelMaterial) { _style.GetArrayElementAtIndex(2).objectReferenceValue = newBevelMaterial; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showBevelMaterialInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showBevelMaterialInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Bevel material:") + "\n\n" + "The material here is used for the <b>bevel</b> of the generated 3D text. The bevel is the smoothly rounded part between the front/back-side of " + "the 3D-Text and its sides. You can change the size of the <b>bevel</b> in the " + VTextEditorGUIHelper.ConvertStringToHelpWindowCategoryLink("Mesh") + " category. It will only be available if the 3D-Text has a <b>depth</b>. You can change the <b>depth</b> of the 3D text " + "in the " + VTextEditorGUIHelper.ConvertStringToHelpWindowCategoryLink("Mesh") + " category too."; DrawHelpWindow(_bevelMaterialHelpImage, txt, ref _bevelMaterialHelpTextScrollPosition, ref _showBevelMaterialInfo); } EditorGUILayout.EndFadeGroup(); #endregion // MATERIALS return(updateMesh); }
/// <summary> /// draw the ui for this component /// /// returns true if this aspect of the VText should be updated (mesh, layout, physics, etc) /// </summary> public override bool DrawUI() { bool updateMesh = false; EditorGUIUtility.labelWidth = LABEL_WIDTH; #region DEPTH // depth GUILayout.BeginHorizontal(); float nDepth = EditorGUILayout.FloatField("Depth:", _pDepth.floatValue); if (nDepth < 0.0f) { nDepth = 0.0f; } if (nDepth != _pDepth.floatValue) { _pDepth.floatValue = nDepth; updateMesh = true; } if ((nDepth - Mathf.Epsilon) < 0.0f) { _pBevel.floatValue = 0.0f; } VTextEditorGUIHelper.DrawHelpButton(ref _showDepthInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showDepthInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Depth:") + "\n\n" + "The <b>depth</b> defines the amount of extrusion of the font. \n" + "Keep in mind that you can <b>bevel</b> your text only if a depth is set."; DrawHelpWindow(_depthHelpImage, txt, ref _depthInfoHelpTextScrollPosition, ref _showDepthInfo); } EditorGUILayout.EndFadeGroup(); #endregion // DEPTH #region BEVEL GUI.enabled = ((_pDepth.floatValue - Mathf.Epsilon) > 0.0f); GUILayout.BeginHorizontal(); float nBevel = Mathf.Clamp01(EditorGUILayout.FloatField("Bevel:", _pBevel.floatValue)); if (nBevel != _pBevel.floatValue) { _pBevel.floatValue = nBevel; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showBevelInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showBevelInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Bevel:") + "\n\n" + "The <b>bevel</b> is a smoothly rounded geometry between the front/back-faces of the text and it's side (see <b>depth</b>).\n" + "You can set the bevel <b><color=#cc2222>only</color></b> if a <b>depth</b> is set."; DrawHelpWindow(_bevelHelpImage, txt, ref _bevelInfoHelpTextScrollPosition, ref _showBevelInfo); } EditorGUILayout.EndFadeGroup(); GUI.enabled = true; #endregion // BEVEL #region BACKFACE GUILayout.BeginHorizontal(); bool nBackface = EditorGUILayout.Toggle("Backface:", _pBackface.boolValue); if (nBackface != _pBackface.boolValue) { _pBackface.boolValue = nBackface; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showBackfaceInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showBackfaceInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Backface:") + "\n\n" + "For performance reasons we normally do not create faces on the backside of the text " + "because most of the texts are only visible from the front (menus, scores, etc).\n" + "But in a couple of cases (for instance if you rotate your text) you want to see the backside too. " + "Here you can enable the backfaces. The corresponding <b>bevels</b> will be created too."; DrawHelpWindow(_backfaceHelpImage, txt, ref _backfaceInfoHelpTextScrollPosition, ref _showBackfaceInfo); } EditorGUILayout.EndFadeGroup(); #endregion // BACKFACE #region QUALITY GUILayout.BeginHorizontal(); int nQuality = EditorGUILayout.IntSlider("Quality:", _pQuality.intValue, 0, 100); if (nQuality != _pQuality.intValue) { _pQuality.intValue = nQuality; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showQualityInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showQualityInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Quality:") + "\n\n" + "With this parameter you can increase the number of triangles which are generated for this text.\n" + "The idea is simple ... the higher the quality the smoother the geometry but the worse the performance.\n" + "We already increase the number of triangles only for the curved parts of a letter.\n" + "So here is your parameter to find a tradeoff which fits your needs. To see the results its a good idea to change " + "the rendermode of the " + VTextEditorGUIHelper.ConvertStringToHelpWindowCategoryLink("Scene view") + " to <b>Wireframe</b> or <b>Shaded wireframe</b>."; DrawHelpWindow(_qualityHelpImage, txt, ref _qualityInfoHelpTextScrollPosition, ref _showQualityInfo); } EditorGUILayout.EndFadeGroup(); #endregion // QUALITY #region SHADOW CASTING MODE (UNITY 5 AND ABOVE) GUILayout.BeginHorizontal(); if (EditorGUILayout.PropertyField(_pShadowCast, new GUIContent("Cast shadows:"))) { updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showShadowCastInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showShadowCastInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Cast shadow modes:") + "\n\n" + "Here you can set the way how Unity renders shadows for the generated text. \n" + "The following modes are available:\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("OFF: ") + "No shadows are cast from this text.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("ON: ") + "Shadows are cast from this text.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("TwoSided: ") + "Shadows are cast from this text, treating it as two-sided. This way you can see the shadows also from inside a letter. " + "Normally you don't need this.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("ShadowsOnly: ") + "The text will cast shadows, but is invisible otherwise in the scene."; DrawHelpWindow(_shadowCastHelpImage, txt, ref _shadowCastInfoHelpTextScrollPosition, ref _showShadowCastInfo); } EditorGUILayout.EndFadeGroup(); #endregion // SHADOW CASTING MODE (UNITY 5 AND ABOVE) #region RECEIVE SHADOWS GUILayout.BeginHorizontal(); bool nReceiveShadows = EditorGUILayout.Toggle("Receive shadows:", _pReceiveShadows.boolValue); if (nReceiveShadows != _pReceiveShadows.boolValue) { _pReceiveShadows.boolValue = nReceiveShadows; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showReceiveShadowInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showReceiveShadowInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Receive shadows:") + "\n\n" + "Enable this if you want your text to receive shadows from other objects."; DrawHelpWindow(_receiveShadowHelpImage, txt, ref _receiveShadowInfoHelpTextScrollPosition, ref _showReceiveShadowInfo); } EditorGUILayout.EndFadeGroup(); #endregion // RECEIVE SHADOWS #region USE LIGHTPROBES GUILayout.BeginHorizontal(); bool nUseLightProbes = EditorGUILayout.Toggle("Use lightprobes:", _pUseLightProbes.boolValue); if (nUseLightProbes != _pUseLightProbes.boolValue) { _pUseLightProbes.boolValue = nUseLightProbes; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showUseLightProbesInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showUseLightProbesInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Use lightprobes:") + "\n\n" + "If you are using Unity's lightprobes and want them to affect the text then you should enable this parameter."; DrawHelpWindow(_useLightProbesHelpImage, txt, ref _useLightProbesInfoHelpTextScrollPosition, ref _showUseLightProbesInfo); } EditorGUILayout.EndFadeGroup(); #endregion // USE LIGHTPROBES #region TANGENTS GUILayout.BeginHorizontal(); bool nNeedTangents = EditorGUILayout.Toggle("Create tangents:", _pNeedTangents.boolValue); if (nNeedTangents != _pNeedTangents.boolValue) { _pNeedTangents.boolValue = nNeedTangents; updateMesh = true; } VTextEditorGUIHelper.DrawHelpButton(ref _showTangentsInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showTangentsInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Create tangents:") + "\n\n" + "Some shader (for instance normal map shaders) require tangents to work correctly. If you use such a shader for the text you should enable " + "this parameter."; DrawHelpWindow(_tangentsHelpImage, txt, ref _tangentsInfoHelpTextScrollPosition, ref _showTangentsInfo); } EditorGUILayout.EndFadeGroup(); #endregion // TANGENTS #if CREASE_OK float nCrease = EditorGUILayout.FloatField("Crease Angle", _pCrease.floatValue); if (nCrease != _pCrease.floatValue) { if (nCrease >= 0f) { if (nCrease < 90f) { _pCrease.floatValue = nCrease; updateMesh = true; } } } #endif return(updateMesh); }
/// <summary> /// Shows the collider editor. /// </summary> private bool ShowColliderEditor() { bool updatePhysics = false; EditorGUILayout.BeginHorizontal(); int colliderTypeID = (int)(VTextPhysics.ColliderType)EditorGUILayout.EnumPopup(new GUIContent("Collider type:", "The type of the collider added to each letter"), (VTextPhysics.ColliderType)System.Enum.GetValues(typeof(VTextPhysics.ColliderType)).GetValue(_colliderType.enumValueIndex)); if (_colliderType.enumValueIndex != colliderTypeID) { _colliderType.enumValueIndex = colliderTypeID; updatePhysics |= true; } if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex != VTextPhysics.ColliderType.None && _showCollider.value == false) { _showCollider.target = true; } else if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex == VTextPhysics.ColliderType.None && _showCollider.value == true) { _showCollider.target = false; } VTextEditorGUIHelper.DrawHelpButton(ref _showColliderInfo); EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showCollider.faded)) { EditorGUI.indentLevel++; if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex == VTextPhysics.ColliderType.Box) { updatePhysics |= ShowBoxColliderParameters(); } else if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex == VTextPhysics.ColliderType.Mesh) { updatePhysics |= ShowMeshColliderParameters(); } // physics material ... this will work for all colliders if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex != VTextPhysics.ColliderType.None) { GUILayout.BeginHorizontal(); PhysicMaterial colMat = EditorGUILayout.ObjectField("Physic material:", _colliderMaterial.objectReferenceValue, typeof(PhysicMaterial), false) as PhysicMaterial; if (colMat != _colliderMaterial.objectReferenceValue) { _colliderMaterial.objectReferenceValue = colMat; updatePhysics |= true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(_showColliderInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Collider:") + "\n\n" + "Here you can specify a collider for each letter of your text. Actually the following types are supported:\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("None: ") + "Don't add a collider at all.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Box: ") + "Add a box collider to each letter. You can specify the <b>IsTrigger</b> " + "property of it. A trigger doesn't register a collision with an incoming Rigidbody. Instead, it sends OnTriggerEnter, OnTriggerExit and " + "OnTriggerStay message when a rigidbody enters or exits the trigger volume.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Mesh: ") + "Add a mesh collider to each letter. Here you can specify if it is " + "<b>convex</b> or not. You can see convex mesh colliders as simplified colliders without holes or entrances. If (<b>and only if</b>) you " + "define the mesh collider to be convex then you can set its <b>IsTrigger</b> property as well. A trigger doesn't register a collision with " + "an incoming Rigidbody. Instead, it sends OnTriggerEnter, OnTriggerExit and OnTriggerStay message when a rigidbody enters or exits the " + "trigger volume. \n\n" + "If you have defined a collider you can also set the colliders <b>physics material</b> to change its physics behaviour."; DrawHelpWindow(_colliderInfoHelpImage, txt, ref _colliderInfoHelpTextScrollPosition, ref _showColliderInfo); } EditorGUILayout.EndFadeGroup(); return(updatePhysics); }
/// <summary> /// Shows the rigidbody editor. /// </summary> private bool ShowRigidbodyEditor() { EditorGUIUtility.labelWidth = LABEL_WIDTH; bool updatePhysics = false; GUILayout.BeginHorizontal(); bool useRigidBody = EditorGUILayout.Toggle(new GUIContent("RigidBody:", "Enable/Disable rigidbodies for letters"), _createRigidbody.boolValue); if (useRigidBody != _createRigidbody.boolValue) { _createRigidbody.boolValue = useRigidBody; updatePhysics = true; } if (_createRigidbody.boolValue != _showRigidBody.value) { _showRigidBody.target = _createRigidbody.boolValue; } VTextEditorGUIHelper.DrawHelpButton(ref _showRigidBodyInfo); GUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(_showRigidBody.faded)) { EditorGUI.indentLevel++; // mass GUILayout.BeginHorizontal(); float mass = EditorGUILayout.FloatField(new GUIContent("Mass:", "The mass of this rigidbody"), _rigidbodyMass.floatValue); if (mass != _rigidbodyMass.floatValue) { _rigidbodyMass.floatValue = mass; updatePhysics = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); // drag GUILayout.BeginHorizontal(); float drag = EditorGUILayout.FloatField(new GUIContent("Drag:", "The drag amount of this rigidbody"), _rigidbodyDrag.floatValue); if (drag != _rigidbodyDrag.floatValue) { _rigidbodyDrag.floatValue = drag; updatePhysics = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); // angular drag GUILayout.BeginHorizontal(); float angularDrag = EditorGUILayout.FloatField(new GUIContent("Angular drag:", "The angular drag amount of this rigidbody"), _rigidbodyAngularDrag.floatValue); if (angularDrag != _rigidbodyAngularDrag.floatValue) { _rigidbodyAngularDrag.floatValue = angularDrag; updatePhysics = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); // use gravity GUILayout.BeginHorizontal(); bool gravity = EditorGUILayout.Toggle(new GUIContent("Use gravity:", "Use gravity?"), _rigidbodyGravity.boolValue); if (gravity != _rigidbodyGravity.boolValue) { _rigidbodyGravity.boolValue = gravity; updatePhysics = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); // is kinematic GUILayout.BeginHorizontal(); bool isKinematic = EditorGUILayout.Toggle(new GUIContent("Is kinematic:", "Is this rigidbody kinematic?"), _rigidbodyIsKinematic.boolValue); if (isKinematic != _rigidbodyIsKinematic.boolValue) { _rigidbodyIsKinematic.boolValue = isKinematic; updatePhysics = true; } GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH); GUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(_showRigidBodyInfo.faded)) { string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("RigidBody:") + "\n\n" + "This allows you to automatically add rigidbodies to each letter of the text. You can apply the most common parameters of Unity's rigidbodies as " + "there are: \n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Mass: ") + "The mass of the rigidbody.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Drag: ") + "The drag amount of the rigidbody.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Angular drag: ") + "The angular drag amount of the rigidbody.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Use gravity: ") + "Determines if gravity should be applied to the letter.\n\n" + VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Is kinematic: ") + "Controls whether physics affects the rigidbody or not. " + "If this value is set to <b>true</b> then <b>no</b> physics are applied to the letter."; DrawHelpWindow(_rigidBodyInfoHelpImage, txt, ref _rigidBodyInfoHelpTextScrollPosition, ref _showRigidBodyInfo); } EditorGUILayout.EndFadeGroup(); return(updatePhysics); }