本文整理汇总了C#中Button.OnClick方法的典型用法代码示例。如果您正苦于以下问题:C# Button.OnClick方法的具体用法?C# Button.OnClick怎么用?C# Button.OnClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.OnClick方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
protected override void Awake()
{
base.Awake();
selectedSectorText = GameObject.Find("text_sector-name").GetComponent<Text>();
sectorDescriptionText = GameObject.Find("text_sector-description").GetComponent<Text>();
for (int i = 1; i < 5; i++)
{
int ic = i;
sectorButtons[ic] = GameObject.Find("button_sector" + ic).GetComponent<Button>();
sectorButtons[ic].OnClick(() => {
selectedSector = ic;
selectedSectorText.text = "Sector " + ic;
sectorDescriptionText.text = Text.Get(string.Format("Sector{0}Description", ic));
});
}
sendDroneButton = GameObject.Find("button_send-drone").GetComponent<Button>();
sendDroneButton.OnClick(() => {
if (selectedSector != 0 && MapController.EnterSector())
{
SwitchView(selectedSector == 1 ? ViewType.Sector1
: selectedSector == 2 ? ViewType.Sector2
: selectedSector == 3 ? ViewType.Sector3
: ViewType.Sector4);
}
});
selectedSector = 1;
selectedSectorText.text = "Sector 1";
sectorDescriptionText.text = Text.Get("Sector1Description");
}
示例2: Main
static void Main()
{
Button BtnStart = new Button();
BtnStart.Draw();
BtnStart.Click += GameStart;
Console.WriteLine("S:게임 시작 , E:끝");
for (; ; )
{
if (Console.KeyAvailable)
{
ConsoleKeyInfo cki;
cki = Console.ReadKey();
if (cki.Key == ConsoleKey.S)
{
BtnStart.OnClick();
}
if (cki.Key == ConsoleKey.E)
{
break;
}
}
System.Threading.Thread.Sleep(100);
}
}
示例3: Awake
private void Awake()
{
mineralASlider = transform.Find("panel_sliders/slider_mineral-a").GetComponent<Slider>();
mineralASlider.value = 1;
mineralBSlider = transform.Find("panel_sliders/slider_mineral-b").GetComponent<Slider>();
mineralBSlider.value = 1;
mineralCSlider = transform.Find("panel_sliders/slider_mineral-c").GetComponent<Slider>();
mineralCSlider.value = 1;
synthFuelButton = transform.Find("button_synth-fuel").GetComponent<Button>();
synthFuelButton.OnClick(() => { WorkshopController.SynthFuel(GetCurrentProbe()); AddProbe(GetCurrentProbe()); });
mineralAFill = transform.Find("panel_triangle/image_triangle-fill-a").GetComponent<Image>();
mineralAFill.fillAmount = 0;
mineralBFill = transform.Find("panel_triangle/image_triangle-fill-b").GetComponent<Image>();
mineralBFill.fillAmount = 0;
mineralCFill = transform.Find("panel_triangle/image_triangle-fill-c").GetComponent<Image>();
mineralCFill.fillAmount = 0;
probesParent = transform.Find("panel_triangle/image_triangle-segments");
for (int a = 1; a < 8; a++)
for (int c = 1; c < 8; c++)
if ((a + c) >= 2 && (a + c) <= 8)
AddProbe(new int[] {a, 0, c}, true);
}
示例4: Awake
private void Awake()
{
wiringText = transform.Find("text_wiring").GetComponent<Text>();
alloyText = transform.Find("text_alloy").GetComponent<Text>();
chipsText = transform.Find("text_chips").GetComponent<Text>();
componentText = transform.Find("text_component").GetComponent<Text>();
fixEngineButton = transform.Find("button_fix-engine").GetComponent<Button>();
fixEngineButton.OnClick(() => WorkshopController.FixEngine());
}
示例5: Awake
private void Awake()
{
currentJournalDay = ServiceLocator.State.CurrentDay;
journalText = transform.Find("text_journal").GetComponent<Text>();
previousButton = transform.Find("button_previous").GetComponent<Button>();
previousButton.OnClick(() => {
currentJournalDay = Mathf.Clamp(currentJournalDay - 1, 1, ServiceLocator.State.CurrentDay);
UpdateJournal();
});
nextButton = transform.Find("button_next").GetComponent<Button>();
nextButton.OnClick(() =>
{
currentJournalDay = Mathf.Clamp(currentJournalDay + 1, 1, ServiceLocator.State.CurrentDay);
UpdateJournal();
});
UpdateJournal();
}
示例6: CreateButton
private void CreateButton(Button btn)
{
if(btn.visible)
{
btn.selected = GUI.Button(getRectByIndex(btn.index, btn.width, btn.height), btn.text);
if(btn.selected)
btn.OnClick();
}
}