Make Methods virtual & extend Game Manager

Help, support and information for our Game Framework Unity Asset.
If posting about the assets in the extras bundle then please use the appropriate forum.
Post Reply
Tmmm
Posts: 2
Joined: Wed Jul 24, 2019 3:37 pm

Make Methods virtual & extend Game Manager

Post by Tmmm » Wed Jul 24, 2019 3:50 pm

Hi!

I just started to work with the Game Framework, and I like it!

Is there a chance to make most of the methods virtual? Then we can override them in our own implementations.
For example: I made an script to play sound on button click, but I wanted the Start function in that script to setup the audio source.

See this example:

Code: Select all

[RequireComponent(typeof(Button))]
[RequireComponent(typeof(AudioSource))]
public class OnButtonClickPlayAudio : OnButtonClick {
    public float Volume = 0.5f;
    private AudioSource audioSource;

    protected override void Start() {
        base.Start();
        audioSource = GetComponent<AudioSource>();
        audioSource.volume = Volume;

    }

    public override void OnClick() {
        audioSource.Play();
    }
}
And also is it possable to extend the GameManger like this (I tried this, but its not working):

Code: Select all

public class GameManagerBlockShield : GameManager {
Thanks in advance!

Tom

mahewitt
Site Admin
Posts: 273
Joined: Thu May 05, 2016 8:06 pm

Re: Make Methods virtual & extend Game Manager

Post by mahewitt » Thu Jul 25, 2019 1:00 pm

Hi,

I can certainly make a note of this for the future as I guess it should be ok in most cases.

If you need to make any specific changes then feel free to submit a pull request at https://github.com/FlipWebApps/GameFramework so you don't have to re-include them when future updates are released.

Not sure about extending GameManager - what is the error you are getting? Could creating a new component be an option rather than inheriting?

Mark

Tmmm
Posts: 2
Joined: Wed Jul 24, 2019 3:37 pm

Re: Make Methods virtual & extend Game Manager

Post by Tmmm » Wed Jul 31, 2019 12:21 pm

I can certainly make a note of this for the future as I guess it should be ok in most cases.

If you need to make any specific changes then feel free to submit a pull request at https://github.com/FlipWebApps/GameFramework so you don't have to re-include them when future updates are released.
Thanks!
Not sure about extending GameManager - what is the error you are getting? Could creating a new component be an option rather than inheriting?
If I extend it, the custom editor scripts aren't working. So I created an specific Game manager for my game as you said.

Thanks for your response.

Tom

mahewitt
Site Admin
Posts: 273
Joined: Thu May 05, 2016 8:06 pm

Re: Make Methods virtual & extend Game Manager

Post by mahewitt » Mon Aug 05, 2019 7:43 pm

Ok. Thanks for letting me know. Always possible there might have been side affects. I will keep this in mind for the future though to make things virtual where possible.

Post Reply