// create a single rebinding row private GameObject createRebindRow(PlayerAction action) { RebindItem row = Instantiate(Template.gameObject, transform, true).GetComponent <RebindItem>(); row.gameObject.SetActive(true); row.ActionName.text = action.Name; row.ActionAButton.GetComponentInChildren <Text>().text = getBindingName(action.Bindings, 0); row.ActionBButton.GetComponentInChildren <Text>().text = getBindingName(action.Bindings, 1); row.ActionAButton.onClick.AddListener(() => rebindAction(action, row.ActionAButton, getBindingSource(action.Bindings, 0))); row.ActionBButton.onClick.AddListener(() => rebindAction(action, row.ActionBButton, getBindingSource(action.Bindings, 1))); row.gameObject.SetActive(false); return(row.gameObject); }
private void setupTemplate() { if (!Template) { Debug.LogError("The template is not assigned. Please give a template for this to work."); _validTemplate = false; return; } GameObject templateGo = Template.gameObject; templateGo.SetActive(true); RebindItem rebindItem = templateGo.AddComponent <RebindItem>(); rebindItem.ActionName = TemplateActionName; rebindItem.ActionAButton = TemplateActionAButton; rebindItem.ActionBButton = TemplateActionBButton; templateGo.SetActive(false); }