本文整理汇总了C#中Button.GetComponentInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Button.GetComponentInChildren方法的具体用法?C# Button.GetComponentInChildren怎么用?C# Button.GetComponentInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.GetComponentInChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Elejir
//Metodo para llamar al panel recibe el texto , el event que seria el metodo a ejecutar en caso de aceptar
//El boton aceptar y el boton cancelar
public void Elejir(string pregunta, UnityAction yesEvent, Button aceptar, Button cancelar, bool bandera, Button help = null)
{
ModalPanelObjeto.SetActive(true);//Activo el panel porque inicialmente tiene que estar desactivado para que no se muestre en la escena
TextUI.text = pregunta;//Le asigno al texto de la ui la pregunta que le mando al llamar a este metodo
if (help != null && help.IsActive()) help.gameObject.SetActive(false);
//Asigno los eventos al boton cancelar para que cierre el panel este lo hago aqui porque el simple
//Pero los eventos para el metodo de aceptar los hago en el otro script porque tengo que usar variables de ese script
cancelar.onClick.RemoveAllListeners();
cancelar.onClick.AddListener(CerrarPanel);
//Ahora para los eventos de aceptar paso el UnityAction y al llamarlo le asigno un metodo en el otro script
//O sea yesEvent=Metodo en el otro script
aceptar.onClick.RemoveAllListeners();
if (yesEvent != null)
{
aceptar.onClick.RemoveAllListeners();
aceptar.onClick.AddListener(yesEvent);
}
aceptar.gameObject.SetActive(true);
aceptar.GetComponentInChildren<Image>().sprite = si;
if (bandera) //Esto es para los paneles informativos dejarle un solo boton
{
cancelar.gameObject.SetActive(false);
aceptar.GetComponentInChildren<Image>().sprite = ok;
}
else
{
cancelar.gameObject.SetActive(true);
}
activo = true;
}
示例2: AddButtonClicked
public void AddButtonClicked(Button sender)
{
var playerIdText = sender.GetComponentInChildren<Text>();
if (playerIdText == null) return;
if (playerIdText.text == "Add Friend")
{
var request = new AddFriendRequest() { FriendPlayFabId = sender.name };
Debug.Log(sender.name);
PlayFabClientAPI.AddFriend(request, result =>
{
if (result.Created)
{
sender.GetComponentInChildren<Text>().text = "Gift";
}
}, error =>
{
if (error.Error == PlayFabErrorCode.UsersAlreadyFriends)
{
sender.GetComponentInChildren<Text>().text = "Gift";
}
});
}
else if (playerIdText.text == "Gift")
{
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "grantItemToPlayer", FunctionParameter = new {benefiter = sender.name}, GeneratePlayStreamEvent = false}, urlResult =>
{
Debug.Log("success cloud scipt!");
}, error =>
{
Debug.Log(error.ErrorMessage);
});
}
}
示例3: Unhide
public void Unhide(Button but)
{
but.enabled = true;
but.GetComponentInChildren<CanvasRenderer>().SetAlpha(1);
Text text = but.GetComponentInChildren<Text>();
if (text != null) {
text.color = Color.black;
}
}
示例4: Hide
public void Hide(Button but)
{
but.enabled = false;
but.GetComponentInChildren<CanvasRenderer>().SetAlpha(0);
Text text = but.GetComponentInChildren<Text>();
if (text != null) {
text.color = Color.clear;
}
}
示例5: ButtonMaxPlayers
public void ButtonMaxPlayers(Button b,int type) // 타입을 주어서 킬과 인원수를 동시처리하는 함수로 만듬
{
if (type == 0) // 0 일때 플레이어 인원 수
{
maxPlayers.text = b.GetComponentInChildren<Text>().text;
}
else // 아닐때 총 킬수
{
maxKill.text = b.GetComponentInChildren<Text>().text;
}
}
示例6: submitScore
public void submitScore(Button submitButton)
{
bool success = HighscoreManager.AddScore((int)GameManager.score, (userInputField.text != "" ? userInputField.text : "The ZipClimber"));
if(success)
{
submitButton.GetComponentInChildren<Text>().text = "Submitted successfully";
}
else
{
submitButton.GetComponentInChildren<Text>().text = "Error";
}
submitButton.interactable = false;
}
示例7: Hidden
public static void Hidden(Button but, bool isHidden)
{
if (isHidden)
{
but.enabled = false;
but.GetComponentInChildren<CanvasRenderer>().SetAlpha(0);
but.GetComponentInChildren<Text>().color = Color.clear;
}
else
{
but.enabled = true;
but.GetComponentInChildren<CanvasRenderer>().SetAlpha(1);
but.GetComponentInChildren<Text>().color = Color.black;
}
}
示例8: SetMsg
public void SetMsg(string text)
{
if (isOver) return;
isOver = true;
gameStateHUD.SetActive(true);
msg = gameStateHUD.GetComponentInChildren<Text>();
msg.text = text;
btn = gameStateHUD.GetComponentInChildren<Button>();
if (GameObject.Find("Me").GetComponent<GhostController>())
{
btn.onClick.RemoveAllListeners();
btn.onClick.AddListener(RestartGame);
btn.GetComponentInChildren<Text>().text = "Restart";
btn.gameObject.SetActive(true);
}
else
{
btn.enabled = false;
btn.interactable = false;
btn.gameObject.SetActive(false);
}
}
示例9: Start
// Use this for initialization
void Start()
{
panel = GameObject.Find("PlayerPanel").GetComponent<Image>();
playerScript = GameObject.Find("Player(Clone)").GetComponent<Player>();
#region Buttons
specialChoice = GameObject.Find("specialChoice").GetComponent<Button>();
specialChoice.onClick.AddListener(ChooseSpecial);
specialText = specialChoice.GetComponentInChildren<Text>();
ready = GameObject.Find("Ready").GetComponent<Button>();
ready.onClick.AddListener(Ready);
#region bugs
health = GameObject.Find("Health").GetComponent<Button>();
health.onClick.AddListener(delegate { ChooseUpgrade("health"); });
moveSpeed = GameObject.Find("MoveSpeed").GetComponent<Button>();
moveSpeed.onClick.AddListener(delegate { ChooseUpgrade("movement speed"); });
shotSpeed = GameObject.Find("ShotSpeed").GetComponent<Button>();
shotSpeed.onClick.AddListener(delegate { ChooseUpgrade("shooting speed"); });
response = GameObject.Find("Response").GetComponent<Text>();
#endregion
#endregion
credits = GameObject.Find("Credits").GetComponent<Text>();
experience = GameObject.Find("Experience").GetComponent<Text>();
player = GameObject.FindGameObjectWithTag("Pilot");
powerBar = GameObject.FindGameObjectWithTag("Power Bar");
healthBar = GameObject.FindGameObjectWithTag("Health Bar");
gameController = GameObject.FindGameObjectWithTag("GameController");
gameControllerScript = gameController.GetComponent<GameController>();
playerScript = player.GetComponent<Player>();
animator = powerBar.GetComponent<Animator>();
}
示例10: Start
// Use this for initialization
void Start () {
optionsMenu = optionsMenu.GetComponent<Canvas> ();
profileNamePrompt = profileNamePrompt.GetComponent<Canvas>();
profileMenu = profileMenu.GetComponent<Canvas> ();
profileBtn = profileBtn.GetComponent<Button> ();
playBtn = playBtn.GetComponent<Button> ();
exitBtn = exitBtn.GetComponent<Button> ();
optionBtn = optionBtn.GetComponent<Button> ();
addBtn = addBtn.GetComponent<Button> ();
deleteBtn = deleteBtn.GetComponent<Button> ();
//List<string> name = new List<string> ();
foreach(Game game in SaveLoad.list.savedGames){
}
deleteBtn.onClick.AddListener(delegate{
DeletProfile(CheckDoubleClick.profileNameClicked , deleteBtn);
});
callout = callout.GetComponent<Image> ();
newName = newName.GetComponent<InputField> ();
calloutText = calloutText.GetComponent<Text> ();
optionsMenu.enabled = false;
profileMenu.enabled = false;
callout.enabled = false;
calloutText.enabled = false;
addBtn.interactable = false;
deleteBtn.enabled = false;
deleteBtn.image.enabled = false;
if (File.Exists (Application.persistentDataPath + "/" + SaveLoad.fileName)) {
Debug.Log("FileExists");
SaveLoad.Load ();
profileNamePrompt.enabled = false;
profileBtn.GetComponentInChildren<Text>().text = SaveLoad.list.latestGame;
//Create Game.current object from latest profile used.
} else {
Debug.Log("No file");
profileNamePrompt.enabled = true;
}
Debug.Log (SaveLoad.list.savedGames.Count);
}
示例11: FileButtonListener
public void FileButtonListener(string mapName, string directory, Button button)
{
//color part
if (activeButton == null) {
print ("Active button null");
activeButton = button;
}
else
{
activeButton.GetComponentInChildren<Text>().color = Color.black;
activeButton = button;
}
button.GetComponentInChildren<Text>().color = Color.green;
//color part
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open (directory+"/"+mapName, FileMode.Open);
mapFromSelectedFile = (GameManager.Map)bf.Deserialize (file);
file.Close ();
if (preview != null)Destroy (preview);
GameManager.instance.GetComponent<MapDrawer>().DrawTerrainPreview (mapFromSelectedFile, previewPositionHolder);
preview = GameManager.instance.GetComponent<MapDrawer>().previewHoldingGO;
GameManager.instance.currentMap = mapFromSelectedFile;
}
示例12: Clciked
public void Clciked(Button button)
{
string str = button.GetComponentInChildren<Text>().text;
if (inpuField.text.Length >= maxChars) return;
inpuField.text += str;
}
示例13: CycleControlType
public void CycleControlType(Button aButton)
{
//Cycle between Keyboard or Xbox controls
if (aButton.name == "KeyboardOrXbox")
{
switch (m_Player.InputType)
{
case InputType.Joystick:
{
InputManager.Instance.SetInputType(ref m_Player, InputType.Keyboard);
}
break;
case InputType.Keyboard:
{
InputManager.Instance.SetInputType(ref m_Player, InputType.Joystick);
}
break;
}
aButton.GetComponentInChildren<Text>().text = "Input: " + m_Player.InputType;
InputManager.Instance.ReInitializeInputStrings(ref m_Player);
InputManager.Instance.m_InputStrings[(int)m_PlayerNumber] = m_Player;
InputManager.Instance.SetPlayerControllerNumbers();
Debug.Log(InputManager.Instance.m_InputStrings[(int)PlayerNumber.One].InputType);
}
RefreshButtonText();
}
示例14: writeJournal
/*
public void writeJournal(Button b){
string s;
s = b.GetComponentInChildren<Text>().text;
GameControl.control.SetInput (GameControl.control.GetInput () + s + "\r\n");
GameControl.control.Save ();
}*/
public void getTodaysDate(Button b)
{
DateTime thisDate = DateTime.Today;
string s = b.GetComponentInChildren<Text> ().text;
s = thisDate.ToString ("D");
GameControl.control.SetInput (GameControl.control.GetInput () + s + "\r\n");
GameControl.control.Save ();
}
示例15: OnButtonClick
public void OnButtonClick(Button b, Mode mode)
{
string name = b.GetComponentInChildren<Text>().text;
var path = mode.supportedEnvironments.Find (x => name == x.name).path;
StartButtonListener.sceneToLoad = path;
}