Skip to content

Instantly share code, notes, and snippets.

@Juanini
Created May 11, 2018 23:27
Show Gist options
  • Save Juanini/817e8295deb4be0e1deb050e235a937e to your computer and use it in GitHub Desktop.
Save Juanini/817e8295deb4be0e1deb050e235a937e to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GameEventSystem;
public class MenuBase : MonoBehaviour {
public void onEnterScreen()
{
// Do basic logic for opening
preActive();
InitScreen();
Canvas aCanvas = gameObject.GetComponent<Canvas>();
aCanvas.worldCamera = Camera.main;
gameObject.SetActive(true);
postActive();
}
public virtual void onExitScreen()
{
// Do basic logic for closing
preDeactive();
gameObject.SetActive(false);
}
public void ShowMenu(int menu, bool closePrivous = true)
{
Hashtable hashParams = new Hashtable();
hashParams.Add(GameEventParam.SCREEN_TO_OPEN, menu);
GameEventManager.TriggerEvent(GameEvents.E_OPEN_SCREEN, hashParams);
}
public virtual void InitScreen () {}
public virtual void preActive () {}
public virtual void postActive () {}
public virtual void preDeactive() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment