Hot answers tagged

17

Dialogue could be provided in any form/structure you wish it depends on how you parse the information that makes the difference. I will provide you with a basic XML syntax to get you started without understanding your games structure or language I afraid i cant provide an implementation. <?xml version="1.0" encoding="UTF-8"?> <npcs> &...


10

I won't write the code for you, but I can put forth a conceptual path forward. Assuming your text is displayed in a string, it is possible to iterate through the character array that makes up that string. The goal here is to print each character individually (or however many at a time you want) separated by a delta time. When you think about it, this isn't ...


9

I think what you are looking for is something like following: GameObject CreateText(Transform canvas_transform, float x, float y, string text_to_print, int font_size, Color text_color) { GameObject UItextGO = new GameObject("Text2"); UItextGO.transform.SetParent(canvas_transform); RectTransform trans = UItextGO.AddComponent<RectTransform>(...


8

You need to use SpriteFont.MeasureString. Vector2 textSize = mySpriteFont.MeasureString("Hello World"); Vector2 center = textSize / 2; The x component of textSize represents the width of the measured string while the y component represents the height.


7

Given SpriteFont font; Do this: Vector2 size = font.MeasureString("Your String Here");


7

Here is a rather simple extension class that you can use. public static class GraphicExtensions { /// <summary> /// Fade methods forUI elements; /// </summary> /// <param name="g"></param> public static void FadeIn(this Graphic g) { g.GetComponent<CanvasRenderer>().SetAlpha(0f); g.CrossFadeAlpha(1f, ....


6

The way I handled this in my simple textbox UI element was to use a scissor rectangle (as Nicolas Bolas said while I was writing this :P). Here's the basic idea: First off, create a RasterizerState field in whatever class does the drawing of the text like so: RasterizerState _rasterizerState = new RasterizerState() { ScissorTestEnable = true }; You'll ...


6

You need to modify your model so that the UV (texture) coordinates place the texture at the correct location. It's possible that setting the texture address mode to clamp may (sort-of) solve your issue. But this also depends on your model having the correct UV coordinates to make it work. GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; (The ...


6

I'm using the freetype library (http://www.freetype.org/) to load glyphs from freetype fonts and then use bin packing to generate a glyph texture/atlas during runtime, similar to how freetype-gl does it (https://code.google.com/p/freetype-gl/). When the game is initialized, I generate a glyph atlas with the printable characters from the ASCII range. This ...


5

In the games I've worked on, we restricted the subset of characters used for Chinese, Japanese, and Korean (together referred to as CJK) to only those required to display the text in the game. In other words, we didn't attempt to cram in every possible character; we just took the database of CJK text from our localization teams, did a pass over it to find ...


5

In my engine, I use a dynamic vertex buffer for batching up text data (each character == 1 vertex) and do point-to-quad expansion in geometry shader. As far as I know, glVertex*, glNormal*, glTexCoord* are considered obsolete (like display lists) and are not recommended to use. This gives a comprehensive overview of various OpenGL-based text rendering ...


5

Although XML is more predictable, kinda have a defined structure and all that. I would go with scripts. Rolling your own language(if you have the time, but usually this is not the best choice), or even implementing one. There are LOTS of script languages out there, they're all nice, some examples: Squirrel, Lua, Angel Script, Python, and many many many ...


5

I got the same problem, try this instead of using public GUIText scoreText; Put using UnityEngine.UI; at the top of your .cs file and after that change the variable type from GUIText to just Text like this: public Text scoreText; Complete code for better example: using UnityEngine; using UnityEngine.UI; using System.Collections; public class ...


5

These are pre-localized strings, most likely. For localization, there will be a primary identifier (like $Spells) that is used to look-up the correct text in a big translation table loaded depending on the active language. These identifiers are also often used to help find the correct voice or texture for in-world elements. For instance, if a wall is ...


4

I think, without a library, this would require quite a few steps, but it is certainly possibly. First convert the letter to a polygon (look at the bitmap to polygon algorithms) and then that polygon to a set of triangles using a technique that supports holes in the polygon, see this wiki page. You now have a flat model built out of triangles. Now draw the ...


4

If you want to do it the old-fashioned way, then yes, you can use it in a grid. But if you want to use any kind of variable or half-width characters, like writing 5 instead of 5, then you'll need to get off the grid. The characters are all the same width anyway so if you're not using any non-Asian characters then it should align by itself. I don't think ...


4

You should generally prefer structured data (XML) over scripts at every opportunity. The biggest reason for this is tool support. You can make a dialog editor for a structured format, which supports internationalization, dialog branching, testing a debugging of dialog trees, deadend and infinite loop detection in trees, etc. For a script, the only thing ...


4

On further inspection it seems like it probably is 8 Bit Wonder, as @Alayric pointed out in the comments. Link: http://www.dafont.com/8bit-wonder.font The font they use on their website is called Edit Undo. Link: http://www.dafont.com/edit-undo.font


4

There's nothing particularly special in how font rendering is handled in OpenTK. OpenTK - among other things - contains an OpenGL wrapper. And as such any techniques you'd use to render text in OpenGL apply here, namely: Using bitmap fonts - loading font atlas texture and rendering textured quads. BMFont Using geometric primitives (triangles/quads) to ...


4

I have ran into this problem more often than I care to remember. First and foremost, there is no NullReferenceException in the script associated with "emptyTest". We know that for two reasons: We can clearly see that the reference has been assigned via the Inspector We only have one line of code, and as you confirm, it is successfully running. A ...


4

We just need to change Scale and layout to 100% in windows setting panel . And in advanced scaling setting I turn on "Let Windows try to fix apps so they're not blurry" . After that Unity UI problem is gone.


3

One thing I have seen often is highlighting key words like places, a macguffin to collect and key characters to talk to next. this allows a player who is just skimming to stop and reread the context consider having a fortuneteller character who gives more direct hints, just someone who will be always available to talk to maybe in the home town maybe ...


3

If you want to clip things to a certain region, you use the scissor box. It's a property of the GraphicsDevice: GraphicsDevice.ScissorTestEnable and either RenderState.ScissorRectangle pre-XNA 4.0 or RasterizerState.ScissorTestEnable in XNA 4.0. You don't need to measure text for it; just set the scissor box to the area you want to clip to. You can draw all ...


3

What's happening is you're clearing the screen after drawing the text. So this window.draw(text); window.clear(sf::Color::Green); should be this window.clear(sf::Color::Green); window.draw(text); If it still doesn't display anything, you definitely need to set a font!


3

Ok so to answer my own question, it turns out I'm an idiot and overlooked something really simple. The code in my question works perfectly, but I never set the text renderer's projection matrix. To make it work, in the resize method I added the following code: renderer.enable(gl, true); renderer.reshapeOrtho(width, height, 0.1f, 1000.0f); renderer.enable(gl,...


3

To turn off antialiasing, all you have to do is change your sampler state to SamplerState.PointClamp in your spriteBatch.Begin() call. Here's a short code example: spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, null)); // Draw text here using DrawString spriteBatch.End(); ...


3

This is one method of updating a ScrollBar (or anything) after changing the content of ScrollView Text and wanting to react to the new width/height of the text after it is rendered. Platform: Unity 4.6 / 5 (I'm using Unity 5, but I think I used all 4.6 components), C# There are a number of videos on how to create scrolling text views for fixed-content: ...


3

1 do you mean you want change the uitext dynamically? If you want to change it, first u have to attach your script to gameobject. Then bind your variables. Tutorials could be found here transform.gameObject.GetComponent<Text>().text = "123"; 2 If you want to create uitext which is not in Hierarchy beforehand. You could use GUI. GUI Label Put the ...


3

If you are looking for a quick&dirty solution for debugging, you can still use the old Unity 4 solution. Implement the OnGUI event of any MonoBehavior you have always active to call the GUI class to add some UI element to the current rendering frame. void OnGUI() { GUI.Label(new Rect(10, 10, 100, 20), "Hello World!"); } If you want to use the ...


3

I got stuck on this same thing in this tutorial. My fix was to assign the font material to the text component's material directly underneath where you change it red.


Only top voted, non community-wiki answers of a minimum length are eligible