本文整理汇总了C#中UnityEngine.UI.Button类的典型用法代码示例。如果您正苦于以下问题:C# Button类的具体用法?C# Button怎么用?C# Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Button类属于UnityEngine.UI命名空间,在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
Transform PanelMessageContainer0 = transform.FindChild("PanelMessageContainer");
messageContainer = PanelMessageContainer0.GetComponent<RectTransform>();
Transform PanelSystemContainer00 = PanelMessageContainer0.FindChild("PanelSystemContainer");
systemContainer = PanelSystemContainer00.GetComponent<RectTransform>();
Transform PanelSystemRichEdit000 = PanelSystemContainer00.FindChild("PanelSystemRichEdit");
systemRichEdit = PanelSystemRichEdit000.GetComponent<RectTransform>();
Transform PanelChatContainer01 = PanelMessageContainer0.FindChild("PanelChatContainer");
chatContainer = PanelChatContainer01.GetComponent<RectTransform>();
Transform PanelChatRichEdit010 = PanelChatContainer01.FindChild("PanelChatRichEdit");
chatRichEdit = PanelChatRichEdit010.GetComponent<RectTransform>();
Transform PanelChatButtonContainer011 = PanelChatContainer01.FindChild("PanelChatButtonContainer");
chatButtonContainer = PanelChatButtonContainer011.GetComponent<RectTransform>();
Transform InputFieldChat0110 = PanelChatButtonContainer011.FindChild("InputFieldChat");
Transform TextChatInputText01100 = InputFieldChat0110.FindChild("ChatInputText");
chatInputText = TextChatInputText01100.GetComponent<Text>();
Transform ButtonChatFace0111 = PanelChatButtonContainer011.FindChild("ButtonChatFace");
buttonChatFace = ButtonChatFace0111.GetComponent<Button>();
buttonChatFace.onClick.AddListener(OnButtonChatFaceClicked);
Transform ButtonSend0112 = PanelChatButtonContainer011.FindChild("ButtonSend");
buttonSend = ButtonSend0112.GetComponent<Button>();
buttonSend.onClick.AddListener(OnButtonSendClicked);
Transform PanelMainButtonContainer1 = transform.FindChild("PanelMainButtonContainer");
mainButtonContainer = PanelMainButtonContainer1.GetComponent<RectTransform>();
Transform ButtonSystem10 = PanelMainButtonContainer1.FindChild("ButtonSystem");
buttonSystem = ButtonSystem10.GetComponent<Button>();
buttonSystem.onClick.AddListener(OnButtonSystemClicked);
Transform ButtonChat11 = PanelMainButtonContainer1.FindChild("ButtonChat");
buttonChat = ButtonChat11.GetComponent<Button>();
buttonChat.onClick.AddListener(OnButtonChatClicked);
}
示例2: EnableButton
// Use this for initialization
public void EnableButton()
{
ThisButton = gameObject.AddComponent<UnityEngine.UI.Button>();
ThisButton.transition = Selectable.Transition.None;
ThisButton.onClick.RemoveAllListeners();
ThisButton.onClick.AddListener( () => OnAClick() );
}
示例3: Awake
// Use this for initialization
void Awake() {
if (instance != null && instance != this) {
// If that is the case, we destroy other instances
Destroy(gameObject);
}
if (instance == null) {
instance = this;
mainPanel = transform.Find("MainPanel").gameObject;
settingsPanel = transform.Find("Settings").gameObject;
controlsPanel = transform.Find("ControlsPanel").gameObject;
menuConfirmPanel = transform.Find("MenuConfirm").gameObject;
desktopConfirmPanel = transform.Find("DesktopConfirm").gameObject;
background = transform.Find("Background").gameObject;
resumeButton = transform.Find("MainPanel/ResumeButton").GetComponent<UnityEngine.UI.Button>();
settingsButton = transform.Find("MainPanel/SettingsButton").GetComponent<UnityEngine.UI.Button>();
controlsButton = transform.Find("MainPanel/ControlsButton").GetComponent<UnityEngine.UI.Button>();
menuButton = transform.Find("MainPanel/MenuButton").GetComponent<UnityEngine.UI.Button>();
quitButton = transform.Find("MainPanel/QuitButton").GetComponent<UnityEngine.UI.Button>();
settingsBackButton = transform.Find("Settings/BackButton").GetComponent<UnityEngine.UI.Button>();
controlsBackButton = transform.Find("ControlsPanel/BackButton").GetComponent<UnityEngine.UI.Button>();
/*
controlsKeyboardButton = transform.Find("ControlsPanel/KeyboardButton").GetComponent<UnityEngine.UI.Button>();
controlsPadButton = transform.Find("ControlsPanel/PadButton").GetComponent<UnityEngine.UI.Button>();
*/
}
}
示例4: Start
private void Start()
{
gridRect = GetComponentInParent<RectTransform>();
gridCanvas = GetComponentInParent<Canvas>();
gridLayout = GetComponentInParent<GridLayoutGroup>();
gridRect.pivot = new Vector2(0, 0);
gridRect.position = new Vector3(terrainMesh.transform.position.x, 6.0f, terrainMesh.transform.position.z);
gridRect.anchorMin = new Vector2(terrainMesh.transform.position.x, terrainMesh.transform.position.z);
gridRect.anchorMax = new Vector2(terrainMesh.terrainData.size.x, terrainMesh.terrainData.size.z);
gridLayout.CalculateLayoutInputHorizontal();
Debug.Log(string.Format("Origin: {0}, Size: {1}, Cell size: {2}\n", gridRect.position.ToString(), gridRect.rect.size.ToString(), gridLayout.cellSize));
buttonTemplate = GetComponentInChildren<Button>();
for (int y = 0; y < gridRect.rect.y; y++)
{
for (int x = 0; x < gridRect.rect.x; x++)
{
Vector3 pos = new Vector3(x, 0, y); // * spacing;
Button b = (Button)Instantiate(buttonTemplate, pos, Quaternion.identity);
//b.gameObject.AddComponent<LayoutElement>();
//b.name = "Button " + x.ToString() + "," + y.ToString();
//b.GetComponentInChildren<Text>().text = b.name;
gridLayout.SetLayoutHorizontal();
}
}
}
示例5: OnStateEnter
override public void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
{
if (firstField == null)
{
var firstFieldTransform = animator.transform.Find(firstFieldPath);
if (firstFieldTransform != null)
{
firstField = firstFieldTransform.GetComponent<InputField>();
}
}
if (submitButton == null)
{
var submitButtonTransform = animator.transform.Find(submitButtonPath);
if (submitButtonTransform != null)
{
submitButton = submitButtonTransform.GetComponent<Button>();
}
}
if (firstField != null)
{
firstField.Select();
}
}
示例6: Awake
public override void Awake()
{
base.Awake();
if (gameObject.transform is RectTransform)
{
var input = gameObject.GetComponent<InputField>();
if (input != null)
{
input.onEndEdit.AddListener((text)=> OnClick());
return;
}
button = GetComponent<UnityEngine.UI.Button>();
if (button == null)
{
if (GetComponent<UnityEngine.UI.Toggle>() == null)
{
button = gameObject.AddComponent<UnityEngine.UI.Button>();
button.interactable = true;
button.transition = Selectable.Transition.None;
}
}
if (button != null && button.onClick.GetPersistentEventCount() == 0)
{
button.onClick.AddListener(OnClick);
}
}
}
示例7: Start
// Use this for initialization
void Start()
{
if (this.player == null)
return;
this.stats_panel = transform.Find("Stats").gameObject;
this.undefined_panel = transform.Find("Undefined").gameObject;
this.name_text = transform.Find("Name").GetComponent<Text>();
this.defi_text = transform.Find("Defi").Find("Text").GetComponent<Text>();
this.name_text.text = this.player.Name;
this.defi_text.text = "Defi";
//this.manager = GameObject.Find("Manager").GetComponent<PhiManager>();
InstantiateSwungMen();
SetUpStats();
this.buy = transform.Find("Buy").GetComponent<Button>();
this.unlocked = Settings.Instance.Default_player.ContainsKey(this.player.UID);
if (this.unlocked)
{
this.undefined_panel.SetActive(false);
BoughtButton();
}
else
{
this.swungMen.SetActive(false);
}
}
示例8: CopyButton
public void CopyButton(MenuButton _element)
{
uiButton = _element.uiButton;
uiText = _element.uiText;
label = _element.label;
hotspotLabel = _element.hotspotLabel;
hotspotLabelID = _element.hotspotLabelID;
anchor = _element.anchor;
textEffects = _element.textEffects;
buttonClickType = _element.buttonClickType;
simulateInput = _element.simulateInput;
simulateValue = _element.simulateValue;
doFade = _element.doFade;
switchMenuTitle = _element.switchMenuTitle;
inventoryBoxTitle = _element.inventoryBoxTitle;
shiftInventory = _element.shiftInventory;
loopJournal = _element.loopJournal;
actionList = _element.actionList;
inputAxis = _element.inputAxis;
clickTexture = _element.clickTexture;
clickAlpha = _element.clickAlpha;
shiftAmount = _element.shiftAmount;
onlyShowWhenEffective = _element.onlyShowWhenEffective;
allowContinuousClick = _element.allowContinuousClick;
parameterID = _element.parameterID;
parameterValue = _element.parameterValue;
base.Copy (_element);
}
示例9: Start
void Start()
{
button = GetComponent<UnityEngine.UI.Button>();
text = GetComponentInChildren<Text>();
canvasGroup = GetComponent<CanvasGroup>();
normalGlow = glow.color;
}
示例10: Start
void Start()
{
quitMenu = quitMenu.GetComponent<Canvas>();
quitMenu.enabled = false;
startText = startText.GetComponent<Button>();
exitText = exitText.GetComponent<Button>();
}
示例11: SetEnabled
public void SetEnabled(Button button, bool enabled)
{
if (enabled)
Enable(button);
else
Disable(button);
}
示例12: Start
// Use this for initialization
private void Start()
{
this.unlocked = false;
// fuck compiler warnings :D
if (this.unlocked) { }
this.upgraded = false;
this.upgradeName = this.GetComponentInChildren<Text>();
this.unlockButton = this.GetComponent<Button>();
this.unlockButton.image.sprite = this.regularImg;
this.upgrade = this.upgradeObj.GetComponent<IUpgrade>();
this.upgradeName.text = this.upgrade.Name;
foreach (Skill s in this.requiredSkills)
{
s.unlockSkill = this;
//_RequiredUnlocks += 1;
}
if (this.requiredSkills.Length != 0)
{
this.unlockButton.image.sprite = this.lockedImg;
this.unlockButton.interactable = false;
}
}
示例13: Start
void Start()
{
HeaderText = this.GetComponentsInChildren<Text>().First(t => t.name == "headertext");
HeaderText.text = Card.Name;
PlayButton = this.GetComponentsInChildren<Button>().First(i => i.name == "PlayButton");
PlayButton.onClick.AddListener(HandleClick);
}
示例14: Awake
public void Awake()
{
_button = GetComponent<Button>();
IsInteractable = _button.interactable;
StateChanged();
}
示例15: ButtonObject
public ButtonObject(string buttonImageFileName, string text, Action onClick)
{
Go = Resources.Load(Settings.Instance.PREFAB_PATH + "Button") as GameObject;
// Go.SetActive(false);
Go = GameObject.Instantiate<GameObject>(Go);
_image = Go.GetComponent<Image>();
Sprite sprite = Resources.Load<Sprite>(Settings.Instance.UI_IMAGE_PATH + buttonImageFileName);
if (_image && sprite)
{
_image.sprite = sprite;
}
else
{
Debug.Log("Do not find image file");
}
_text = Go.GetComponentInChildren<Text>();
_text.text = text;
_button = Go.GetComponent<Button>();
if(_button)
{
_button.onClick.AddListener(new UnityEngine.Events.UnityAction(onClick));
}
}