protected virtual void Dispose(bool disposing) { if (disposing) { textContainer = null; } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods // Inserts text into the text block array. The text is either a string // or an array of char. internal static void InsertText(TextTreeRootTextBlock rootTextBlock, int offset, object text) { TextTreeTextBlock block; int localOffset; int insertCount; int textLength; Invariant.Assert(text is string || text is char[], "Bad text parameter!"); // Get the block matching the insertion point. block = FindBlock(rootTextBlock, offset, out localOffset); // Fill this block to capacity. textLength = TextContainer.GetTextLength(text); insertCount = block.InsertText(localOffset, text, 0, textLength); if (insertCount < textLength) { // Put all the text to the smaller side of the gap into the new block. if (block.GapOffset < TextTreeTextBlock.MaxBlockSize / 2) { InsertTextLeft(block, text, insertCount); } else { InsertTextRight(block, text, insertCount); } } }
void OnEnable() { // Serialized Properties anchorPosition_prop = serializedObject.FindProperty("m_anchorPosition"); pivot_prop = serializedObject.FindProperty("m_pivot"); rectangle_prop = serializedObject.FindProperty("m_rect"); margins_prop = serializedObject.FindProperty("m_margins"); m_textContainer = (TextContainer)target; m_transform = Selection.activeGameObject.transform; // Get the UI Skin and Styles for the various Editors TMP_UIStyleManager.GetUIStyles(); /* if (m_visualHelper == null) { m_visualHelper = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform; m_visualHelper.localScale = new Vector3(0.25f, 0.25f, 0.25f); } */ }
//private FpsCounterAnchorPositions last_AnchorPosition; void Awake() { if (!enabled) { return; } m_camera = Camera.main; GameObject frameCounter = new GameObject("Frame Counter"); m_frameCounter_transform = frameCounter.transform; m_frameCounter_transform.parent = m_camera.transform; m_frameCounter_transform.localRotation = Quaternion.identity; m_TextMeshPro = frameCounter.AddComponent <TextMeshPro>(); m_TextMeshPro.font = Resources.Load("Fonts & Materials/ARIAL SDF", typeof(TextMeshProFont)) as TextMeshProFont; m_TextMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/ARIAL SDF Overlay", typeof(Material)) as Material; m_TextMeshPro.fontSize = 30; m_TextMeshPro.isOverlay = true; m_textContainer = frameCounter.GetComponent <TextContainer>(); Set_FrameCounter_Position(AnchorPosition); //last_AnchorPosition = AnchorPosition; m_TextMeshPro.text = instructions; }
void initializeContainers() { TextContainer container = new TextContainer("Fonts/LindseyLarge"); container.addEffect(new ScaleEffect(null, new Vector2(60, 140), 0.05f, 0.2f)); container.addEffect(new ScaleEffect(null, new Vector2(60, 140), -0.05f, 0.15f)); container.addEffect(new PauseEffect(null, 1)); container.addEffect(new FadeEffect(null, 0.5f, -1)); hud.addContainer(container, "Next Level"); container = new TextContainer("Fonts/LindseyMedium"); container.addEffect(new ScaleEffect(null, new Vector2(90, 180), 0.05f, 0.2f)); container.addEffect(new ScaleEffect(null, new Vector2(90, 180), -0.05f, 0.15f)); container.addEffect(new PauseEffect(null, 1)); container.addEffect(new FadeEffect(null, 0.5f, -1)); hud.addContainer(container, "Bonus"); container = new TextContainer("Fonts/LindseyMedium"); container.addEffect(new FadeEffect(null, 0.5f, 1)); container.addEffect(new PauseEffect(null, 2)); container.addEffect(new FadeEffect(null, 0.5f, -1)); hud.addContainer(container, "Bonus Expired"); hud.addContainer(new TextContainer("Fonts/LindseyMedium", new FadeEffect(null, 0.40f, -1)), "Draw Score"); hud.addContainer(new GraphicsContainer(Game.GraphicsDevice, 200, 20, Color.White, new FadeEffect(null, 0.40f, -1)), "Draw Flash"); }
// Helper for InsertText. Inserts text to the right of an existing block. private static void InsertTextRight(TextTreeTextBlock leftBlock, object text, int textOffset) { int newBlockCount; TextTreeTextBlock rightBlock; TextTreeTextBlock neighborBlock; TextTreeTextBlock newBlock; int count; int textEndOffset; int i; textEndOffset = TextContainer.GetTextLength(text); if (leftBlock.GapOffset == leftBlock.Count) { // Try to fill neighbor block. neighborBlock = (TextTreeTextBlock)leftBlock.GetNextNode(); if (neighborBlock != null) { count = Math.Min(neighborBlock.FreeCapacity, textEndOffset - textOffset); neighborBlock.InsertText(0, text, textEndOffset - count, textEndOffset); textEndOffset -= count; } } if (textOffset < textEndOffset) { // Try adding just one block. newBlockCount = 1; rightBlock = leftBlock.SplitBlock(); // Fill up the right block. count = Math.Min(rightBlock.FreeCapacity, textEndOffset - textOffset); rightBlock.InsertText(0, text, textEndOffset - count, textEndOffset); textEndOffset -= count; if (textOffset < textEndOffset) { // Fill up the larger block. // We need to copy from the end of the text here. textOffset += leftBlock.InsertText(leftBlock.Count, text, textOffset, textEndOffset); if (textOffset < textEndOffset) { // We've filled both blocks, and there's still more text to copy. // Prepare to allocate some more blocks. newBlockCount += (textEndOffset - textOffset + TextTreeTextBlock.MaxBlockSize - 1) / TextTreeTextBlock.MaxBlockSize; } } for (i = 0; i < newBlockCount - 1; i++) { newBlock = new TextTreeTextBlock(TextTreeTextBlock.MaxBlockSize); textOffset += newBlock.InsertText(0, text, textOffset, textEndOffset); newBlock.InsertAtNode(leftBlock, false /* insertBefore */); leftBlock = newBlock; } Invariant.Assert(textOffset == textEndOffset, "Not all text copied!"); } }
void Awake() { if (!enabled) return; m_camera = Camera.main; //Debug.Log("w:" + Screen.width + " h:" + Screen.height); GameObject frameCounter = new GameObject("Frame Counter"); m_frameCounter_transform = frameCounter.transform; m_frameCounter_transform.parent = m_camera.transform; m_frameCounter_transform.localRotation = Quaternion.identity; m_TextMeshPro = frameCounter.AddComponent<TextMeshPro>(); m_TextMeshPro.font = Resources.Load("Fonts & Materials/ARIAL SDF", typeof(TextMeshProFont)) as TextMeshProFont; m_TextMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/ARIAL SDF Overlay", typeof(Material)) as Material; m_TextMeshPro.fontSize = 48; //m_TextMeshPro.FontColor = new Color32(255, 255, 255, 128); //m_TextMeshPro.edgeWidth = .15f; m_TextMeshPro.isOverlay = true; //m_TextMeshPro.FaceColor = new Color32(255, 128, 0, 0); //m_TextMeshPro.EdgeColor = new Color32(0, 255, 0, 255); //m_TextMeshPro.FontMaterial.renderQueue = 4000; //m_TextMeshPro.CreateSoftShadowClone(new Vector2(1f, -1f)); m_textContainer = frameCounter.GetComponent<TextContainer>(); Set_FrameCounter_Position(AnchorPosition); last_AnchorPosition = AnchorPosition; }
public static void GeneratePDF() { var TC = new TextContainer(); var img = new MainImage(); var textManager = GameObject.FindObjectOfType <TextManager>(); var TMrect = textManager.GetComponent <RectTransform>().rect; img.x = TMrect.yMin; img.y = TMrect.xMin; img.width = TMrect.width; img.height = TMrect.height; img.totalPages = textManager.images.Count; TC.image = img; TC.list = new List <TextJSON>(); foreach (var c in GameObject.FindObjectsOfType <TextItem>()) { TC.list.Add(c.toJSON()); } var str = JsonConvert.SerializeObject(TC, Formatting.Indented); EditorGUIUtility.systemCopyBuffer = str; }
public async void BindFromAzure() { try { syncIndicator.IsRunning = true; memberDatabase = new MemberDatabase(); // var members = memberDatabase.GetMembers(); var sb = await manager1.GetTodoItemsAsync(); // var a = sb.Count(); // var b = members.Count(); TextContainer.Clear(); foreach (TodoItem var2 in sb) { if (var2.Message.StartsWith("blobimage")) { int index = var2.Message.IndexOf("blobimage"); var img1 = var2.Message.Substring(index + 9); var imagestore2 = img1 + ".jpg"; var images = DependencyService.Get <IFileService>().GetPictureFromDisk(imagestore2, getGalleryPath()); TextContainer.Add(new MessageText { imgsource = images, imgheight = "200", imgwidth = "200", Status = var2.Status }); var last3 = ListView.ItemsSource.Cast <object>().LastOrDefault(); ListView.ScrollTo(last3, ScrollToPosition.MakeVisible, false); } else if (var2.Message.StartsWith("pdf")) { int index = var2.Message.IndexOf("pdf"); var img1 = var2.Message.Substring(index + 3); var imagestore2 = img1 + ".pdf"; var pdffile = DependencyService.Get <IFileService>().GetPictureFromDisk(imagestore2, getGalleryPath()); // TextContainer.Add(new MessageText { imgsource = images, imgheight = "200", imgwidth = "200", Status = var2.Status }); TextContainer.Add(new MessageText { Text = pdffile, imgheight = "10", imgwidth = "10", Status = var2.Status }); var last3 = ListView.ItemsSource.Cast <object>().LastOrDefault(); ListView.ScrollTo(last3, ScrollToPosition.MakeVisible, false); } else { TextContainer.Add(new MessageText { Text = var2.Message, imgheight = "10", imgwidth = "10", Status = var2.Status }); var last3 = ListView.ItemsSource.Cast <object>().LastOrDefault(); ListView.ScrollTo(last3, ScrollToPosition.MakeVisible, false); } } syncIndicator.IsRunning = false; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); syncIndicator.IsRunning = false; } }
private void button1_Click(object sender, EventArgs e) { TextContainer tc = new TextContainer(_currentPanelQuestion.Entity, this); ControlMover.Add(tc.Instance); // _currentTask.Identifier++; }
/// <summary> /// Removes an item from a collection and from a tree. /// The element removed can be re-inserted later in another collection of a tree. /// </summary> /// <param name="item"></param> /// <returns> /// True if removal was successful. /// </returns> public bool Remove(TextElementType item) { if (item == null) { return(false); } if (item.Parent != this.Parent) { return(false); } // Note: We need to remember the textcontainer for any delete operations in this collection. // This is important for the case when the owner of the collection is a sibling member. // In a scenario where you remove the owner itself from the collection, // the owner belongs to another tree after the reposition. TextContainer textContainer = this.TextContainer; textContainer.BeginChange(); try { item.RepositionWithContent(null); } finally { textContainer.EndChange(); } return(true); }
void Awake() { m_TextMeshPro = GetComponent <TextMeshPro>(); m_TextContainer = GetComponent <TextContainer>(); textBefore = m_TextMeshPro.text; // m_TextMeshPro.ForceMeshUpdate(); }
private void ShowNextWord() { CancelInvoke("ShowNextWord"); TextContainer currentTextContainer = textContainers[currentTextMeshIndex]; if (currentTextContainer.CanDisplayNextWord()) { currentTextContainer.AppendNextWord(); DispatchMessage("OnShowNextWord", null); Invoke("ShowNextWord", textTimeout); } else { if (currentTextMeshIndex < textContainers.Count - 1) { currentTextMeshIndex++; currentTextContainer = textContainers[currentTextMeshIndex]; Invoke("ShowNextWord", textTimeout); return; } DispatchMessage("OnTextDone", this); return; } }
public void UpdateTextControls(string text) { Clear(); // this shouldnt be here since the whole point of this label is to HAVE a target size, just for place holder tho. if (string.IsNullOrWhiteSpace(text)) { return; } scale = 1; Vector2 measuredFontSize = Font.MeasureString(text); Vector2 measureWordWrappedSize = GetWordWrappedSize(text, 1); // Pre-check // if no target size given, set size to measurestring size. if (targetSize == Vector2.Zero) { this.Size = measuredFontSize; textContainer = new TextContainer(measuredFontSize, text, color); Add(textContainer); } else if (measureWordWrappedSize.Y > targetSize.Y) { // if you cant word wrap with the current scale. RESIZE!! this.Size = targetSize; textContainer = new TextContainer(measuredFontSize, text, color); Add(textContainer); /* * scale = Math.Min(targetSize.X / measuredFontSize.X, targetSize.Y / measuredFontSize.Y); * textContainer = new TextContainer(measuredFontSize, text, color); * //textContainer.Scale = scale; * Add(textContainer);*/ } // Check 1 // See if font.X > this.X // word wrap // Check 2 // see if font.Y > this.Y // scale whole size by y. /* * Vector2 fontSize = Font.MeasureString(text); * if(fontSize.X > this.X) * * * if (string.IsNullOrWhiteSpace(text)) * this.Size = this.parent.Size; * else * this.Size = GetTextSize(); * */ this.ControlSizeChange(lastSize); lastSize = this.Size; lastText = text; alignApplied = true; }
//private FpsCounterAnchorPositions last_AnchorPosition; private void Awake() { if (!enabled) { return; } m_camera = Camera.main; var frameCounter = new GameObject("Frame Counter"); m_frameCounter_transform = frameCounter.transform; m_frameCounter_transform.parent = m_camera.transform; m_frameCounter_transform.localRotation = Quaternion.identity; m_TextMeshPro = frameCounter.AddComponent <TextMeshPro>(); m_TextMeshPro.font = Resources.Load <TMP_FontAsset>("Fonts & Materials/LiberationSans SDF"); m_TextMeshPro.fontSharedMaterial = Resources.Load <Material>("Fonts & Materials/LiberationSans SDF - Overlay"); m_TextMeshPro.fontSize = 30; m_TextMeshPro.isOverlay = true; m_textContainer = frameCounter.GetComponent <TextContainer>(); Set_FrameCounter_Position(AnchorPosition); //last_AnchorPosition = AnchorPosition; m_TextMeshPro.text = instructions; }
public void SetWindowSize(int x, int y) { TextContainer textContainer = TextWindow.textContainer; textContainer.width = (float)x; textContainer.height = (float)y; }
//private FpsCounterAnchorPositions last_AnchorPosition; void Awake() { if (!enabled) return; m_camera = Camera.main; GameObject frameCounter = new GameObject("Frame Counter"); m_frameCounter_transform = frameCounter.transform; m_frameCounter_transform.parent = m_camera.transform; m_frameCounter_transform.localRotation = Quaternion.identity; m_TextMeshPro = frameCounter.AddComponent<TextMeshPro>(); m_TextMeshPro.font = Resources.Load("Fonts & Materials/ARIAL SDF", typeof(TextMeshProFont)) as TextMeshProFont; m_TextMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/ARIAL SDF Overlay", typeof(Material)) as Material; m_TextMeshPro.fontSize = 30; m_TextMeshPro.isOverlay = true; m_textContainer = frameCounter.GetComponent<TextContainer>(); Set_FrameCounter_Position(AnchorPosition); //last_AnchorPosition = AnchorPosition; m_TextMeshPro.text = instructions; }
protected virtual void ShowNextWord() { CancelInvoke("ShowNextWord"); TextContainer currentTextContainer = textContainers[currentTextMeshIndex]; if (currentTextContainer.CanDisplayNextWord()) { PlayTalkingAnimation(); currentTextContainer.AppendNextWord(); DispatchMessage("OnShowNextWord", null); if (textTimeout != -1f) { Invoke("ShowNextWord", textTimeout); } } else { if (currentTextMeshIndex < textContainers.Count - 1) { currentTextMeshIndex++; currentTextContainer = textContainers[currentTextMeshIndex]; Invoke("ShowNextWord", textTimeout); return; } OnTextBoxDone(); DispatchMessage("OnTextDone", this); return; } }
public async Task <TextContainer> GetArticleBySubject(string subject) { TextContainer text = null; if (!string.IsNullOrEmpty(subject)) { Article article = await db.GetArticleBySubject(subject); if (article != null) { text = new TextContainer() { Subject = article.Subject, Text = article.Text, }; return(text); } else { throw new HttpResponseException(HttpStatusCode.NotFound); } } else { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
private IEnumerator GetTextContentWWW(string[] paths, TextContainer container) { container.content = new string[paths.Length]; for (int i = 0; i < paths.Length; i++) { #if UNITY_STANDALONE || UNITY_EDITOR string filePath = "file://" + Path.Combine(Application.streamingAssetsPath, paths[i]); WWW www = new WWW(filePath); yield return(www); container.content[i] = www.text; #elif UNITY_ANDROID string filePath = "jar:file://" + Application.dataPath + "!/assets/" + paths[i].Replace("\\", "/"); WWW www = new WWW(filePath); yield return(www); container.content[i] = www.text; #elif UNITY_WEBGL string filePath = Path.Combine(Application.streamingAssetsPath, paths[i]).Replace("\\", "/"); //temp = filePath; UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); //#if !UNITY_EDITOR // var bytes = System.Text.Encoding.UTF8.GetBytes(www.downloadHandler.text); // var text = System.Text.Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3); // container.content[i] = text; //#else container.content[i] = www.downloadHandler.text; //#endif //temp += "\n"+ container.content[i]; #endif } }
// Token: 0x06006F06 RID: 28422 RVA: 0x001FE374 File Offset: 0x001FC574 internal static IContentHost FindContentHost(ContentElement contentElement) { IContentHost result = null; if (contentElement == null) { return(null); } if (contentElement is TextElement) { TextContainer textContainer = ((TextElement)contentElement).TextContainer; DependencyObject parent = textContainer.Parent; if (parent is IContentHost) { result = (IContentHost)parent; } else if (parent is FlowDocument) { result = ContentHostHelper.GetICHFromFlowDocument((TextElement)contentElement, (FlowDocument)parent); } else if (textContainer.TextView != null && textContainer.TextView.RenderScope is IContentHost) { result = (IContentHost)textContainer.TextView.RenderScope; } } return(result); }
public void Name_SetNull_ReturnsEmpty() { var result = TextContainer.Parse(Properties.Resources.text_container_1); result.Name = null; Assert.AreEqual(string.Empty, result.Name); }
/// <summary> /// collapse text /// </summary> public void CollapseText() { TextContainer.FakeAttributeClass = "display: block;"; if (TextContainer.WaitUntilExists(3).GetAttribute("class").Equals("block")) { TextLink.Wait(3).Click(); } }
public void GetKey_NotFoundKey_ThrowsKeyNotFoundException() { var result = TextContainer.Parse(Properties.Resources.text_container_1); result.SetCulture(CultureInfo.InvariantCulture); result.GetText("invalidKey"); }
/// <summary> /// expand text /// </summary> public void ExpandText() { TextContainer.FakeCssValueStyle = "display: none;"; if (TextContainer.WaitUntilExists(3).GetAttribute("class").Contains("none")) { TextLink.Wait(3).Click(); } }
public GeneratedDocumentContainer() { _csharpTextContainer = new TextContainer(_setOutputLock); _csharpTextContainer.TextChanged += CSharpTextContainer_TextChanged; _htmlTextContainer = new TextContainer(_setOutputLock); _htmlTextContainer.TextChanged += HtmlTextContainer_TextChanged; }
public void SetCulture_ChangesCulture() { TextContainer container = new TextContainer(supportedCulturesInvariant, invariantCultureTexts); container.SetCulture(CultureInfo.InvariantCulture); Assert.AreEqual(CultureInfo.InvariantCulture, container.CurrentCulture); }
public void Start() { framerateThisFrame = 1 / Time.deltaTime; Debug.Log(framerateThisFrame); times = new List <double>(); fpsText = GetComponent <TextMeshProUGUI>(); m_TextContainer = GetComponent <TextContainer>(); }
void Start() { for (int i = 0; i < NumberOfNPC; i++) { if (SpawnType == 0) { // TextMesh Pro Implementation //go.transform.localScale = new Vector3(2, 2, 2); GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); //go.renderer.castShadows = false; //go.renderer.receiveShadows = false; //go.transform.rotation = Quaternion.Euler(0, Random.Range(0, 360), 0); TextMeshPro textMeshPro = go.AddComponent <TextMeshPro>(); TextContainer textContainer = go.GetComponent <TextContainer>(); //textMeshPro.FontAsset = Resources.Load("Fonts & Materials/ARIAL SDF 16", typeof(TextMeshProFont)) as TextMeshProFont; //textMeshPro.anchor = AnchorPositions.Bottom; //textContainer.anchorPosition = TextContainerAnchors.Bottom; textContainer.isAutoFitting = false; textMeshPro.alignment = TextAlignmentOptions.Bottom; textMeshPro.fontSize = 96; textMeshPro.color = new Color32(255, 255, 0, 255); textMeshPro.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 0; } else { // TextMesh Implementation GameObject go = new GameObject(); //"NPC " + i); go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f)); //go.transform.position = new Vector3(0, 1.01f, 0); TextMesh textMesh = go.AddComponent <TextMesh>(); textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font; textMesh.renderer.sharedMaterial = textMesh.font.material; textMesh.anchor = TextAnchor.LowerCenter; textMesh.fontSize = 96; textMesh.color = new Color32(255, 255, 0, 255); textMesh.text = "!"; // Spawn Floating Text floatingText_Script = go.AddComponent <TextMeshProFloatingText>(); floatingText_Script.SpawnType = 1; } } }
private void updateCursorAndLayout() { Placeholder.Font = Placeholder.Font.With(size: CalculatedTextSize); textUpdateScheduler.Update(); float cursorPos = 0; if (text.Length > 0) { cursorPos = getPositionAt(selectionLeft); } float cursorPosEnd = getPositionAt(selectionEnd); float?selectionWidth = null; if (selectionLength > 0) { selectionWidth = getPositionAt(selectionRight) - cursorPos; } float cursorRelativePositionAxesInBox = (cursorPosEnd - textContainerPosX) / DrawWidth; //we only want to reposition the view when the cursor reaches near the extremities. if (cursorRelativePositionAxesInBox < 0.1 || cursorRelativePositionAxesInBox > 0.9) { textContainerPosX = cursorPosEnd - DrawWidth / 2 + LeftRightPadding * 2; } textContainerPosX = Math.Clamp(textContainerPosX, 0, Math.Max(0, TextFlow.DrawWidth - DrawWidth + LeftRightPadding * 2)); TextContainer.MoveToX(LeftRightPadding - textContainerPosX, 300, Easing.OutExpo); if (HasFocus) { caret.DisplayAt(new Vector2(cursorPos, 0), selectionWidth); } if (textAtLastLayout != text) { Current.Value = text; } if (textAtLastLayout.Length == 0 || text.Length == 0) { if (text.Length == 0) { Placeholder.Show(); } else { Placeholder.Hide(); } } textAtLastLayout = text; }
// Token: 0x06006A55 RID: 27221 RVA: 0x001E4378 File Offset: 0x001E2578 internal StructuralCache(FlowDocument owner, TextContainer textContainer) { Invariant.Assert(owner != null); Invariant.Assert(textContainer != null); Invariant.Assert(textContainer.Parent != null); this._owner = owner; this._textContainer = textContainer; this._backgroundFormatInfo = new BackgroundFormatInfo(this); }
private void OnEnable() { anchorPosition_prop = base.serializedObject.FindProperty("m_anchorPosition"); pivot_prop = base.serializedObject.FindProperty("m_pivot"); rectangle_prop = base.serializedObject.FindProperty("m_rect"); margins_prop = base.serializedObject.FindProperty("m_margins"); m_textContainer = (TextContainer)(object)base.target; TMP_UIStyleManager.GetUIStyles(); }
/// <summary> /// CreateTextBlock - Creates a text block, adds as visual child, databinds properties and sets up appropriate event listener. /// </summary> private void CreateTextBlock() { _textContainer = new TextContainer(this, false /* plainTextOnly */); _textBlock = new TextBlock(); AddVisualChild(_textBlock); _textBlock.IsContentPresenterContainer = true; _textBlock.SetTextContainer(_textContainer); InitializeTextContainerListener(); }
protected override void LoadViewState(object savedState) { if (savedState != null) { object[] arrState = savedState as object[]; this.nodeText = (string)arrState[1]; this.nodeValue = (string)arrState[2]; this.linksContainer = (LinksContainer)arrState[3]; this.textContainer = (TextContainer)arrState[4]; base.LoadViewState(arrState[0]); } }
public TreeViewLinksNode(string nodeText, string nodeValue, LinksContainer linksContainer, TextContainer textContainer) { this.nodeText = nodeText; this.nodeValue = nodeValue; this.linksContainer = linksContainer; this.textContainer = textContainer; this.Text = ""; this.Value = nodeValue; this.SelectAction = TreeNodeSelectAction.Select; }
void Start() { if (SpawnType == 0) { // TextMesh Pro Implementation m_textMeshPro = m_floatingText.AddComponent<TextMeshPro>(); m_textContainer = m_floatingText.GetComponent<TextContainer>(); m_floatingText_Transform = m_floatingText.transform; m_floatingText_Transform.position = m_transform.position + new Vector3(0, 15f, 0); m_textContainer.isAutoFitting = false; //m_textMeshPro.fontAsset = Resources.Load("Fonts & Materials/JOKERMAN SDF", typeof(TextMeshProFont)) as TextMeshProFont; // User should only provide a string to the resource. //m_textMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/ARIAL SDF 1", typeof(Material)) as Material; //m_textContainer.anchorPosition = TextContainerAnchors.Bottom; m_textMeshPro.alignment = TextAlignmentOptions.Center; m_textMeshPro.color = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), 255); m_textMeshPro.fontSize = 24; //m_textMeshPro.enableExtraPadding = true; //m_textMeshPro.enableShadows = false; m_textMeshPro.text = string.Empty; StartCoroutine(DisplayTextMeshProFloatingText()); } else if (SpawnType == 1) { //Debug.Log("Spawning TextMesh Objects."); m_floatingText_Transform = m_floatingText.transform; m_floatingText_Transform.position = m_transform.position + new Vector3(0, 15f, 0); m_textMesh = m_floatingText.AddComponent<TextMesh>(); m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font; m_textMesh.GetComponent<Renderer>().sharedMaterial = m_textMesh.font.material; m_textMesh.color = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), 255); m_textMesh.anchor = TextAnchor.LowerCenter; m_textMesh.fontSize = 24; StartCoroutine(DisplayTextMeshFloatingText()); } else if (SpawnType == 2) { } }
void Awake() { if (!enabled) return; m_camera = Camera.main; Application.targetFrameRate = -1; GameObject frameCounter = new GameObject("Frame Counter"); m_TextMeshPro = frameCounter.AddComponent<TextMeshPro>(); m_TextMeshPro.font = Resources.Load("Fonts & Materials/ARIAL SDF", typeof(TMP_FontAsset)) as TMP_FontAsset; m_TextMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/ARIAL SDF Overlay", typeof(Material)) as Material; m_frameCounter_transform = frameCounter.transform; m_frameCounter_transform.SetParent(m_camera.transform); m_frameCounter_transform.localRotation = Quaternion.identity; m_TextMeshPro.enableWordWrapping = false; m_TextMeshPro.fontSize = 24; //m_TextMeshPro.FontColor = new Color32(255, 255, 255, 128); //m_TextMeshPro.edgeWidth = .15f; m_TextMeshPro.isOverlay = true; //m_TextMeshPro.FaceColor = new Color32(255, 128, 0, 0); //m_TextMeshPro.EdgeColor = new Color32(0, 255, 0, 255); //m_TextMeshPro.FontMaterial.renderQueue = 4000; //m_TextMeshPro.CreateSoftShadowClone(new Vector2(1f, -1f)); m_textContainer = frameCounter.GetComponent<TextContainer>(); Set_FrameCounter_Position(AnchorPosition); last_AnchorPosition = AnchorPosition; }
public void UpdateTextControls(string text) { Clear(); // this shouldnt be here since the whole point of this label is to HAVE a target size, just for place holder tho. if (string.IsNullOrWhiteSpace(text)) return; scale = 1; Vector2 measuredFontSize = Font.MeasureString(text); Vector2 measureWordWrappedSize = GetWordWrappedSize(text, 1); // Pre-check // if no target size given, set size to measurestring size. if (targetSize == Vector2.Zero) { this.Size = measuredFontSize; textContainer = new TextContainer(measuredFontSize, text, color); Add(textContainer); } else if (measureWordWrappedSize.Y > targetSize.Y) { // if you cant word wrap with the current scale. RESIZE!! this.Size = targetSize; textContainer = new TextContainer(measuredFontSize, text, color); Add(textContainer); /* scale = Math.Min(targetSize.X / measuredFontSize.X, targetSize.Y / measuredFontSize.Y); textContainer = new TextContainer(measuredFontSize, text, color); //textContainer.Scale = scale; Add(textContainer);*/ } // Check 1 // See if font.X > this.X // word wrap // Check 2 // see if font.Y > this.Y // scale whole size by y. /* Vector2 fontSize = Font.MeasureString(text); if(fontSize.X > this.X) if (string.IsNullOrWhiteSpace(text)) this.Size = this.parent.Size; else this.Size = GetTextSize(); */ this.ControlSizeChange(lastSize); lastSize = this.Size; lastText = text; alignApplied = true; }
void OnEnable() { // Serialized Properties anchorPosition_prop = serializedObject.FindProperty("m_anchorPosition"); pivot_prop = serializedObject.FindProperty("m_pivot"); rectangle_prop = serializedObject.FindProperty("m_rect"); margins_prop = serializedObject.FindProperty("m_margins"); m_textContainer = (TextContainer)target; m_transform = Selection.activeGameObject.transform; // GUI SKINS // Find to location of the TextMesh Pro Asset Folder (as users may have moved it) string tmproAssetFolderPath = TMPro_EditorUtility.GetAssetLocation(); // GUI Skin if (EditorGUIUtility.isProSkin) mySkin = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/TMPro_DarkSkin.guiskin", typeof(GUISkin)) as GUISkin; else mySkin = AssetDatabase.LoadAssetAtPath(tmproAssetFolderPath + "/GUISkins/TMPro_LightSkin.guiskin", typeof(GUISkin)) as GUISkin; if (mySkin != null) { SectionLabel = mySkin.FindStyle("Section Label"); //GroupLabel = mySkin.FindStyle("Group Label"); //SquareAreaBox85G = mySkin.FindStyle("Square Area Box (85 Grey)"); } /* if (m_visualHelper == null) { m_visualHelper = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform; m_visualHelper.localScale = new Vector3(0.25f, 0.25f, 0.25f); } */ }
// moves an endpoint forward a certain number of units. // the endpoint is just an index into the text so it could represent either // the endpoint. private int MoveEndpointForward(int index, TextUnit unit, int count, out int moved) { switch (unit) { case TextUnit.Character: { int limit = _provider.GetTextLength() ; ValidateEndpoints(); moved = Math.Min(count, limit - index); index = index + moved; index = index > limit ? limit : index; } break; case TextUnit.Word: { string text = _provider.GetText(); ValidateEndpoints(); #if WCP_NLS_ENABLED // use the same word breaker as Avalon Text. WordBreaker breaker = new WordBreaker(); TextContainer container = new TextContainer(text); TextNavigator navigator = new TextNavigator(index, container); // move forward one word break for each count for (moved = 0; moved < count && index < text.Length; moved++) { if (!breaker.MoveToNextWordBreak(navigator)) break; } index = navigator.Position; #else for (moved = 0; moved < count && index < text.Length; moved++) { for (index++; !AtWordBoundary(text, index); index++) ; } #endif } break; case TextUnit.Line: { // figure out what line we are on. if we are in the middle of a line and // are moving left then we'll round up to the next line so that we move // to the beginning of the current line. int line = _provider.LineFromChar(index); // limit the number of lines moved to the number of lines available to move // Note lineMax is always >= 1. int lineMax = _provider.GetLineCount(); moved = Math.Min(count, lineMax - line - 1); if (moved > 0) { // move the endpoint to the beginning of the destination line. index = _provider.LineIndex(line + moved); } else if (moved == 0 && lineMax == 1) { // There is only one line so get the text length as endpoint index = _provider.GetTextLength(); moved = 1; } } break; case TextUnit.Paragraph: { // just like moving words but we look for paragraph boundaries instead of // word boundaries. string text = _provider.GetText(); ValidateEndpoints(); for (moved = 0; moved < count && index < text.Length; moved++) { for (index++; !AtParagraphBoundary(text, index); index++) ; } } break; case TextUnit.Format: case TextUnit.Page: case TextUnit.Document: { // since edit controls are plain text moving one uniform format unit will // take us all the way to the end of the document, just like // "pages" and document. int limit = _provider.GetTextLength(); ValidateEndpoints(); // we'll move 1 format unit if we aren't already at the end of the // document. Otherwise, we won't move at all. moved = index < limit ? 1 : 0; index = limit; } break; default: throw new System.ComponentModel.InvalidEnumArgumentException("unit", (int)unit, typeof(TextUnit)); } return index; }
void ITextRangeProvider.ExpandToEnclosingUnit(TextUnit unit) { Misc.SetFocus(_provider._hwnd); switch (unit) { case TextUnit.Character: // if it is a degenerate range then expand it to be one character. // otherwise, leave it as it is. if (Start == End) { int moved; End = MoveEndpointForward(End, TextUnit.Character, 1, out moved); } break; case TextUnit.Word: { // this works same as paragraph except we look for word boundaries instead of paragraph boundaries. // get the text so we can figure out where the boundaries are string text = _provider.GetText(); ValidateEndpoints(); #if WCP_NLS_ENABLED // use the same word breaker that Avalon Text uses. WordBreaker breaker = new WordBreaker(); TextContainer container = new TextContainer(text); // if the starting point of the range is not already at a word break // then move it backwards to the nearest word break. TextNavigator startNavigator = new TextNavigator(Start, container); if (!breaker.IsAtWordBreak(startNavigator)) { breaker.MoveToPreviousWordBreak(startNavigator); Start = startNavigator.Position; } // if the range is degenerate or the ending point of the range is not already at a word break // then move it forwards to the nearest word break. TextNavigator endNavigator = new TextNavigator(End, container); if (Start==End || !breaker.IsAtWordBreak(endNavigator)) { breaker.MoveToNextWordBreak(endNavigator); End = endNavigator.Position; } #else // move start left until we reach a word boundary. for (; !AtWordBoundary(text, Start); Start--) ; // move end right until we reach word boundary (different from Start). End = Math.Min(Math.Max(End, Start + 1), text.Length); for (; !AtWordBoundary(text, End); End++) ; #endif } break; case TextUnit.Line: { if (_provider.GetLineCount() != 1) { int startLine = _provider.LineFromChar(Start); int endLine = _provider.LineFromChar(End); MoveTo(_provider.LineIndex(startLine), _provider.LineIndex(endLine + 1)); } else { MoveTo(0, _provider.GetTextLength()); } } break; case TextUnit.Paragraph: { // this works same as paragraph except we look for word boundaries instead of paragraph boundaries. // get the text so we can figure out where the boundaries are string text = _provider.GetText(); ValidateEndpoints(); // move start left until we reach a paragraph boundary. for (; !AtParagraphBoundary(text, Start); Start--); // move end right until we reach a paragraph boundary (different from Start). End = Math.Min(Math.Max(End, Start + 1), text.Length); for (; !AtParagraphBoundary(text, End); End++); } break; case TextUnit.Format: case TextUnit.Page: case TextUnit.Document: MoveTo(0, _provider.GetTextLength()); break; //break; default: throw new System.ComponentModel.InvalidEnumArgumentException("unit", (int)unit, typeof(TextUnit)); } }
IEnumerator Start() { if (BenchmarkType == 0) // TextMesh Pro Component { m_textMeshPro = gameObject.AddComponent<TextMeshPro>(); m_textContainer = GetComponent<TextContainer>(); m_textContainer.isAutoFitting = true; //m_textMeshPro.anchorDampening = true; if (TMProFont != null) m_textMeshPro.font = TMProFont; //m_textMeshPro.font = Resources.Load("Fonts & Materials/IMPACT SDF", typeof(TextMeshProFont)) as TextMeshProFont; // Make sure the IMPACT SDF exists before calling this... //m_textMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/IMPACT SDF", typeof(Material)) as Material; // Same as above make sure this material exists. m_textMeshPro.fontSize = 48; m_textMeshPro.alignment = TextAlignmentOptions.Center; //m_textMeshPro.anchor = AnchorPositions.Center; m_textMeshPro.extraPadding = true; //m_textMeshPro.outlineWidth = 0.25f; //m_textMeshPro.fontSharedMaterial.SetFloat("_OutlineWidth", 0.2f); //m_textMeshPro.fontSharedMaterial.EnableKeyword("UNDERLAY_ON"); //m_textMeshPro.lineJustification = LineJustificationTypes.Center; //m_textMeshPro.enableWordWrapping = true; //m_textMeshPro.lineLength = 60; //m_textMeshPro.characterSpacing = 0.2f; //m_textMeshPro.fontColor = new Color32(255, 255, 255, 255); m_material01 = m_textMeshPro.font.material; m_material02 = Resources.Load("Fonts & Materials/ARIAL SDF BEVEL", typeof(Material)) as Material; // Make sure the IMPACT SDF exists before calling this... } else if (BenchmarkType == 1) // TextMesh { m_textMesh = gameObject.AddComponent<TextMesh>(); if (TextMeshFont != null) { m_textMesh.font = TextMeshFont; m_textMesh.GetComponent<Renderer>().sharedMaterial = m_textMesh.font.material; } else { m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font; m_textMesh.GetComponent<Renderer>().sharedMaterial = m_textMesh.font.material; } m_textMesh.fontSize = 48; m_textMesh.anchor = TextAnchor.MiddleCenter; //m_textMesh.color = new Color32(255, 255, 0, 255); } for (int i = 0; i <= 1000000; i++) { if (BenchmarkType == 0) { m_textMeshPro.SetText(label01, i % 1000); if (i % 1000 == 999) m_textMeshPro.fontSharedMaterial = m_textMeshPro.fontSharedMaterial == m_material01 ? m_textMeshPro.fontSharedMaterial = m_material02 : m_textMeshPro.fontSharedMaterial = m_material01; } else if (BenchmarkType == 1) m_textMesh.text = label02 + (i % 1000).ToString(); yield return null; } yield return null; }
// moves an endpoint backward a certain number of units. // the endpoint is just an index into the text so it could represent either // the endpoint. private int MoveEndpointBackward(int index, TextUnit unit, int count, out int moved) { switch (unit) { case TextUnit.Character: { int limit = _provider.GetTextLength(); ValidateEndpoints(); int oneBasedIndex = index + 1; moved = Math.Max(count, -oneBasedIndex); index = index + moved; index = index < 0 ? 0 : index; } break; case TextUnit.Word: { string text = _provider.GetText(); ValidateEndpoints(); #if WCP_NLS_ENABLED // use the same word breaker as Avalon Text. WordBreaker breaker = new WordBreaker(); TextContainer container = new TextContainer(text); TextNavigator navigator = new TextNavigator(index, container); // move backward one word break for each count for (moved = 0; moved > count && index > 0; moved--) { if (!breaker.MoveToPreviousWordBreak(navigator)) break; } index = navigator.Position; #else for (moved = 0; moved > count && index > 0; moved--) { for (index--; !AtWordBoundary(text, index); index--) ; } #endif } break; case TextUnit.Line: { // Note count < 0. // Get 1-based line. int line = _provider.LineFromChar(index) + 1; int lineMax = _provider.GetLineCount(); // Truncate the count to the number of available lines. int actualCount = Math.Max(count, -line); moved = actualCount; if (actualCount == -line) { // We are moving by the maximum number of possible lines, // so we know the resulting index will be 0. index = 0; // If a line other than the first consists of only "\r\n", // you can move backwards past this line and the position changes, // hence this is counted. The first line is special, though: // if it is empty, and you move say from the second line back up // to the first, you cannot move further; however if the first line // is nonempty, you can move from the end of the first line to its // beginning! This latter move is counted, but if the first line // is empty, it is not counted. // Recalculate the value of "moved". // The first line is empty if it consists only of // a line separator sequence. bool firstLineEmpty = ((lineMax > 1 && _provider.LineIndex(1) == _lineSeparator.Length) || lineMax == 0); if (moved < 0 && firstLineEmpty) { ++moved; } } else // actualCount > -line { // Move the endpoint to the beginning of the following line, // then back by the line separator length to get to the end // of the previous line, since the Edit control has // no method to get the character index of the end // of a line directly. index = _provider.LineIndex(line + actualCount) - _lineSeparator.Length; } } break; case TextUnit.Paragraph: { // just like moving words but we look for paragraph boundaries instead of // word boundaries. string text = _provider.GetText(); ValidateEndpoints(); for (moved = 0; moved > count && index > 0; moved--) { for (index--; !AtParagraphBoundary(text, index); index--) ; } } break; case TextUnit.Format: case TextUnit.Page: case TextUnit.Document: { // since edit controls are plain text moving one uniform format unit will // take us all the way to the beginning of the document, just like // "pages" and document. // we'll move 1 format unit if we aren't already at the beginning of the // document. Otherwise, we won't move at all. moved = index > 0 ? -1 : 0; index = 0; } break; default: throw new System.ComponentModel.InvalidEnumArgumentException("unit", (int)unit, typeof(TextUnit)); } return index; }