public override void SceneLoadLocalDone(string map) { if (map == "Game") { WorldItemManager = GameObject.Find("GameManager").GetComponent <WorldItemManager>(); } }
void Start () { _world_item_manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent<WorldItemManager>(); _amount_panel = GameObject.Find("Amount Panel"); _amt_input_field = GameObject.Find("Amount InputField"); _error_text = _amount_panel.transform.Find("Error Text").GetComponent<Text>(); _amount_panel.SetActive(false); }
void Awake() { if (Instance == null) //Check if instance already exists Instance = this; //if not, set instance to this else if (Instance != this) //If instance already exists and it's not this: Destroy(gameObject); //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a WorldItemManager. DontDestroyOnLoad(gameObject); //Sets this to not be destroyed when reloading scene }
/*--------------------------------------------------------------------------- -- FUNCTION: Awake -- DATE: 15/03/2016 -- REVISIONS: -- DESIGNER: Joseph Tam-Huang -- PROGRAMMER: Joseph Tam-Huang -- INTERFACE: void Awake() -- RETURNS: void -- NOTES: -- Called once during the lifetime of the script, create one and only one -- instance of the WorldItemManager. Enforces the singleton pattern. -----------------------------------------------------------------------------*/ void Awake() { if (Instance == null) Instance = this; else if (Instance != this) Destroy(gameObject); DontDestroyOnLoad(gameObject); }
/*--------------------------------------------------------------------------------------- * -- FUNCTION: Start * -- DATE: 10/03/2016 * -- REVISIONS: * -- DESIGNER: Joseph Tam-Huang * -- PROGRAMMER: Joseph Tam-Huang * -- INTERFACE: void Start() * -- RETURNS: void * -- NOTES: * -- Retrieves the WorldItemManager script, the AmountPanel GameObject, the Amount * -- InputField GameObject and the Error Text object. * -- Deactivates the AmountPanel GameObject. * ----------------------------------------------------------------------------------------*/ void Start() { _world_item_manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <WorldItemManager>(); _amount_panel = GameObject.Find("Amount Panel"); _amt_input_field = GameObject.Find("Amount InputField"); _error_text = _amount_panel.transform.Find("Error Text").GetComponent <Text>(); _amount_panel.SetActive(false); }
/* * Retrieve the player id */ void Start() { gameObject.layer = LayerMask.NameToLayer("HiddenThings"); gameObject.transform.Translate(0, 0, 9); // set material to stencil masked gameObject.GetComponent<SpriteRenderer>().material = (Material)Resources.Load("Stencil_01_Diffuse Sprite", typeof(Material)); _player_id = GameData.MyPlayer.PlayerID; _world_item_manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent<WorldItemManager>(); _tooltip = GameObject.Find("Inventory").GetComponent<Tooltip>(); }
/* * Retrieves the ItemMenu game object and sets it to inactive. * Retrieves the WorldItemManager script. */ void Start () { _item_menu = GameObject.Find("Item Menu"); _item_menu.SetActive(false); _world_item_manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent<WorldItemManager>(); _amount_panel = GameObject.Find("Inventory").GetComponent<AmountPanel>(); _use_btn = _item_menu.transform.FindChild("Use Button").gameObject; _item_menu_rt = _item_menu.GetComponent<RectTransform>(); _item_menu_height = _item_menu_rt.rect.height; }
/*--------------------------------------------------------------------------------------- * -- FUNCTION: Start * -- DATE: 05/03/2016 * -- REVISIONS: * -- DESIGNER: Joseph Tam-Huang * -- PROGRAMMER: Joseph Tam-Huang * -- INTERFACE: void Start() * -- RETURNS: void * -- NOTES: * -- Retrieves the ItemMenu game object and sets it to inactive. * -- Retrieves the WorldItemManager script. * ----------------------------------------------------------------------------------------*/ void Start() { _item_menu = GameObject.Find("Item Menu"); _item_menu.SetActive(false); _world_item_manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <WorldItemManager>(); _amount_panel = GameObject.Find("Inventory").GetComponent <AmountPanel>(); _use_btn = _item_menu.transform.FindChild("Use Button").gameObject; _item_menu_rt = _item_menu.GetComponent <RectTransform>(); _item_menu_height = _item_menu_rt.rect.height; }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } }
private void Awake() { if (instance == null || instance == this) { instance = this; } else { UnityEngine.Debug.LogWarning("Removed a second instance of WorldItemManager"); Destroy(this); } }
/*--------------------------------------------------------------------------------------- * -- FUNCTION: Start * -- DATE: 05/03/2016 * -- REVISIONS: * -- DESIGNER: Joseph Tam-Huang * -- PROGRAMMER: Joseph Tam-Huang * -- INTERFACE: void Start() * -- RETURNS: void * -- NOTES: * -- Retrieves the HiddenThings layer mask. * -- Retrieves the WorldItemManager script. * -- Retrieves the Tooltip GameObject. * ----------------------------------------------------------------------------------------*/ void Start() { gameObject.layer = LayerMask.NameToLayer("HiddenThings"); gameObject.transform.Translate(0, 0, 9); // set material to stencil masked gameObject.GetComponent <SpriteRenderer>().material = (Material)Resources.Load("Stencil_01_Diffuse Sprite", typeof(Material)); _player_id = GameData.MyPlayer.PlayerID; _world_item_manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <WorldItemManager>(); _tooltip = GameObject.Find("Inventory").GetComponent <Tooltip>(); }
/*--------------------------------------------------------------------------- * -- FUNCTION: Awake * -- DATE: 15/03/2016 * -- REVISIONS: * -- DESIGNER: Joseph Tam-Huang * -- PROGRAMMER: Joseph Tam-Huang * -- INTERFACE: void Awake() * -- RETURNS: void * -- NOTES: * -- Called once during the lifetime of the script, create one and only one * -- instance of the WorldItemManager. Enforces the singleton pattern. * -----------------------------------------------------------------------------*/ void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }