Quick blog post on more work on the game I wrote about the other week. So I decided that before Christmas I wanted to get all the front end menus done. Then all that will be left for this game would be polish before release.
I am no artist which I think I have mentioned before so I went onto the unity asset store to find some good UI elements that would suit this game. I found these which are perfect for what I want. The pack contains hundreds of UI elements, animations, sounds, etc.
So I started working on the front screen that will contain the game title (I haven’t decided on this yet) and a big play button. Nothing else is really needed at this point, since there is no DLC paid for or otherwise (although I may have a mute sound button).
Since this pack comes with a set of animations for the UI element I decided to use them. However this presented a problem. I wanted the play button to be big and take up a lot of the screen space. But because the animations set the scale of the object this would override any scale I would set in the editor.
So I did a bit of digging and I couldn’t find anything where I could set the scale value and have that apply to each key frame of the animation. This left me with two options,
- Alter the key frames
- Write a script that would apply the scale after the animation has ticked over.
I didn’t want to alter the key frames of the animation as this would mean I would have to clone each animation if I wanted to keep the originals for future use.
So that left me with writing a script. Which is the method I went with.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Scale : MonoBehaviour
{
public Vector3 scale;
private void LateUpdate()
{
Vector3 localScale = transform.localScale;
localScale += scale;
transform.localScale = localScale;
}
}
This is hacky in my opinion hence the title of the blog, but it does work. There is a better way of doing this that I will update it later. For now I am focusing on finishing my other project first.
I hope you all have a great Christmas and New Year.
