// Vector3 bp; // Use this for initialization void Start() { tmb = GameObject.Find("/Text B").GetComponent <TTFText>(); tmh = GameObject.Find("/TTF Hello").GetComponent <TTFText>(); tm = tmb; // bp=tm.transform.position; }
public void ComputePositions() { TTFSubtext subtext = GetComponent <TTFSubtext>(); if (!transform.parent) { return; } TTFText tt = transform.parent.GetComponent <TTFText>(); if (tt == null) { return; } if (subtext == null) { return; } if (subtext.Layout == null) { Debug.LogWarning("No layout info"); return; } float x = subtext.Layout.CharSumAdvance(0) / tt.advance.magnitude; transform.localPosition = pTween(x); transform.localScale = Vector3.one * scalingCurve.Evaluate(x); if (orientAccordingPath) { transform.localRotation = Quaternion.FromToRotation(Vector3.right, oTween(x)); } transform.localRotation = Quaternion.Euler(YZRotationCurve.Evaluate(x) * 180, 0, 0) * transform.localRotation; }
// // Draw cross hair cursor with axis labels // private void crossHair(XYChart c, int mouseX, int mouseY) { // Clear the current dynamic layer and get the DrawArea object to draw on it. DrawArea d = c.initDynamicLayer(); // The plot area object PlotArea plotArea = c.getPlotArea(); // Draw a vertical line and a horizontal line as the cross hair d.vline(plotArea.getTopY(), plotArea.getBottomY(), mouseX, d.dashLineColor(0x000000, 0x0101)); d.hline(plotArea.getLeftX(), plotArea.getRightX(), mouseY, d.dashLineColor(0x000000, 0x0101)); // Draw y-axis label string label = "<*block,bgColor=FFFFDD,margin=3,edgeColor=000000*>" + c.formatValue(c.getYValue( mouseY, c.yAxis()), "{value|P4}") + "<*/*>"; TTFText t = d.text(label, "Arial Bold", 8); t.draw(plotArea.getLeftX() - 5, mouseY, 0x000000, Chart.Right); // Draw x-axis label label = "<*block,bgColor=FFFFDD,margin=3,edgeColor=000000*>" + c.formatValue(c.getXValue(mouseX), "{value|P4}") + "<*/*>"; t = d.text(label, "Arial Bold", 8); t.draw(mouseX, plotArea.getBottomY() + 5, 0x000000, Chart.Top); }
/* * public string extrachar=System.Text.UTF32Encoding.UTF32.GetString( * System.Text.UTF8Encoding.UTF8.GetBytes( * "基本的に découvrir sur elle-même une vision inaccessible" * ) * ); */ // Use this for initialization void Start() { textobject = new GameObject(); textobject.AddComponent <MeshFilter>(); textobject.AddComponent <MeshRenderer>(); textobject.AddComponent <TTFText>(); textobject.renderer.material = new Material(Shader.Find("Diffuse")); textobject.renderer.material.color = Color.red; text = textobject.GetComponent <TTFText>(); text.TokenMode = TTFText.TokenModeEnum.Character; //#if UNITY_ANDROID text.SetPreferedEngine(RuntimePlatform.Android, 2); // text.SetPreferedEngine(RuntimePlatform.Android,3); //#endif stime = Time.time; switchmodes = new SwitchModeD [] { Mode0, Mode1, Mode2, Mode3, Mode4, Mode5 #if UNITY_ANDROID || UNITY_IPHONE , Mode6 #endif }; switchmodes[0](); }
float Xmin0 = 0; // leftmost boundary for the first glyph of this line #endregion Fields #region Constructors public LineLayout(string l, TTFText atm, bool initialize) { offset = 0; linetext = ""; hspacing = atm.Hspacing; tm = atm; linewidth = tm.CurrentTextStyle.LineWidth; advancedir = Vector3.right; charadvances = new float[default_alloc]; // for each character this is the ideal advance charpositions = new float[default_alloc]; // we shall allow user to set up each character individually charheights = new float[default_alloc]; charstyleindex = new int[default_alloc]; charmetadata = new object[default_alloc]; for (int j=0; j<default_alloc; j++) { charstyleindex [j] = -1; } advancelen = 0; lineno = 0; align = tm.CurrentTextStyle.ParagraphAlignment; AppendText (l); //ComputeMetricInfo(); if (initialize) { ComputeCharacterPositions (); } }
public LineLayout(string l, TTFText atm, bool initialize) { offset = 0; linetext = ""; hspacing = atm.Hspacing; tm = atm; linewidth = tm.CurrentTextStyle.LineWidth; advancedir = Vector3.right; charadvances = new float[default_alloc]; // for each character this is the ideal advance charpositions = new float[default_alloc]; // we shall allow user to set up each character individually charheights = new float[default_alloc]; charstyleindex = new int[default_alloc]; charmetadata = new object[default_alloc]; for (int j = 0; j < default_alloc; j++) { charstyleindex [j] = -1; } advancelen = 0; lineno = 0; align = tm.CurrentTextStyle.ParagraphAlignment; AppendText(l); //ComputeMetricInfo(); if (initialize) { ComputeCharacterPositions(); } }
void Update() { TTFText dtm = GetComponent <TTFText>(); string txt = dtm.Text; foreach (char c in Input.inputString) { if (c == '\b') { if (txt.Length != 0) { txt = txt.Substring(0, txt.Length - 1); } } else if (c == '\n' || c == '\r') { // do something interesting here ... txt = ""; } else { txt += c; } } if (txt != dtm.Text) { dtm.Text = txt; } }
public void RegisterClient(TTFText tm) { if (!Clients.Contains(tm)) { Clients.Add(tm); } //EnsureFont(tm.FontId); }
// Use this for initialization void Start() { tt=GetComponent<TTFText>(); embold=tt.Embold; slant=tt.Slant; size=tt.Size; extrusionDepth=tt.ExtrusionDepth; }
// Use this for initialization void Start() { tt = GetComponent <TTFText>(); embold = tt.Embold; slant = tt.Slant; size = tt.Size; extrusionDepth = tt.ExtrusionDepth; }
// draw track line with data labels private void trackLineLabel(XYChart c, int mouseX) { DrawArea d = c.initDynamicLayer(); PlotArea plotArea = c.getPlotArea(); double xValue = c.getNearestXValue(mouseX); int xCoor = c.getXCoor(xValue); d.vline(plotArea.getTopY(), plotArea.getBottomY(), xCoor, d.dashLineColor(0x000000, 0x0101)); // container to hold the legned entries ArrayList legendEntries = new ArrayList(); for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); int xIndex = layer.getXIndexOf(xValue); // iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // we are only interested in visibale sets with names string dataName = dataSet.getDataName(); int color = dataSet.getDataColor(); if ((!string.IsNullOrEmpty(dataName)) && (color != Chart.Transparent)) { // Build the legend entry, consist of the legend icon, name and data value. double dataValue = dataSet.getValue(xIndex); legendEntries.Add("<*block*>" + dataSet.getLegendIcon() + " " + dataName + ": " + (( dataValue == Chart.NoValue) ? "N/A" : c.formatValue(dataValue, "{value|P4}")) + "<*/*>"); // Draw a track dot for data points within the plot area int yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis()); if ((yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY())) { d.circle(xCoor, yCoor, 4, 4, color, color); } } } } // Create the legend by joining the legend entries legendEntries.Reverse(); string legendText = "<*block,maxWidth=" + plotArea.getWidth() + "*><*block*><*font=Arial Bold*>[" + c.xAxis().getFormattedLabel(xValue, "{value|P4") + "]<*/*> " + String.Join( " ", (string[])legendEntries.ToArray(typeof(string))) + "<*/*>"; // Display the legend on the top of the plot area TTFText t = d.text(legendText, "Arial", 8); t.draw(plotArea.getLeftX() + 5, plotArea.getTopY() - 3, 0x000000, Chart.BottomLeft); }
public TTFTextStyle PushF(string name, bool createstyle, ref bool notfound) { GameObject go = (GameObject)GameObject.Find("/TTFText Styles/" + name); if (go == null) { Object o = Resources.Load("/TTFText/Styles/" + name + ".prefab"); if (o != null) { GameObject ngo = (GameObject)o; ngo.name = name; ngo.transform.parent = GameObject.Find("/TTFText Styles").transform; go = ngo; } if (go == null) { if (createstyle) { GameObject gop = (GameObject)GameObject.Find("/TTFText Styles"); if (gop == null) { gop = new GameObject(); gop.name = "TTFText Styles"; } go = new GameObject(); go.transform.parent = gop.transform; go.name = name; go.AddComponent <TTFText> (); TTFText tm = go.GetComponent <TTFText> (); go.AddComponent <MeshRenderer> (); go.AddComponent <TTFTextExtra_SetMaterialColor> (); tm.Text = ""; tm.IsStyleObject = true; tm.updateObjectName = false; //tm.InitTextStyle=(TTFTextStyle)ScriptableObject.Instantiate(this); tm.InitTextStyle = new TTFTextStyle(this); tm.InitTextStyle.materialSource = go; tm.InitTextStyle.ResetStyle(); } else { notfound = true; return(new TTFTextStyle(this)); } } } //TTFTextStyle tp=(TTFTextStyle)ScriptableObject.Instantiate(go.GetComponent<TTFText>().InitTextStyle); TTFTextStyle tp = new TTFTextStyle(go.GetComponent <TTFText> ().InitTextStyle); tp.stackparent = this; //tp.renewid(); return(tp); }
public void Rebuild() { Vector3 advance = Vector3.zero; Mesh m; MeshFilter mf = GetComponent <MeshFilter>(); m = mf.sharedMesh; TTFText tm = transform.parent.GetComponent <TTFText>(); TTFTextInternal.Engine.BuildMesh(ref m, Layout, tm, out advance); mf.sharedMesh = m; }
// TTFText Markup works as follow // <@Size=3@> to set size to 3 // <@Size=3|Embold=*2@> to set size to 3, and multiply the embold by 2 // <@Style=name_of_the style@> // <@pop@> to return at the previous style // <@#Image(2,1,"texturename")@> // <@#L.AddImage(2,1,"texturename")@> #region MAIN_FUNCTION /// <summary> /// This is the main functon that is used to generate any text mesh /// </summary> /// <param name='tm'> /// The textmesh object to be updated /// </param> /// /// /// /// public static void BuildText (TTFText tm) { ResetTextMesh (tm); tm.ResetUsedStyles (); tm.CurrentTextStyle = tm.InitTextStyle; if (tm.TokenMode != TTFText.TokenModeEnum.Text) { BuildTextModeSubobjects (tm); } else { BuildTextModeText (tm); } }
// Use this for initialization void Start() { tmb = GameObject.Find("/Text B").GetComponent <TTFText>(); tmj = GameObject.Find("/Text J").GetComponent <TTFText>(); tmlc = GameObject.Find("/Text LC").GetComponent <TTFText>(); tmlcdp = GameObject.Find("/Text LCDP").GetComponent <TTFText>(); tm = tmj; bp = tm.transform.position; tmb.transform.position = bp + Vector3.forward * 100; tmlc.transform.position = bp + Vector3.forward * 100; tmlcdp.transform.position = bp + Vector3.forward * 100; }
// public void UpdateClient(TTFText tm) { // may be used to update the necessary charmap of // a font on the fly TTFTextFontStoreFont x = GetFont(tm.FontId); x.AddRequiredCharacters(x.additionalChar); if (x.needRebuild) { x.BuildCharSet(tm.FontId); } Debug.LogWarning("Not yet implemented"); }
// Use this for initialization void Start() { tmb = GameObject.Find("/Text B").GetComponent <TTFText>(); tmj = GameObject.Find("/Text J").GetComponent <TTFText>(); tmlc = GameObject.Find("/Text LC").GetComponent <TTFText>(); tm = tmj; bp = tm.transform.position; tmb.transform.position = bp + Vector3.forward * 100; tmlc.transform.position = bp + Vector3.forward * 100; foreach (Transform t in tm.transform) { t.renderer.enabled = showMeshes; } }
public static IEnumerable BuildTextASync (TTFText tm) { ResetTextMesh (tm); tm.ResetUsedStyles (); tm.CurrentTextStyle = tm.InitTextStyle; if (tm.TokenMode != TTFText.TokenModeEnum.Text) { foreach (object o in BuildTextModeSubobjectsAsync (tm)) { yield return o; } } else { foreach (object o in BuildTextModeTextAsync (tm)) { yield return o; } } }
// Update is called once per frame void Update() { if (Random.Range(0, 1f / frequency) < Time.deltaTime) { GameObject go = new GameObject(); go.AddComponent <MeshRenderer>(); go.AddComponent <MeshFilter>(); go.AddComponent <scene2_particle_autodestroy>(); go.AddComponent <Rigidbody>(); go.AddComponent <TTFText>(); TTFText tm = go.GetComponent <TTFText>(); do { tm.ExtrusionMode = (TTFText.ExtrusionModeEnum)Random.Range(0, 6); } while (tm.ExtrusionMode == TTFText.ExtrusionModeEnum.FreeHand); tm.ExtrusionDepth = Random.Range(0.1f, 1f); tm.NbDiv = Random.Range(2, 8); tm.BevelForce = Random.Range(0.2f, 0.5f); tm.Gamma = Random.Range(0f, 7f); tm.BevelDepth = Random.Range(0f, 1f); tm.Text = words[Random.Range(0, words.Length)]; tm.Size = Random.Range(0.1f, 1.2f); go.rigidbody.velocity = Vector3.back * Random.Range(minspeed, minspeed + speedinterval); go.rigidbody.angularVelocity = new Vector3(Random.Range(-aspeed, aspeed), Random.Range(-aspeed, aspeed), Random.Range(-aspeed, aspeed)); go.rigidbody.useGravity = false; go.transform.position = new Vector3(Random.Range(-2f, 2f), Random.Range(-2f, 2f), 5); go.transform.parent = transform; go.renderer.material = materials[Random.Range(0, materials.Length)]; //tm.runtimeFontPath=FontListManager.Instance.SystemFonts[fonts[Random.Range(0,fonts.Count)]].Path; tm.FontId = fonts[Random.Range(0, fonts.Count)]; } if (Random.Range(0, 1f / flareFrequency) < Time.deltaTime) { GameObject go = new GameObject(); go.AddComponent <LensFlare>(); go.AddComponent <Rigidbody>(); go.rigidbody.velocity = Vector3.back * Random.Range(minspeed + speedinterval, minspeed + 2 * speedinterval); go.rigidbody.useGravity = false; go.transform.position = new Vector3(Random.Range(-2f, 2f), Random.Range(-2f, 2f), 5); go.transform.parent = transform; LensFlare lf = go.GetComponent <LensFlare>(); lf.color = new Color(Random.Range(0.5f, 1f), Random.Range(0.5f, 1f), Random.Range(0.5f, 1f)); lf.flare = flares[Random.Range(0, flares.Length)]; lf.brightness = Random.Range(0f, 1f); } }
public static void BuildTextModeSubobjects (TTFText tm) { #if TTFTEXT_LITE if (tm.DemoMode) { #endif // CASE 1 : WE GENERATE DIFFERENT GAME OBJECTS FOR EACH TOKEN Bounds bounds = new Bounds (Vector3.zero, Vector3.zero); //BuildTextModeSubobjectsP1(tm,ref bounds); foreach (object o in BuildTextModeSubobjectsP1(tm)) { TTFTextInternal.Utilities.MergeBounds (ref bounds, (Bounds)o); } BuildTextModeSubobjectsP2 (tm, ref bounds); #if TTFTEXT_LITE } #endif }
public void UnregisterClient(TTFText tm) { while (Clients.Contains(tm)) { Clients.Remove(tm); } if (Clients.Count == 0 && destroyWhenUnused) { if ((Application.isEditor) && (!Application.isPlaying)) { GameObject.DestroyImmediate(gameObject); } else { GameObject.Destroy(gameObject); } } }
public void RebuildMesh() { gameObject.AddComponent <TTFText>(); TTFText tt = gameObject.GetComponent <TTFText>(); // reflect all possible parameters : PropertyInfo[] rproperties = typeof(TTFTextMesh).GetProperties(); PropertyInfo[] wproperties = typeof(TTFText).GetProperties(); foreach (PropertyInfo pi in rproperties) { try { PropertyInfo pi2 = null; foreach (PropertyInfo pi3 in wproperties) { if (pi.Name == pi3.Name) { pi2 = pi3; } } if (pi2 != null) { if ((pi.CanRead) && (pi2.CanWrite)) { //Debug.Log(pi.Name); pi2.SetValue(tt, pi.GetValue(this, null), null); } } } catch (System.Exception e) { Debug.LogError(e); } } if ((Application.isEditor) && (!Application.isPlaying)) { DestroyImmediate(this); } else { Destroy(this); } }
// // Draw the differences between the track lines // void drawTrackDiff(XYChart c, Dictionary <string, double> log0, Dictionary <string, double> log1) { double x0, x1; if (!((null != log0) && log0.TryGetValue("x", out x0) && (null != log1) && log1.TryGetValue("x", out x1))) { return; } // Two columns in the table var leftCol = new System.Text.StringBuilder(); var rightCol = new System.Text.StringBuilder(); leftCol.Append("Change in x: "); rightCol.Append(c.formatValue(x1 - x0, "{value|2}")); // Iterate through all layers to draw the data labels for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { var dataSetName = layer.getDataSet(j).getDataName(); double v0, v1; if (!(log0.TryGetValue(dataSetName, out v0) && log1.TryGetValue(dataSetName, out v1))) { continue; } leftCol.Append("\nChange in ").Append(dataSetName).Append(": "); rightCol.Append("\n").Append(c.formatValue(v1 - v0, "{value|2}")); } } string table = "<*block,bgColor=80ffffff,margin=4*><*block*>" + leftCol.ToString() + "<*/*><*block,halign=right*>" + rightCol.ToString() + "<*/*><*/*>"; TTFText t = c.getDrawArea().text(table, "Arial", 10); t.draw(c.getPlotArea().getRightX() - t.getWidth(), c.getPlotArea().getTopY(), 0x000000); }
// Use this for initialization void Start() { ttm=transform.parent.GetComponent<TTFText>(); tts=GetComponent<TTFSubtext>(); TTFTextOutline o=TTFTextInternal.Engine.MakeOutline(tts.Text, ttm.Hspacing,ttm.Embold,ttm); foreach(TTFTextOutline.Boundary bn in o.boundaries) { b=bn; break; } sz2=o.GetSize()/2; if (b!=null) { but=b.GetUniformTraverser(); flare=transform.FindChild("Flare"); flare2=transform.FindChild("Flare2"); flare3=transform.FindChild("Flare3"); } }
/// <summary> /// Tries to build a whole charset according current parameters of a textmesh object /// </summary> public void BuildCharSet(TTFText tm) { #if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR int istep = TTFTextFontStore.Instance.defaultInterpolationSteps; charset = new TTFTextOutline[0x80]; charset_advance = new Vector3[0x80]; System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding(); TTF.Font font = TTFTextInternal.Utilities.TryOpenFont(tm.InitTextStyle, 1); if (font == null) { Debug.LogError("(TTFText) BuildCharSet: no font found"); return; } height = font.Height; for (byte i = 0x20; i < 0x7F; i++) { string s = ae.GetString(new byte [] { i }); charset[i] = TTFTextInternal.Engine.MakeNativeOutline(s, 1, 0, font, tm.OrientationReversed, istep); charset_advance[i] = charset[i].advance; } // Additional Custom Characters AddRequiredCharacters(TTFTextFontStore.Instance.defaultAdditionalCharacters + (tm.InitTextStyle.GetFontEngineParameters(1) as TTFTextInternal.FontStoreFontEngine.Parameters).additionalCharacters); addCharset = new TTFTextOutline[additionalChar.Length]; int idx = 0; foreach (char c in additionalChar) { addCharset[idx] = TTFTextInternal.Engine.MakeNativeOutline("" + c, 1, 0, font, tm.OrientationReversed, istep); ++idx; } font.Dispose(); _needRebuild = false; #endif }
// Use this for initialization void Start() { ttm = transform.parent.GetComponent <TTFText>(); tts = GetComponent <TTFSubtext>(); TTFTextOutline o = TTFTextInternal.Engine.MakeOutline(tts.Text, ttm.Hspacing, ttm.Embold, ttm); foreach (TTFTextOutline.Boundary bn in o.boundaries) { b = bn; break; } sz2 = o.GetSize() / 2; if (b != null) { but = b.GetUniformTraverser(); flare = transform.FindChild("Flare"); flare2 = transform.FindChild("Flare2"); flare3 = transform.FindChild("Flare3"); } }
/// <summary> /// Tries to build a whole charset according current parameters of a textmesh object /// </summary> public void BuildCharSet(TTFText tm) { #if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR int istep=TTFTextFontStore.Instance.defaultInterpolationSteps; charset = new TTFTextOutline[0x80]; charset_advance = new Vector3[0x80]; System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding(); TTF.Font font = TTFTextInternal.Utilities.TryOpenFont(tm.InitTextStyle,1); if (font == null) { Debug.LogError("(TTFText) BuildCharSet: no font found"); return; } height=font.Height; for (byte i = 0x20; i < 0x7F; i++) { string s = ae.GetString(new byte [] {i}); charset[i] = TTFTextInternal.Engine.MakeNativeOutline(s, 1,0,font,tm.OrientationReversed,istep); charset_advance[i] = charset[i].advance; } // Additional Custom Characters AddRequiredCharacters(TTFTextFontStore.Instance.defaultAdditionalCharacters + (tm.InitTextStyle.GetFontEngineParameters(1) as TTFTextInternal.FontStoreFontEngine.Parameters).additionalCharacters); addCharset = new TTFTextOutline[additionalChar.Length]; int idx = 0; foreach (char c in additionalChar) { addCharset[idx] = TTFTextInternal.Engine.MakeNativeOutline("" + c, 1, 0, font,tm.OrientationReversed,istep); ++idx; } font.Dispose(); _needRebuild=false; #endif }
// Update is called once per frame void Update() { if (clicked) { GameObject tgo = new GameObject(); tgo.AddComponent <TTFText>(); tgo.transform.localPosition = new Vector3(0, 3.40f, 0); tgo.transform.localRotation = Quaternion.Euler(40, 0, 0); TTFText tm = tgo.GetComponent <TTFText>(); tm.FontId = "Droid Sans Mono (Regular)"; tm.Size = 0.25f; tm.LineWidth = 15; tm.LayoutMode = TTFText.LayoutModeEnum.Wrap; tm.ParagraphAlignment = TTFText.ParagraphAlignmentEnum.Justified; tm.TokenMode = TTFText.TokenModeEnum.Word; tm.GlyphPrefab = prefab; tm.FirstLineOffset = 1.5f; // tm.DynamicTextRuntimeFontProviderMethod=TTFText.DynamicTextRuntimeFontProviderMethodEnum.EmbeddedAndNetworkFonts; tm.Text = string.Join("\n", text); //.Substring(0,1000); started = true; clicked = false; } }
/// <summary> /// Utility function returns the correct translation according to the 3d attachment of the object /// </summary> /// <returns> /// The object from bounds. /// </returns> /// <param name='tm'> /// Tm. /// </param> /// <param name='bounds'> /// Bounds. /// </param> public static Vector3 TranslateObjectFromBounds(TTFText tm, Bounds bounds) { Vector3 tr = Vector3.zero; switch (tm.HJust) { case TTFText.HJustEnum.Center: tr.x = -bounds.center.x; break; case TTFText.HJustEnum.Left: tr.x = -bounds.min.x; break; case TTFText.HJustEnum.Right: tr.x = -bounds.max.x; break; } switch (tm.VJust) { case TTFText.VJustEnum.Center: tr.y = -bounds.center.y; break; case TTFText.VJustEnum.Top: tr.y = -bounds.max.y; break; case TTFText.VJustEnum.Bottom: tr.y = -bounds.min.y; break; } tr.z = -bounds.center.z; return(tr); }
static int ExpectedNumberOfSubmeshes (TTFText tm) { int nsubmeshes = 1; if ((tm.SplitSides)) { nsubmeshes = 3; if (tm.ExtrusionMode == TTFText.ExtrusionModeEnum.Pipe) { nsubmeshes = 1; } if (tm.ExtrusionMode == TTFText.ExtrusionModeEnum.None) { if (! tm.BackFace) nsubmeshes = 1; else nsubmeshes = 2; } } return nsubmeshes; }
public void UnregisterClient(TTFText t) { }
public static void BuildTextModeSubobjectsP2 (TTFText tm, ref Bounds bounds) { //if (tm.rebuildLayout) { // Vector3 tr = Utilities.TranslateObjectFromBounds (tm, bounds); foreach (Transform t in tm.transform) { //t.localPosition += tr; if (tm.gameObject) { //TTFSubtext stx = t.gameObject.GetComponent<TTFSubtext> (); //if (stx != null) { // stx.LocalSoftPosition += tr; //} #if UNITY_EDITOR if (true) { MeshFilter smf=t.GetComponent<MeshFilter>(); if (smf!=null) { Mesh stm =smf.sharedMesh; if (stm!=null) { tm.statistics_num_vertices+=(stm!=null)?stm.vertexCount:0; tm.statistics_num_subobjects++; } } } #endif } } }
public static void BuildTextModeTextP1 (TTFText tm, int nsubmeshes, ref List<CombineInstance []> cis) { List<TTFTextInternal.LineLayout> lls = new List<TTFTextInternal.LineLayout> (GenerateTextLayout (tm.Text, tm)); for (int i=0; i<nsubmeshes; i++) { cis.Add (new CombineInstance[lls.Count]); } float lm = tm.LineSpacingMult; float la = tm.LineSpacingAdd; int idx = 0; foreach (TTFTextInternal.LineLayout ll in lls) { Vector3 adv; Mesh mesh = new Mesh (); BuildMesh (ref mesh, ll, tm, out adv); float msz = Mathf.Abs (ll.MaxCharacterSize); if (msz <= 0) msz = tm.Size; if ((ll.line.Length > 0) && (ll.charstyleindex != null) && (ll.charstyleindex [0] != -1)) { lm = ll.GetCharStyle (0).LineSpacingMult; la = ll.GetCharStyle (0).LineSpacingAdd; } Vector3 offset = new Vector3 (ll.offset, - (msz * lm + la) * idx, 0); // we offseteach line vertically for (int i=0; i<nsubmeshes; i++) { cis [i] [idx].mesh = mesh; cis [i] [idx].subMeshIndex = i; cis [i] [idx].transform = Matrix4x4.TRS (offset, Quaternion.identity, new Vector3 (1, 1, 1)); } idx++; tm.advance = Vector3.Max (tm.advance, ll.advance); } }
// public void UpdateClient(TTFText tm) { // may be used to update the necessary charmap of // a font on the fly TTFTextFontStoreFont x= GetFont (tm.FontId); x.AddRequiredCharacters(x.additionalChar); if (x.needRebuild) { x.BuildCharSet(tm.FontId); } Debug.LogWarning("Not yet implemented"); }
public static void BuildTextModeTextP2 (TTFText tm, int nsubmeshes, ref List<CombineInstance []> cis) { if (tm.mesh == null) { tm.mesh = new Mesh (); } tm.mesh.Clear (); CombineInstance [] tci = new CombineInstance[nsubmeshes]; for (int i=0; i<nsubmeshes; i++) { tci [i].mesh = new Mesh (); tci [i].mesh.CombineMeshes (cis [i], true, true); tci [i].subMeshIndex = 0; tci [i].transform = Matrix4x4.identity; } tm.mesh.CombineMeshes (tci, false, false); // Free intermediate meshes for (int i = 0; i < nsubmeshes; ++i) { foreach (CombineInstance c in cis[i]) { Utilities.DestroyObj (c.mesh); } Utilities.DestroyObj (tci [i].mesh); } tm.mesh.name = "TTF Text AutoGenerated"; tm.mesh.RecalculateBounds (); Vector3 tr = Utilities.TranslateObjectFromBounds (tm, tm.mesh.bounds); TTFTextInternal.Utilities.TranslateMesh (tm.mesh, tr); tm.mesh.Optimize (); #if UNITY_EDITOR tm.statistics_num_vertices+=tm.mesh.vertexCount; tm.statistics_num_subobjects++; #endif UpdateComponentsWithNewMesh (tm.gameObject, tm.mesh); #endregion }
public static TTFTextOutline MakeOutline (string txt, float charSpacing, float embold, TTFText tm) { return MakeOutline (txt, charSpacing, embold, tm, tm.OrientationReversed, null, null, null); }
public void RegisterClient(TTFText tm ) { if (! Clients.Contains(tm)) { Clients.Add(tm); } //EnsureFont(tm.FontId); }
public static void ResetChildren (TTFText tm) { List<Transform> l = new List<Transform> (); // keep track of token previous positions if (tm.SaveTokenPos) { tm.TokenPos.Clear (); } foreach (Transform t in tm.transform) { if (tm.SaveTokenPos) { tm.TokenPos.Add (new TTFText.TrInfo (t)); } l.Add (t); } foreach (Transform t in l) { if (t.GetComponent<TTFSubtext> () != null) { Utilities.DestroyObj (t.gameObject); } } }
public static TTFTextOutline MakeOutline (TTFTextInternal.LineLayout ll, float embold, TTFText tm) { return MakeOutline (ll.line, ll.hspacing, embold, tm, tm.OrientationReversed, ll.charpositions, ll.charstyleindex, ll.charmetadata); }
// EASY MARKUP public static void EvalEasyMarkUp (TTFText tm, string bs, ref TTFTextInternal.LineLayout ll) { // Debug.Log("Eval "+bs); #if TTFTEXT_LITE if (tm.DemoMode) { #endif TTFTextStyle ts = tm.CurrentTextStyle; try { bs = bs.Trim (); if (bs [0] == '#') { EvalScriptText (tm, bs.Substring (1), ref ll); } char [] separators = {'|'}; foreach (string s in bs.Split(separators)) { if (s.Contains ("=")) { char [] seps = {'='}; string [] vals = s.Split (seps); string lval = vals [0].Trim (); string rval = vals [1].Trim (); if (lval == "style") { if (rval.Contains ("<")) { // probably invalid return; } ts = ts.PushF (rval, tm.autoCreateStyles, ref tm.nonFoundStyles); } else { if (!lval.Contains ("#")) { // we modify our component System.Type tp = typeof(TTFTextStyle); System.Reflection.PropertyInfo pi = tp.GetProperty (lval); string tpn = pi.PropertyType.Name; ts = ts.Push (); if (tpn == tpn_float) { if (rval [0] == '+') { pi.SetValue (ts, ((float)pi.GetValue (ts, null)) + System.Single.Parse (rval.Substring (1)), null); } else { if (rval [0] == '*') { pi.SetValue (ts, ((float)pi.GetValue (ts, null)) * System.Single.Parse (rval.Substring (1)), null); } else { pi.SetValue (ts, System.Single.Parse (rval), null); } } } else { if (tpn == tpn_bool) { pi.SetValue (ts, System.Boolean.Parse (rval), null); } else { if (tpn == tpn_int) { pi.SetValue (ts, System.Int32.Parse (rval), null); } else { if (tpn == tpn_string) { pi.SetValue (ts, rval, null); } else { Debug.LogWarning (pi.PropertyType.Name + " : Behaviour not defined"); } } } } } else { int isharp = lval.IndexOf ('#'); string comppart = lval.Substring (0, isharp); string fieldname = lval.Substring (isharp + 1); object o = (object)tm.gameObject.GetComponent (comppart); System.Type tp = o.GetType (); System.Reflection.FieldInfo fi = tp.GetField (fieldname); string tpn = fi.FieldType.Name; if (tpn == tpn_float) { if (rval [0] == '+') { fi.SetValue (o, ((float)fi.GetValue (o)) + System.Single.Parse (rval.Substring (1))); } else { if (rval [0] == '*') { fi.SetValue (o, ((float)fi.GetValue (o)) * System.Single.Parse (rval.Substring (1))); } else { fi.SetValue (o, System.Single.Parse (rval)); } } } else { if (tpn == tpn_bool) { fi.SetValue (o, System.Boolean.Parse (rval)); } else { if (tpn == tpn_int) { fi.SetValue (o, System.Int32.Parse (rval)); } else { if (tpn == tpn_string) { fi.SetValue (o, rval); } else { Debug.LogWarning (fi.FieldType.Name + " : Behaviour not defined"); } } } } } } } else { if ((s.ToLower () == "end") || (s.ToLower () == "pop")) { ts = ts.Pop (); } else { Debug.LogError ("(TTFText) Unknown command : " + s); } } // Debug.Log("Setting ts fontid : "+ts.FontId+" getid : " +ts.getid()); tm.CurrentTextStyle = ts; } } catch (System.Exception e) { Debug.LogError (e); } #if TTFTEXT_LITE } #endif }
/// <summary> /// The following script text is experimental /// it is based on JyC. /// It provide direct access to C# methods and objects /// but it may not be the most intuitive for our users /// It is accessbile through tags <@# .... @> /// /// </summary> public static void EvalScriptText (TTFText tm, string s, ref TTFTextInternal.LineLayout ll) { #if! TTFTEXT_LITE // TTFTextStyle ts = tm.CurrentTextStyle; Jyc.Expr.Parser ep = new Jyc.Expr.Parser (); Jyc.Expr.Tree tree; try { tree = ep.Parse (s); Jyc.Expr.Evaluator evaluater = new Jyc.Expr.Evaluator (); Jyc.Expr.ParameterVariableHolder pvh = new Jyc.Expr.ParameterVariableHolder (); pvh.Parameters ["T"] = pvh.Parameters ["text"] = new Jyc.Expr.Parameter (tm); pvh.Parameters ["S"] = pvh.Parameters ["style"] = new Jyc.Expr.Parameter (ts); pvh.Parameters ["L"] = pvh.Parameters ["linelayout"] = new Jyc.Expr.Parameter (ll); //pvh.Parameters ["I"] = pvh.Parameters ["img"] = new Jyc.Expr.Parameter(TTFTextInternal.Get); evaluater.VariableHolder = pvh; ts = (TTFTextStyle)evaluater.Eval (tree); if (ts != null) { //Debug.Log ( ts.Size); tm.CurrentTextStyle = ts; } } catch (System.Exception e) { Debug.LogError (e); } #endif }
static void ResetTextMesh (TTFText tm) { ResetChildren (tm); MeshFilter mf = tm.GetComponent<MeshFilter> (); if (mf != null) { mf.sharedMesh = null; } if (tm.mesh != null) { Utilities.DestroyObj (tm.mesh); tm.mesh = null; } tm.advance = Vector3.zero; tm.nonFoundStyles = false; tm.statistics_num_vertices = 0; tm.statistics_num_subobjects = 0; }
public void UpdateClient(TTFText t) { }
public void FontSelector(TTFText tm) { GUILayout.Label ("Font Selection"); Color defcolor = GUI.color; EditorGUI.indentLevel=2; //if (selectedFontEngine == -1) { // GUILayout.Label ("Invalid font engine selected this should not happen !"); // return; // } /* * Force Compatible ? * if (!TTFTextInternal.TTFTextFontEngine.font_engines[selectedFontEngine].IsCompatible(BuildTargetToRuntimePlatform(EditorUserBuildSettings.activeBuildTarget))) { selectedFontEngine=-1; for (int i=0;i<TTFTextInternal.TTFTextFontEngine.font_engines.Length;i++){ if (TTFTextInternal.TTFTextFontEngine.font_engines[i].IsCompatible(BuildTargetToRuntimePlatform(EditorUserBuildSettings.activeBuildTarget))) { selectedFontEngine=i; break; } } } */ #if !TTFTEXT_LITE tm.InitTextStyle.useDifferentFontIdForEachFontEngine= EditorGUILayout.Toggle (new GUIContent("Platform specific","Use different font for each font engine"),tm.InitTextStyle.useDifferentFontIdForEachFontEngine); if (!tm.InitTextStyle.useDifferentFontIdForEachFontEngine) { tm.InitTextStyle.EmbedFont= EditorGUILayout.Toggle (new GUIContent("Embed font","Force font embedding on all platform"),tm.InitTextStyle.EmbedFont); } #endif if (tm.InitTextStyle.GetFontEngineParameters (selectedFontEngine) == null) { selectedFontEngine = 0; } if (tm.InitTextStyle.useDifferentFontIdForEachFontEngine) { EditorGUILayout.BeginHorizontal (); int prefered=tm.InitTextStyle.GetUsedFontEngine(); for (int i=0; i<TTFTextInternal.TTFTextFontEngine.font_engines.Length; i++) { //if ( (TTFTextInternal.TTFTextFontEngine.font_engines [i].IsCompatible (BuildTargetToRuntimePlatform (EditorUserBuildSettings.activeBuildTarget)))) { if (selectedFontEngine == -1) { selectedFontEngine = i; } string n = TTFTextInternal.TTFTextFontEngine.font_engines [i].GetType ().Name; if (i==prefered) { GUI.tooltip="This font engine is the one being used by default"; } else { GUI.tooltip=null; } if (selectedFontEngine == i) { GUI.color = selectedColor; } else { if (tm.InitTextStyle.GetFontEngineParameters (i) == null) { GUI.color = Color.gray; } else { GUI.color = defcolor; } } if (GUILayout.Button (n.Substring (0, n.Length - 10))) { selectedFontEngine = i; } GUI.color = defcolor; } EditorGUILayout.EndHorizontal (); } // ok the font selector is gonna be either "simple" (for one platform only), either advanced // we want to select font for each platform without forgetting our choices for // the other platforms... if ((selectedFontEngine < 0)||(!tm.InitTextStyle.useDifferentFontIdForEachFontEngine)) selectedFontEngine = 0; List<string> fontIDs = TTFTextInternal.TTFTextFontEngine.font_engines [selectedFontEngine].GetFontList (tm.InitTextStyle.GetFontEngineParameters (selectedFontEngine)); string fontid = tm.InitTextStyle.GetFontEngineFontId (selectedFontEngine); string prevfontid = fontid; if (fontid == null) { fontid = tm.FontId; } fontpat = EditorGUILayout.TextField ("Search : ", fontpat).ToLower(); if (fontIDs != null) { if (fontid == null || fontid == "") { if (fontIDs.Count > 0) { fontid = fontIDs [0]; } } { scrollpos = EditorGUILayout.BeginScrollView (scrollpos, false, true, GUILayout.MinHeight (150), GUILayout.MaxHeight (150)); for (int i = 0; i < fontIDs.Count; ++i) { string id = fontIDs [i]; if ((fontpat.Length>0)&&(!id.ToLower().Contains(fontpat))) { continue; } if (tm.IsStyleObject) { if (fontid == id) { GUI.color = (!tm.InitTextStyle.overrideFontId) ? defcolor : style_choice_color; } else { GUI.color = defcolor; } } else { if (fontid == id) { GUI.color = selectedColor; } else { GUI.color = defcolor; } } if (GUILayout.Button (id)) { fontid = id; } } EditorGUILayout.EndScrollView (); GUI.color = defcolor; } } #if !TTFTEXT_LITE EditorGUI.indentLevel += 1; showRuntimeOption = EditorGUILayout.Foldout (showRuntimeOption, "Font Engine Advanced Options"); EditorGUI.indentLevel += 1; if (showRuntimeOption) { fontid = EditorGUILayout.TextField ("Font selector : ", fontid); object r = tm.InitTextStyle.GetFontEngineParameters (selectedFontEngine); if (r != null) { if (Inspector (ref r)) { if (tm.InitTextStyle.useDifferentFontIdForEachFontEngine) { tm.InitTextStyle.SetFontEngineParameters (selectedFontEngine, r); } else { tm.InitTextStyle.SetFontEngineParameters (-1, r); } tm.SetDirty (); } } else { GUI.color = Color.red; GUILayout.TextField ("Engine parameters not accessible... [Serialization error ? This should not occur.]"); GUI.color = defcolor; } } EditorGUI.indentLevel = 0; #endif if (fontid != prevfontid) { if (tm.InitTextStyle.embedFont) { tm.FontId=fontid; tm.InitTextStyle.overrideFontId = false; } else { tm.InitTextStyle.SetFontEngineFontId (selectedFontEngine, fontid); tm.InitTextStyle.overrideFontId = true; } tm.SetDirty (); } }
// // Draw the track line with legend // private void trackLineLegend(XYChart c, int mouseX) { // Clear the current dynamic layer and get the DrawArea object to draw on it. DrawArea d = c.initDynamicLayer(); // The plot area object PlotArea plotArea = c.getPlotArea(); // Get the data x-value that is nearest to the mouse, and find its pixel coordinate. double xValue = c.getNearestXValue(mouseX); int xCoor = c.getXCoor(xValue); // Draw a vertical track line at the x-position d.vline(plotArea.getTopY(), plotArea.getBottomY(), xCoor, 0xaaaaaa); // Container to hold the legend entries var legendEntries = new List <string>(); // Iterate through all layers to build the legend array for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // We are only interested in visible data sets with names string dataName = dataSet.getDataName(); int color = dataSet.getDataColor(); if ((!string.IsNullOrEmpty(dataName)) && (color != Chart.Transparent)) { // Build the legend entry, consist of the legend icon, name and data value. double dataValue = dataSet.getValue(xIndex); legendEntries.Add("<*block*>" + dataSet.getLegendIcon() + " " + dataName + ": " + (( dataValue == Chart.NoValue) ? "N/A" : c.formatValue(dataValue, "{value|P4}")) + "<*/*>"); // Draw a track dot for data points within the plot area int yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis()); if ((yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY())) { d.circle(xCoor, yCoor, 4, 4, color, color); } } } } // Create the legend by joining the legend entries legendEntries.Reverse(); string legendText = "<*block,maxWidth=" + plotArea.getWidth() + "*><*block*><*font=Arial Bold*>[" + c.xAxis().getFormattedLabel(xValue, "mmm dd, yyyy") + "]<*/*> " + String.Join( " ", legendEntries) + "<*/*>"; // Display the legend on the top of the plot area TTFText t = d.text(legendText, "Arial Bold", 10); t.draw(plotArea.getLeftX() + 5, plotArea.getTopY() - 3, 0x000000, Chart.BottomLeft); }
/// <summary> /// Core function generating the outline for a portion of text /// </summary> /// <returns> /// The outline. /// </returns> /// <param name='txt'> /// The text to be rendered /// </param> /// <param name='charSpacing'> /// The default character spacing /// </param> /// <param name='embold'> /// Current embold /// </param> /// <param name='tm'> /// Link to the TTFText object /// </param> /// <param name='reversed'> /// Orientation of the outlines /// </param> /// <param name='charpositions'> /// Position of the character /// </param> /// <param name='charstyleidx'> /// Style index of each character /// </param> /// <param name='charmetadata'> /// Metadata associated to special character such as images and bitmap characters /// </param> /// <exception cref='System.Exception'> /// Is thrown when the exception. /// </exception> public static TTFTextOutline MakeOutline (string txt, float charSpacing, float embold, TTFText tm, bool reversed, float [] charpositions, int [] charstyleidx, object [] charmetadata) { TTFTextOutline outline = new TTFTextOutline (); int fp = 0; string currentfontid = ""; object cfont = null; object parameters = null; TTFTextStyle cttfstyle = null; if (charstyleidx == null) { cttfstyle = tm.InitTextStyle; fp = cttfstyle.PreferredEngine (Application.platform); #if ! TTFTEXT_LITE cfont = cttfstyle.GetFont (ref fp, ref currentfontid, ref parameters); #else fp=0; currentfontid=cttfstyle.FontId; parameters=cttfstyle.GetFontEngineParameters(0); if (parameters==null) { System.Type t = TTFTextInternal.TTFTextFontEngine.font_engines [0].GetType ().GetNestedType ("Parameters"); cttfstyle.SetFontEngineParameters(0,t.InvokeMember (t.Name, BindingFlags.CreateInstance, null, null, null)); parameters=cttfstyle.GetFontEngineParameters(0); } cfont= TTFTextInternal.TTFTextFontEngine.font_engines[0].GetFont(parameters,currentfontid); #endif if (cfont == null) { throw new System.Exception ("(TTFText) Font not found :" + tm.InitTextStyle.FontId); } } if (charpositions != null && charpositions.Length < txt.Length) { Debug.LogError ("(TTFText) Bad char position len=" + charpositions.Length + " txt = " + txt + " (len=" + txt.Length + ")"); charpositions = null; } int i = 0; foreach (char c in txt) { TTFTextOutline o = null; if (charstyleidx != null) { if ((cfont == null) || (currentfontid != tm.UsedStyles [charstyleidx [i]].GetFontEngineFontId (tm.UsedStyles [charstyleidx [i]].PreferredEngine (Application.platform)))) { cttfstyle = tm.UsedStyles [charstyleidx [i]]; fp = cttfstyle.PreferredEngine (Application.platform); //Debug.Log(fp); #if ! TTFTEXT_LITE cfont = cttfstyle.GetFont (ref fp, ref currentfontid, ref parameters); #else fp=0; currentfontid=cttfstyle.FontId; parameters=cttfstyle.GetFontEngineParameters(0); if (parameters==null) { System.Type t = TTFTextInternal.TTFTextFontEngine.font_engines [0].GetType ().GetNestedType ("Parameters"); cttfstyle.SetFontEngineParameters(0,t.InvokeMember (t.Name, BindingFlags.CreateInstance, null, null, null)); parameters=cttfstyle.GetFontEngineParameters(0); } cfont= TTFTextInternal.TTFTextFontEngine.font_engines[0].GetFont(parameters,currentfontid); #endif if (cfont == null) { throw new System.Exception ("Font not found :" + tm.InitTextStyle.FontId); } } } if ((charmetadata == null) || (charmetadata [i] == null)) { // a normal character if (TTFTextFontEngine.font_engines [fp].IsBitmapFontProvider (parameters)) { TTFTextTexturePortion p = TTFTextFontEngine.font_engines [fp].GetGlyphBitmap (parameters, cfont, c); o = new TTFTextOutline (); float w = ((float)p.w); float h = ((float)p.h); Vector3 b = new Vector3 (p.x, p.y, 0); //Vector3[] quad = {Vector3.zero,Vector3.right*w,new Vector3(w,h,0),Vector3.up*h}; Vector3[] quad = {b,b + Vector3.up * h,b + new Vector3 (w, h, 0),b + Vector3.right * w}; o.AddBoundary (quad); TTFTextInternal.TextureElement tel = new TTFTextInternal.TextureElement (); tel.width = w; tel.height = h; tel.material = p.material; tel.shouldReleaseMaterial = p.shouldReleaseMaterial; tel.texture = p.texture; tel.shouldReleaseTexture = p.shouldReleaseTexture; tel.UVstartx = p.sx; tel.UVstarty = p.sy; tel.UVwidth = p.dx; tel.UVheight = p.dy; charmetadata [i] = tel; } else { o = TTFTextFontEngine.font_engines [fp].GetGlyphOutline (parameters, cfont, c); if (charstyleidx != null) { for (int ii=0; ii<tm.UsedStyles[charstyleidx[i]].GetOutlineEffectStackElementLength(); ii++) { TTFTextStyle.TTFTextOutlineEffectStackElement tse = tm.InitTextStyle.GetOutlineEffectStackElement (ii); o = TTFTextOutline.AvailableOutlineEffects [tse.id].Apply (o, tse.parameters); } } else { for (int ii=0; ii<tm.InitTextStyle.GetOutlineEffectStackElementLength(); ii++) { TTFTextStyle.TTFTextOutlineEffectStackElement tse = tm.InitTextStyle.GetOutlineEffectStackElement (ii); o = TTFTextOutline.AvailableOutlineEffects [tse.id].Apply (o, tse.parameters); } } } } else { // it is some kind of special object (an embedded image... ?) //Debug.Log("Not yet implemented"); o = new TTFTextOutline (); float w = 1; float h = 1; Vector3[] quad = {Vector3.zero,Vector3.right * w,new Vector3 (w, h, 0),Vector3.up * h}; o.AddBoundary (quad); } o = o.Embolden (((charstyleidx != null) ? tm.UsedStyles [charstyleidx [i]].Embold : tm.Embold) + embold); o.Rescale ((charstyleidx != null) ? tm.UsedStyles [charstyleidx [i]].Size : tm.Size); if (charpositions == null) { outline.Append (o, outline.advance); } else { outline.Append (o, Vector3.right * charpositions [i]); } i += 1; } return outline; }
public void UnregisterClient(TTFText tm ) { while (Clients.Contains(tm)) { Clients.Remove(tm); } if (Clients.Count==0 && destroyWhenUnused) { if ((Application.isEditor)&&(!Application.isPlaying)) { GameObject.DestroyImmediate(gameObject); } else { GameObject.Destroy(gameObject); } } }
public void RegisterClient(TTFText t) { }
/* public string extrachar=System.Text.UTF32Encoding.UTF32.GetString( System.Text.UTF8Encoding.UTF8.GetBytes( "基本的に découvrir sur elle-même une vision inaccessible" ) ); */ // Use this for initialization void Start() { textobject=new GameObject(); textobject.AddComponent<MeshFilter>(); textobject.AddComponent<MeshRenderer>(); textobject.AddComponent<TTFText>(); textobject.renderer.material=new Material(Shader.Find("Diffuse")); textobject.renderer.material.color=Color.red; text=textobject.GetComponent<TTFText>(); text.TokenMode=TTFText.TokenModeEnum.Character; //#if UNITY_ANDROID text.SetPreferedEngine(RuntimePlatform.Android,2); // text.SetPreferedEngine(RuntimePlatform.Android,3); //#endif stime=Time.time; switchmodes = new SwitchModeD [] { Mode0, Mode1, Mode2, Mode3, Mode4, Mode5 #if UNITY_ANDROID || UNITY_IPHONE ,Mode6 #endif }; switchmodes[0](); }
// // Draw the track box with legend // private void trackBoxLegend(XYChart c, int mouseX, int mouseY) { // Clear the current dynamic layer and get the DrawArea object to draw on it. DrawArea d = c.initDynamicLayer(); // The plot area object PlotArea plotArea = c.getPlotArea(); // Get the data x-value that is nearest to the mouse double xValue = c.getNearestXValue(mouseX); // Compute the position of the box. This example assumes a label based x-axis, in which the // labeling spacing is one x-axis unit. So the left and right sides of the box is 0.5 unit from // the central x-value. int boxLeft = c.getXCoor(xValue - 0.5); int boxRight = c.getXCoor(xValue + 0.5); int boxTop = plotArea.getTopY(); int boxBottom = plotArea.getBottomY(); // Draw the track box d.rect(boxLeft, boxTop, boxRight, boxBottom, 0x000000, Chart.Transparent); // Container to hold the legend entries ArrayList legendEntries = new ArrayList(); // Iterate through all layers to build the legend array for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // Build the legend entry, consist of the legend icon, the name and the data value. double dataValue = dataSet.getValue(xIndex); if ((dataValue != Chart.NoValue) && (dataSet.getDataColor() != Chart.Transparent)) { legendEntries.Add(dataSet.getLegendIcon() + " " + dataSet.getDataName() + ": " + c.formatValue(dataValue, "{value|P4}")); } } } // Create the legend by joining the legend entries if (legendEntries.Count > 0) { legendEntries.Reverse(); string legend = "<*block,bgColor=FFFFCC,edgeColor=000000,margin=5*><*font,underline=1*>" + c.xAxis().getFormattedLabel(xValue) + "<*/font*><*br*>" + String.Join("<*br*>", (string[]) legendEntries.ToArray(typeof(string))) + "<*/*>"; // Display the legend at the bottom-right side of the mouse cursor, and make sure the legend // will not go outside the chart image. TTFText t = d.text(legend, "Arial Bold", 8); t.draw(Math.Min(mouseX + 12, c.getWidth() - t.getWidth()), Math.Min(mouseY + 18, c.getHeight() - t.getHeight()), 0x000000, Chart.TopLeft); } }
/// <summary> /// Wraps a paragraph in a text that possibly contains some markup /// </summary> /// <returns> /// Description of linelayout. /// </returns> /// <param name='text'> /// The text to be wrapped /// </param> /// <param name='tm'> /// The textmesh object that contains information about style and rendering /// </param> public static IEnumerable<TTFTextInternal.LineLayout> WrapParagraphsExt (string text, TTFText tm) { float d; int lno = 0; char[] lseps = new char[] { '\n' }; char[] wseps = new char[] { ' ' }; string [] paragraphs = text.Split (lseps); if (paragraphs.Length == 0) { yield break; } float firstlineoffset = 0; if ((tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Right) && (tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Center)) { firstlineoffset = tm.FirstLineOffset; } foreach (string paragraph in paragraphs) { System.Collections.Generic.List<TTFTextScriptTextToken> ttstts = new System.Collections.Generic.List<TTFTextScriptTextToken> (ParseScriptText (paragraph)); string otext; //string[] words = paragraph.Split(wseps, System.StringSplitOptions.RemoveEmptyEntries); int ntexts = 0; foreach (TTFTextScriptTextToken t in ttstts) { if (!t.is_script) ntexts++; } //return new TTFTextInternal.LineLayout(words[0],tm,true); if (ntexts == 0) { yield return new TTFTextInternal.LineLayout("",tm,true); if ((tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Right) && (tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Center)) { firstlineoffset = tm.FirstLineOffset; } } else { TTFTextInternal.LineLayout ll = new TTFTextInternal.LineLayout ("", tm, true); foreach (TTFTextScriptTextToken t in ttstts) { if (t.is_script) { otext = ll.line; EvalEasyMarkUp (tm, t.text, ref ll); d = ll.GetDefaultLineWidth (ll.hspacing); // TODO: <- THIS IS WRONG ! if (d > (ll.linewidth - firstlineoffset)) { ll.RewindLine (otext); FinalizeLL (ref ll, firstlineoffset); ll.lineno = lno++; yield return ll; firstlineoffset = 0; ll = new TTFTextInternal.LineLayout ("", tm, true); EvalEasyMarkUp (tm, t.text, ref ll); } } else { string[] words = null; if (tm.CurrentTextStyle.WordSplitMode == TTFText.WordSplitModeEnum.SpaceBased) { words = t.text.Split (wseps, System.StringSplitOptions.RemoveEmptyEntries); } if (tm.CurrentTextStyle.WordSplitMode == TTFText.WordSplitModeEnum.Character) { words = new string[t.text.Length]; int ci = 0; foreach (char c in t.text) { words [ci] = "" + c; ci++; } } foreach (string w in words/*t.text.Split(wseps)*/) { otext = ll.line; if (otext.Length != 0) { if (tm.CurrentTextStyle.WordSplitMode == TTFText.WordSplitModeEnum.SpaceBased) { ll.AppendText (' ' + w); } else { ll.AppendText (w); } } else { ll.AppendText (w); } d = ll.GetDefaultLineWidth (ll.hspacing); // TODO: <- THIS IS WRONG ! if (d > (ll.linewidth - firstlineoffset)) { ll.RewindLine (otext); FinalizeLL (ref ll, firstlineoffset); ll.lineno = lno++; yield return ll; firstlineoffset = 0; ll = new TTFTextInternal.LineLayout (w, tm, true); } } } } // last line if ((tm.ParagraphAlignment == TTFText.ParagraphAlignmentEnum.Justified)) { ll.align = TTFText.ParagraphAlignmentEnum.Left; } ll.offset = 0; if (((ll.align != TTFText.ParagraphAlignmentEnum.Right)) && ((ll.align != TTFText.ParagraphAlignmentEnum.Center))) { ll.offset = firstlineoffset; } ll.ComputeCharacterPositions (); if ((tm.ParagraphAlignment == TTFText.ParagraphAlignmentEnum.Right)) { ll.offset = ll.linewidth - ll.GetActualLinewidth (); } else { if ((tm.ParagraphAlignment == TTFText.ParagraphAlignmentEnum.Center)) { ll.offset = (ll.linewidth - ll.GetActualLinewidth ()) / 2; } else { ll.offset = firstlineoffset; } } ll.lineno = lno++; yield return ll; if ((tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Right) && (tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Center)) { firstlineoffset = tm.FirstLineOffset; } } } }
void drawTrackLine(XYChart c, int lineX, Dictionary <string, double> log) { // The drawarea and plotarea objects DrawArea d = c.getDrawArea(); PlotArea plotArea = c.getPlotArea(); // Get the data x-value that is nearest to the mouse, and find its pixel coordinate. double xValue = c.getNearestXValue(lineX); int xCoor = c.getXCoor(xValue); // Draw empty track line if it is ahead of the data if ((currentIndex <= 0) || ((xCoor < lineX) && (xValue >= chartTimeLimit))) { d.vline(plotArea.getTopY(), plotArea.getBottomY(), lineX, 0x888888); return; } // Draw a vertical track line at the x-position d.vline(plotArea.getTopY(), plotArea.getBottomY(), xCoor, 0x888888); // Draw a label on the x-axis to show the track line position. string xlabel = "<*font,bgColor=000000*> " + c.xAxis().getFormattedLabel(xValue, "nn:ss.ff") + " <*/font*>"; TTFText t = d.text(xlabel, "Arial Bold", 10); log["x"] = xValue; // Restrict the x-pixel position of the label to make sure it stays inside the chart image. int xLabelPos = Math.Max(0, Math.Min(xCoor - t.getWidth() / 2, c.getWidth() - t.getWidth())); t.draw(xLabelPos, plotArea.getBottomY() + 6, 0xffffff); // Iterate through all layers to draw the data labels for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // Get the color and position of the data label int color = dataSet.getDataColor(); int yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis()); // Draw a track dot with a label next to it for visible data points in the plot area if ((yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY()) && (color != Chart.Transparent) && (!string.IsNullOrEmpty(dataSet.getDataName()))) { d.circle(xCoor, yCoor, 4, 4, color, color); string label = "<*font,bgColor=" + color.ToString("x") + "*> " + c.formatValue( dataSet.getValue(xIndex), "{value|P4}") + " <*/font*>"; t = d.text(label, "Arial Bold", 10); log[dataSet.getDataName()] = dataSet.getValue(xIndex); // Draw the label on the right side of the dot if the mouse is on the left side the // chart, and vice versa. This ensures the label will not go outside the chart image. if (xCoor <= (plotArea.getLeftX() + plotArea.getRightX()) / 2) { t.draw(xCoor + 5, yCoor, 0xffffff, Chart.Left); } else { t.draw(xCoor - 5, yCoor, 0xffffff, Chart.Right); } } } } }
public static IEnumerable BuildTextModeTextAsync (TTFText tm) { // CASE 2 : WE MERGE ALL THE LAYOUT WE HAVE GENERATED IN A SINGLE MESH int nsubmeshes = ExpectedNumberOfSubmeshes (tm); List<CombineInstance []> cis = new List<CombineInstance[]> (); List<TTFTextInternal.LineLayout> lls = new List<TTFTextInternal.LineLayout> (GenerateTextLayout (tm.Text, tm)); for (int i=0; i<nsubmeshes; i++) { cis.Add (new CombineInstance[lls.Count]); } float lm = tm.LineSpacingMult; float la = tm.LineSpacingAdd; int idx = 0; foreach (TTFTextInternal.LineLayout ll in lls) { Vector3 adv; Mesh mesh = new Mesh (); BuildMesh (ref mesh, ll, tm, out adv); yield return mesh; float msz = Mathf.Abs (ll.MaxCharacterSize); if (msz <= 0) msz = tm.Size; if ((ll.line.Length > 0) && (ll.charstyleindex != null) && (ll.charstyleindex [0] != -1)) { lm = ll.GetCharStyle (0).LineSpacingMult; la = ll.GetCharStyle (0).LineSpacingAdd; } Vector3 offset = new Vector3 (ll.offset, - (msz * lm + la) * idx, 0); // we offseteach line vertically for (int i=0; i<nsubmeshes; i++) { cis [i] [idx].mesh = mesh; cis [i] [idx].subMeshIndex = i; cis [i] [idx].transform = Matrix4x4.TRS (offset, Quaternion.identity, new Vector3 (1, 1, 1)); } idx++; tm.advance = Vector3.Max (tm.advance, ll.advance); yield return null; } BuildTextModeTextP2 (tm, nsubmeshes, ref cis); }
// // Draw track line with data labels // private void trackLineLabel(XYChart c, int mouseX) { // Clear the current dynamic layer and get the DrawArea object to draw on it. DrawArea d = c.initDynamicLayer(); // The plot area object PlotArea plotArea = c.getPlotArea(); // Get the data x-value that is nearest to the mouse, and find its pixel coordinate. double xValue = c.getNearestXValue(mouseX); int xCoor = c.getXCoor(xValue); // Draw a vertical track line at the x-position d.vline(plotArea.getTopY(), plotArea.getBottomY(), xCoor, d.dashLineColor(0x000000, 0x0101)); // Draw a label on the x-axis to show the track line position. string xlabel = "<*font,bgColor=000000*> " + c.xAxis().getFormattedLabel(xValue, "mmm dd, yyyy") + " <*/font*>"; TTFText t = d.text(xlabel, "Arial Bold", 8); // Restrict the x-pixel position of the label to make sure it stays inside the chart image. int xLabelPos = Math.Max(0, Math.Min(xCoor - t.getWidth() / 2, c.getWidth() - t.getWidth())); t.draw(xLabelPos, plotArea.getBottomY() + 6, 0xffffff); // Iterate through all layers to draw the data labels for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // Get the color and position of the data label int color = dataSet.getDataColor(); int yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis()); // Draw a track dot with a label next to it for visible data points in the plot area if ((yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY()) && (color != Chart.Transparent)) { d.circle(xCoor, yCoor, 4, 4, color, color); string label = "<*font,bgColor=" + color.ToString("x") + "*> " + c.formatValue( dataSet.getValue(xIndex), "{value|P4}") + " <*/font*>"; t = d.text(label, "Arial Bold", 8); // Draw the label on the right side of the dot if the mouse is on the left side the // chart, and vice versa. This ensures the label will not go outside the chart image. if (xCoor <= (plotArea.getLeftX() + plotArea.getRightX()) / 2) { t.draw(xCoor + 5, yCoor, 0xffffff, Chart.Left); } else { t.draw(xCoor - 5, yCoor, 0xffffff, Chart.Right); } } } } }
/// <summary> /// Wraps a paragraphs that does not contain any markup. /// </summary> /// <returns> /// The paragraphs simple. /// </returns> /// <param name='text'> /// The Text to be wrapped up. /// </param> /// <param name='tm'> /// The textmesh object associated with it. /// </param> public static IEnumerable<TTFTextInternal.LineLayout> WrapParagraphsSimple (string text, TTFText tm) { // This function proceeds as follow it generates outline adding words one by one // if the line becomes too long for the desired textwidth it starts a new line float d; int lno = 0; char[] lseps = new char[] { '\n' }; char[] wseps = new char[] { ' ' }; string [] paragraphs = text.Split (lseps); if (paragraphs.Length == 0) { yield break; } float firstlineoffset = 0; if ((tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Right) && (tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Center)) { firstlineoffset = tm.FirstLineOffset; } foreach (string paragraph in paragraphs) { string[] words = null; if (tm.WordSplitMode == TTFText.WordSplitModeEnum.SpaceBased) { words = paragraph.Split (wseps, System.StringSplitOptions.RemoveEmptyEntries); } if (tm.WordSplitMode == TTFText.WordSplitModeEnum.Character) { words = new string[paragraph.Length]; int ci = 0; foreach (char c in paragraph) { words [ci] = "" + c; ci++; } } if (words.Length == 0) { yield return new TTFTextInternal.LineLayout("",tm,true); if ((tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Right) && (tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Center)) { firstlineoffset = tm.FirstLineOffset; } } else { TTFTextInternal.LineLayout ll = new TTFTextInternal.LineLayout (words [0], tm, true); for (int idx = 1; idx < words.Length; ++idx) { string w = words [idx]; string otext = ll.line; if (tm.WordSplitMode == TTFText.WordSplitModeEnum.SpaceBased) { ll.AppendText (" " + w); } else { ll.AppendText (w); } d = ll.GetDefaultLineWidth (ll.hspacing); if (d > (ll.linewidth - firstlineoffset)) { ll.RewindLine (otext); ll.offset = 0; if (((ll.align != TTFText.ParagraphAlignmentEnum.Right)) && ((ll.align != TTFText.ParagraphAlignmentEnum.Center))) { ll.offset = firstlineoffset; } ll.ComputeCharacterPositions (); if ((ll.align == TTFText.ParagraphAlignmentEnum.Right)) { // Debug.Log(System.String.Format("{0} {1}",ll.linewidth, ll.GetActualLinewidth())); ll.offset = ll.linewidth - ll.GetActualLinewidth (); } else { if ((ll.align == TTFText.ParagraphAlignmentEnum.Center)) { ll.offset = (ll.linewidth - ll.GetActualLinewidth ()) / 2; } else { ll.offset = firstlineoffset; } } ll.lineno = lno++; yield return ll; firstlineoffset = 0; ll = new TTFTextInternal.LineLayout (w, tm, true); } } // last line if ((tm.ParagraphAlignment == TTFText.ParagraphAlignmentEnum.Justified)) { ll.align = TTFText.ParagraphAlignmentEnum.Left; } ll.offset = 0; if (((ll.align != TTFText.ParagraphAlignmentEnum.Right)) && ((ll.align != TTFText.ParagraphAlignmentEnum.Center))) { ll.offset = firstlineoffset; } ll.ComputeCharacterPositions (); if ((tm.ParagraphAlignment == TTFText.ParagraphAlignmentEnum.Right)) { ll.offset = ll.linewidth - ll.GetActualLinewidth (); } else { if ((tm.ParagraphAlignment == TTFText.ParagraphAlignmentEnum.Center)) { ll.offset = (ll.linewidth - ll.GetActualLinewidth ()) / 2; } else { ll.offset = firstlineoffset; } } ll.lineno = lno++; yield return ll; if ((tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Right) && (tm.ParagraphAlignment != TTFText.ParagraphAlignmentEnum.Center)) { firstlineoffset = tm.FirstLineOffset; } } } }
public void OnGUI() { GUI.color = Color.black; //GUI.Label(new Rect((Screen.width-400)/2,10,400,300), // "2012/03/14: First demo of textmesh generation running on the web, some algorithms are still experimental and will be improved soon."); GUI.color = Color.red; GUILayout.BeginArea(new Rect(20, 20, Screen.width / 2.5f - 40, Screen.height)); GUILayout.Label("Change the text"); tm.Text = GUILayout.TextArea(tm.Text, 32); GUILayout.Label("Font"); GUILayout.BeginHorizontal(); GUI.color = (ct == "J")?Color.magenta:Color.red; if (GUILayout.Button("Junction")) { ct = "J"; tm.gameObject.GetComponent <Renderer>().enabled = false; tm.transform.position = bp + Vector3.forward * 100; tm = GameObject.Find("/Text " + ct).GetComponent <TTFText>(); tm.gameObject.GetComponent <Renderer>().enabled = true; tm.transform.position = bp; tm.Slant = 0; tm.Slant = 1; tm.Slant = 0; } GUI.color = (ct == "B")?Color.magenta:Color.red; if (GUILayout.Button("Talie")) { ct = "B"; tm.gameObject.GetComponent <Renderer>().enabled = false; tm.transform.position = bp + Vector3.forward * 100; tm = GameObject.Find("/Text " + ct).GetComponent <TTFText>(); tm.gameObject.GetComponent <Renderer>().enabled = true; tm.transform.position = bp; tm.Slant = 0; tm.Slant = 1; tm.Slant = 0; tm.ExtrusionMode = TTFText.ExtrusionModeEnum.Simple; tm.ExtrusionDepth = 0; tm.ExtrusionDepth = 1; } GUI.color = (ct == "LC")?Color.magenta:Color.red; if (GUILayout.Button("Strato")) { ct = "LC"; tm.gameObject.GetComponent <Renderer>().enabled = false; tm.transform.position = bp + Vector3.forward * 100; tm = GameObject.Find("/Text " + ct).GetComponent <TTFText>(); tm.gameObject.GetComponent <Renderer>().enabled = true; tm.transform.position = bp; tm.Slant = 0; tm.Slant = 1; tm.Slant = 0; } GUI.color = (ct == "LCDP")?Color.magenta:Color.red; if (GUILayout.Button("Dots")) { ct = "LCDP"; tm.gameObject.GetComponent <Renderer>().enabled = false; tm.transform.position = bp + Vector3.forward * 100; tm = GameObject.Find("/Text " + ct).GetComponent <TTFText>(); tm.gameObject.GetComponent <Renderer>().enabled = true; tm.transform.position = bp; tm.Slant = 0; tm.Slant = 1; tm.Slant = 0; tm.ExtrusionMode = TTFText.ExtrusionModeEnum.Simple; tm.ExtrusionDepth = 0; tm.ExtrusionDepth = 0.1f; } GUILayout.EndHorizontal(); GUI.color = Color.red; GUILayout.Label("Slant amount"); tm.Slant = GUILayout.HorizontalSlider(tm.Slant, -1, 1); GUILayout.Label("Character Spacing"); tm.Hspacing = GUILayout.HorizontalSlider(tm.Hspacing, 1, 2); GUILayout.Label("Simplify outline amount"); tm.SimplifyAmount = GUILayout.HorizontalSlider(tm.SimplifyAmount, 1.5f, 5f); GUILayout.Label("Extrusion"); if (ct != "LCDP") { GUILayout.BeginHorizontal(); GUI.color = (tm.ExtrusionMode == TTFText.ExtrusionModeEnum.Simple)?Color.magenta:Color.red; if (GUILayout.Button("Simple")) { tm.ExtrusionMode = TTFText.ExtrusionModeEnum.Simple; tm.ExtrusionDepth = 0; tm.ExtrusionDepth = 1; } GUI.color = (tm.ExtrusionMode == TTFText.ExtrusionModeEnum.Bevel)?Color.magenta:Color.red; if (GUILayout.Button("Bevel")) { tm.ExtrusionMode = TTFText.ExtrusionModeEnum.Bevel; tm.ExtrusionDepth = 0; tm.ExtrusionDepth = 1; } GUI.color = (tm.ExtrusionMode == TTFText.ExtrusionModeEnum.Bent)?Color.magenta:Color.red; if (GUILayout.Button("Bent")) { tm.ExtrusionMode = TTFText.ExtrusionModeEnum.Bent; tm.ExtrusionDepth = 0; tm.ExtrusionDepth = 1; } GUILayout.EndHorizontal(); } GUI.color = Color.red; if (tm.ExtrusionMode != TTFText.ExtrusionModeEnum.None) { GUILayout.Label("Depth"); tm.ExtrusionDepth = GUILayout.HorizontalSlider(tm.ExtrusionDepth, 0, 3.5f); } if ((tm.ExtrusionMode == TTFText.ExtrusionModeEnum.Bent) || (tm.ExtrusionMode == TTFText.ExtrusionModeEnum.Bevel)) { GUILayout.Label("Intensity"); tm.BevelForce = GUILayout.HorizontalSlider(tm.BevelForce, 0, 5); tm.BevelDepth = 1; //tm.ExtrusionSteps=; } /* * f = EditorGUILayout.FloatField("Gamma", tm.Gamma); * if (f != tm.Gamma) { * tm.Gamma = f; * int nbDiv=tm.NbDiv; * tm.ExtrusionSteps = new float[nbDiv]; * float cz=0; * float deltaZ = 0; * * for (int i=1;i<(nbDiv+1);i++) { * deltaZ=Mathf.Pow(Mathf.Sin(i*Mathf.PI/(nbDiv+1)),tm.Gamma); * tm.ExtrusionSteps[i-1]=cz; * cz+=deltaZ; * } * * cz -= deltaZ; * if (cz != 0) { * for (int i=0;i<nbDiv;i++) { * tm.ExtrusionSteps[i]/=cz; * } * } * } */ /* * * if (tm.ExtrusionMode == TTFText.ExtrusionMode.Bevel) { * * tm.ExtrusionDepth = EditorGUILayout.FloatField("Extrusion Depth", tm.ExtrusionDepth); * tm.BevelForce = EditorGUILayout.FloatField("Bevel Force", tm.BevelForce); * * idx = EditorGUILayout.IntField("Steps", tm.NbDiv); * if (idx != tm.NbDiv) { * if (idx < 2) { idx = 2; } * tm.NbDiv = idx; * } * * tm.BevelDepth = EditorGUILayout.Slider("Bevel Depth %", tm.BevelDepth, 0f, 1f); * * * } * */ GUILayout.EndArea(); }
public static void BuildTextModeText (TTFText tm) { // CASE 2 : WE MERGE ALL THE LAYOUT WE HAVE GENERATED IN A SINGLE MESH int nsubmeshes = ExpectedNumberOfSubmeshes (tm); List<CombineInstance []> cis = new List<CombineInstance[]> (); BuildTextModeTextP1 (tm, nsubmeshes, ref cis); BuildTextModeTextP2 (tm, nsubmeshes, ref cis); }