private GameObject CreateButton(GameObject prefab, string name, Rewired.UI.UIAnchor anchor, UIPivot pivot, Vector2 offset, out ButtonInfo buttonInfo) { buttonInfo = null; if (prefab == null) { return(null); } GameObject gameObject = UITools.InstantiateGUIObject <ButtonInfo>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset); if (gameObject == null) { return(null); } buttonInfo = gameObject.GetComponent <ButtonInfo>(); UnityEngine.UI.Button component = gameObject.GetComponent <UnityEngine.UI.Button>(); if (component == null) { UnityEngine.Debug.Log("Button prefab is missing Button component!"); return(null); } if (buttonInfo == null) { UnityEngine.Debug.Log("Button prefab is missing ButtonInfo component!"); return(null); } return(gameObject); }
public void CreateButton(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string buttonText, UnityAction confirmCallback, UnityAction cancelCallback, bool setDefault) { if (prefab == null) { return; } ButtonInfo buttonInfo; GameObject gameObject = this.CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo); if (gameObject == null) { return; } UnityEngine.UI.Button component = gameObject.GetComponent <UnityEngine.UI.Button>(); if (confirmCallback != null) { component.onClick.AddListener(confirmCallback); } CustomButton customButton = component as CustomButton; if (cancelCallback != null && customButton != null) { customButton.CancelEvent += cancelCallback; } if (buttonInfo.text != null) { buttonInfo.text.text = buttonText; } if (setDefault) { this._defaultUIElement = gameObject; } }
public void AddContentText(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { Text item = null; this.CreateText(prefab, ref item, "Content Text", pivot, anchor, offset); this._contentText.Add(item); }
private void CreateImage(GameObject prefab, string name, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { if (prefab == null || this.content == null) { return; } UITools.InstantiateGUIObject <Image>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset); }
private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { if (prefab == null || this.content == null) { return; } if (textComponent != null) { UnityEngine.Debug.LogError("Window already has " + name + "!"); return; } GameObject gameObject = UITools.InstantiateGUIObject <Text>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset); if (gameObject == null) { return; } textComponent = gameObject.GetComponent <Text>(); }
public void AddContentImage(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string text) { this.AddContentImage(prefab, pivot, anchor, offset); }
public void AddContentImage(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { this.CreateImage(prefab, "Image", pivot, anchor, offset); }
public void AddContentText(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string text) { this.AddContentText(prefab, pivot, anchor, offset); this.SetContentText(text, this._contentText.Count - 1); }