I want to be able to embed control icons in my text.

Currently I have a static method I can call that gives me back the current image for a control action I have requested.

This takes into account kb/gamepad usage, and custom control mapping that the player has configured.

I cant see a way to embed this into a text dialog, or anything else with any of the text commands.
  • Hm, I haven't tested it, but you should be able to do this via resources icon text codes. E.g. if your icon is named Armor01, the text code would be #resources.iconArmor01#.
    Put that into a string variable and use the variable to add the icon to your text - if you need to swap out the icons, just change the text code in the variable.

    For this to work, you need to have the icons in a Resources folder in your project.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I will try this out
  • Ok so, this sort of works, but because the text is only interpreted once on displaying (in MultiContent.cs), it doesnt update while the icon is displayed. So if i switch from gamepad to kb/mouse controls, id like that icon to update immediately.

    Now I could do it if I load a prefab from the resources folder, because I can manage the lifecycle internally to the prefab.

    The code for this wouldnt need to be much different from the code for an icon, just it would need to cast to a gameobject instead, i expect.
  • So I got it to work using Graphiucs.CopyTexture based on what is the current control scheme. The issue is that I dont have a good way to tell which ones are displaying currently, so I have to change the entire set of control icons every time the control scheme changes. Im doing one image per frame currently, but there is a noticable delay on the images updating (obviously).

    Any suggestions?
  • Yeah, I wouldn't do that this way ...

    Where is the text with the changing icon text codes displayed? E.g. if it's in an Information HUD, you could use the Update By Variables option to recalculate the HUD when global variables change (e.g. the string variables for your icons).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Its in dialogue boxes, for example if i want to have a description of the buttons used for a certain action.

    Another option would be a conditional text code where i could do something like

    #if SomeObject.SomeStaticFunctionThatReturnsBool()#true_data#else#false_data#endif#

    For example.

    I'd be happy to write a scanner/parser for you :P (if i can remember my old compilers class, that is)
  • A conditional text code would still have been processed before and wouldn't change if the dialogue isn't updated.

    I'd recommend using an Information HUD for displaying this - e.g. using variables in your display condition to control when to show it. Using the Update By Variables option would automatically udpate it on changes :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.