Exemple #1
0
        public override void PreRender()
        {
            if (IsEditing)
            {
                // cursor blinks every 0.5s
                float dt = FPlatform.RealTime() - start_active_time;
                cursor.SetVisible((int)(2 * dt) % 2 == 0);

                // DO NOT DO THIS EVERY FRAME!!!
                BoxModel.MoveTo(cursor, this.Bounds2D.CenterLeft, -Height * 0.1f);
                Vector2f cursorPos = textMesh.TextObject.GetCursorPosition(cursor_position);
                BoxModel.Translate(cursor, cursorPos);
            }
            else
            {
                cursor.SetVisible(false);
            }
        }
Exemple #2
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = new GameObject(UniqueNames.GetNext("HUDTextEntry"));
            Mesh mesh = MeshGenerators.CreateTrivialRect(Width, Height, MeshGenerators.UVRegionType.FullUVSquare);

            backgroundMaterial       = MaterialUtil.CreateFlatMaterialF(BackgroundColor);
            activeBackgroundMaterial = MaterialUtil.CreateFlatMaterialF(ActiveBackgroundColor);
            bgMesh = AppendMeshGO("background", mesh, backgroundMaterial, entry);
            bgMesh.transform.Rotate(Vector3.right, -90.0f); // ??

            BoxPosition horzAlign = BoxPosition.CenterLeft;

            if (AlignmentHorz == HorizontalAlignment.Center)
            {
                horzAlign = BoxPosition.Center;
            }
            else if (AlignmentHorz == HorizontalAlignment.Right)
            {
                horzAlign = BoxPosition.CenterRight;
            }

            textMesh = GameObjectFactory.CreateTextMeshGO(
                "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset);

            Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign);

            BoxModel.Translate(textMesh, Vector2f.Zero, toPos);

            AppendNewGO(textMesh, entry, false);

            cursor = GameObjectFactory.CreateRectangleGO("cursor", Height * 0.1f, Height * 0.8f, Colorf.VideoBlack, false);
            BoxModel.Translate(cursor, Vector2f.Zero, this.Bounds2D.CenterLeft, -Height * 0.1f);
            cursor.RotateD(Vector3f.AxisX, -90.0f);
            AppendNewGO(cursor, entry, false);
            cursor.SetVisible(false);
        }