public ProceduralTextWindow(GameObject parent, string textToDisplay, ProceduralTextWindowDefinition ProceduralTextWindowDefinition, ProceduralTextParametersV2 ProceduralTextParametersV2 = null) { this.ProceduralTextWindowDefinition = ProceduralTextWindowDefinition; this.ProceduralTextWindowGameObject = new ProceduralTextWindowGameObject(parent, ProceduralTextWindowDefinition); this.ProceduralText = new ProceduralText(textToDisplay, ProceduralTextWindowDefinition.GeneratedTextDimensionsComponent, this.ProceduralTextWindowGameObject.TextComponent, ProceduralTextParametersV2); this.ElapsedTime = 0f; }
public ProceduralTextWindowGameObject(GameObject parent, ProceduralTextWindowDefinition ProceduralTextWindowDefinition) { this.RootGameObject = new GameObject("TextWindowRoot", typeof(RectTransform)); this.RootGameObject.transform.parent = parent.transform; this.ContentSizeFitter = this.RootGameObject.AddComponent <ContentSizeFitter>(); this.ContentSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; this.ContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; this.RootHorizontalLayoutGroup = this.RootGameObject.AddComponent <HorizontalLayoutGroup>(); this.RootHorizontalLayoutGroup.childControlHeight = false; this.RootHorizontalLayoutGroup.childControlWidth = false; this.RootHorizontalLayoutGroup.childScaleHeight = true; this.RootHorizontalLayoutGroup.childScaleWidth = true; this.RootHorizontalLayoutGroup.childAlignment = TextAnchor.MiddleCenter; this.ApplyHorizontalLayoutGroupData(this.RootHorizontalLayoutGroup, ProceduralTextWindowDefinition.ProceduralTextWindowMargins); //initialize image var targetImage = this.ContentSizeFitter.gameObject.AddComponent <Image>(); this.CopyImageComponent(ProceduralTextWindowDefinition.BackgroundImagePrefab, targetImage); this.TextParentObject = new GameObject("TextParent", typeof(RectTransform)); this.TextParentObject.transform.parent = this.RootHorizontalLayoutGroup.transform; this.TextGameObject = new GameObject("TextObject", typeof(RectTransform)); this.TextGameObject.transform.parent = this.TextParentObject.transform; //text object is upper left corner var textGameObjectRectTransform = this.TextGameObject.transform as RectTransform; textGameObjectRectTransform.anchorMax = new Vector2(0, 1); textGameObjectRectTransform.anchorMin = new Vector2(0, 1); textGameObjectRectTransform.pivot = new Vector2(0, 1); this.TextCanvasRenderer = this.TextGameObject.AddComponent <CanvasRenderer>(); this.TextComponent = this.TextGameObject.AddComponent <Text>(); this.CopyTextComponent(ProceduralTextWindowDefinition.TextPrefabDefinition, this.TextComponent); RectTransformHelper.SetPivot(this.RootGameObject.transform as RectTransform, ProceduralTextWindowDefinition.WindowPivot); }
public DisplayAllTextWindow(GameObject parent, string textToDisplay, ProceduralTextWindowDefinition ProceduralTextWindowDefinition, ProceduralTextParametersV2 ProceduralTextParametersV2 = null) { this.ProceduralTextWindow = new ProceduralTextWindow(parent, textToDisplay, ProceduralTextWindowDefinition, ProceduralTextParametersV2); this.ProceduralTextWindow.GenerateAndDisplayAllText(); }