Forum rules - please read before posting.

Change an AC label's Font at runtime.

edited July 2016 in Technical Q&A
Hi! I was just wondering how you would go about changing a label's font at runtime? And I mean an AC Label. I'd like to be able to change the font at runtime for different effects (like for hotspots, if its something creepy, put a creepy looking font for the hotspot name, or if its a whimsical object or place, to put an alert message with a cheerful, comical font, etc.)

Anyways, for something as simple as an alert text, I'd really like to stick to using AC's labels if possible. So if anyone can advice me on how to do this, I'll greatly appreciate it.

Comments

  • Only through code.  You can access a MenuElement's class with:

    AC.PlayerMenus.GetElementWithName ("MyMenu", "MyElement");

    The MenuElement class, from which all elements derive, has a font variable that you can change.
  • edited July 2016
    Thanks! that's exactly what I wanted to know. Then, I could make an Action that changes the font, right? Anyways, I'll give it a shot later today. Thanks for the info.  :)>-
  • hi! I had a follow up question. I'm using a global variable to store the text to be displayed in the GUI, that way I can use a single menu to display all my alerts. The only thing is, for the sake of modularity, I'd like to be able to provide that variable within the action itself (in case I make optional variables or if I move the scripts to other projects). Currently I'm getting the ID as a string and converting it to an int. But I'd really wish if I could use the same method you use in the rest of your actions, which shows a drop down menu with all the vars. How would I go about adding that to my action? If it's not too complicated, then I would love to know, just to make the action nicer to use.
  • edited July 2016
    Ok, so it's working but at the same time there's an issue with storing the data.

    I went ahead and made an Action which can show an alert using an existing AC menu (any, if you change the default names). You can change the font, and it even has a duration in case you want to automatically stop the message after a certain amount of time (similar to The Dialogue system's). Well, the action works alright, but then I made some Action list assets and saved the information I want them to display every time that I use them (like for different props or places). But, unfortunately, the data gets erased and returns to defaults every time I close and restart unity... 

    So, how do you make sure the fields will be remembered even in Action list assets? I saw in the tutorials that you can add constant IDs to GameObjects, but how in tarnation do you do the same with strings and bools and floats? FieldToID and IDToField errors out on me saying the data is not a UnityEngine.Behaviour... How do you get the rest of the fields in your Actions to save, if they're not game objects?

    Edit: I don't think I'll ever need to use parameters on the action, but do I need to have them active so the fields are saved? or does it needs to be something like a constant ID?

    Edit: Never mind, I go it. They were not saving because they were private variables... I don't want to nag but I wish that was explicitly mentioned in the tutorial. I saw you use public variables in it but I didn't expect it to be a requirement...
  • Fair point - tutorial updated.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.