예제 #1
0
        public static Entity SpawnText(EntityManager EntityManager, Entity parent, string text,
                                       float3 positionOffset, Color color, float fontSizer = 0.014f) // float2 iconSize,
        {
            float2     fontSize   = new float2(fontSizer, fontSizer);
            RenderText renderText = new RenderText();

            //renderText.alignment = 1;
            renderText.fontSize = fontSize.x;
            renderText.SetColor(color);
            renderText.SetText(text);
            float2 panelSize  = renderText.GetPanelSize();
            Entity textEntity = SpawnVisualElement(
                EntityManager,
                parent,
                positionOffset,         // + ((new float3(iconSize.x, -iconSize.y, 0) / 2f) - new float3(0, -fontSize.y, 0) / 2f),
                panelSize,
                null,
                null);

            // should get size from text when set - it will set size depending on individual font sizes

            /*if (isCentred == 1)
             * {
             *  renderText.offsetX = -panelSize.x * 0.5f;// uiDatam.skillbarIconSize / 2f;
             * }*/
            EntityManager.AddComponentData(textEntity, renderText);
            return(textEntity);
        }
예제 #2
0
        public static Entity SpawnButtonWithText(EntityManager EntityManager, Entity panelUI, float3 position, float buttonFontSize, string text,
                                                 Material buttonMaterial, Color buttonColor, Color textColor)
        {
            //Childrens children = new Childrens { };
            //children.children = new BlitableArray<Entity>(1, Unity.Collections.Allocator.Persistent);
            //float buttonFontSize = 0.01f;
            //RenderTextSystem.SetLetterColor(EntityManager, button, Color.green);
            //children.children[0] = button;
            //EntityManager.AddComponentData(panelUI, children);
            Entity button = SpawnButton(
                EntityManager,
                panelUI,
                position,
                (new float2(buttonFontSize * text.Length * 1f, buttonFontSize)),
                null,
                buttonMaterial);

            SetEntityColor(EntityManager, button, buttonColor);
            RenderText buttonText = new RenderText {
            };

            buttonText.fontSize = buttonFontSize;
            buttonText.SetText(text);
            buttonText.SetColor(textColor);
            EntityManager.AddComponentData(button, buttonText);
            return(button);
        }
예제 #3
0
        protected override void OnSpawnedPanel(Entity character, Entity panelUI, object spawnData)
        {
            var dialogueTree = Bootstrap.instance.data.dialogues[0].dialogueTree;
            //int startingDialogueID = dialogueTree.id;
            //DialogueDatam dialogueTree = meta[startingDialogueID];
            var        branch     = dialogueTree.branches[0];
            float      fontSize   = 0.03f;
            RenderText renderText = new RenderText
            {
                fontSize = fontSize,
                offsetX  = ((-branch.speech.Length - 1f) / 2f) * fontSize
            };

            renderText.SetColor(Color.blue);
            DialogueUI dialogueUI = new DialogueUI
            {
                treeID           = dialogueTree.id,
                timePerLetterMin = 0.07f,
                timePerLetterMax = 0.21f
            };

            dialogueUI.RandomizeCooldown();
            dialogueUI.SetText(branch.speech, ref renderText);
            //UnityEngine.Debug.LogError("Testing dialogue - self talking: " + dialogueTree.data[0].speech);
            World.EntityManager.AddComponentData(panelUI, dialogueUI);
            World.EntityManager.AddComponentData(panelUI, renderText);
            byte uiIndex = ((byte)((int)PlayerUIType.DialogueUI));

            World.EntityManager.SetComponentData(panelUI, new PanelUI
            {
                id          = uiIndex,
                characterID = World.EntityManager.GetComponentData <ZoxID>(character).id,
                size        = new float2((branch.speech.Length) * (fontSize * 1.1f), fontSize),
                dirty       = 1,
                orbitDepth  = uiDatam.orbitDepth,
                anchor      = (byte)UIAnchoredPosition.Middle
            });
            Childrens children = new Childrens {
            };

            World.EntityManager.AddComponentData(panelUI, children);
        }