Page 1 of 1

Make Methods virtual & extend Game Manager

Posted: Wed Jul 24, 2019 3:50 pm
by Tmmm
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

Re: Make Methods virtual & extend Game Manager

Posted: Thu Jul 25, 2019 1:00 pm
by mahewitt
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

Re: Make Methods virtual & extend Game Manager

Posted: Wed Jul 31, 2019 12:21 pm
by Tmmm
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

Re: Make Methods virtual & extend Game Manager

Posted: Mon Aug 05, 2019 7:43 pm
by mahewitt
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.