当前位置: 首页>>代码示例>>C#>>正文


C# Button.GetComponentInChildren方法代码示例

本文整理汇总了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;
    }
开发者ID:zeldax54,项目名称:jregame,代码行数:36,代码来源:ModalPanel.cs

示例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);
         });
     }
 }
开发者ID:PlayFab,项目名称:PlayFabGameServer,代码行数:33,代码来源:FriendComponent.cs

示例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;
     }
 }
开发者ID:polle-vanhoof,项目名称:Containment,代码行数:9,代码来源:PauzeButton.cs

示例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;
     }
 }
开发者ID:polle-vanhoof,项目名称:Containment,代码行数:9,代码来源:PauzeButton.cs

示例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;
     }
 }
开发者ID:gus5345,项目名称:Unity_DomainWar,代码行数:11,代码来源:CreateRoom.cs

示例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;
 }
开发者ID:TheNextGuy32,项目名称:zipclimber,代码行数:13,代码来源:MenuManager.cs

示例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;
     }
 }
开发者ID:StoRRica,项目名称:Sn-c-ake,代码行数:15,代码来源:StartMenu.cs

示例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);
        }
    }
开发者ID:igm-capstone,项目名称:capstone-game-unity,代码行数:25,代码来源:GameStateHUD.cs

示例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>();
    }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:36,代码来源:PlayerHUD.cs

示例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);
	}
开发者ID:deerHub,项目名称:mikan-lostInJapan,代码行数:61,代码来源:MainMenu.cs

示例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;
    }
开发者ID:Leopold5,项目名称:gogo123,代码行数:25,代码来源:ListOfMapFilesAsButtons.cs

示例12: Clciked

    public void Clciked(Button button)
    {
        string str = button.GetComponentInChildren<Text>().text;

           if (inpuField.text.Length >= maxChars) return;
            inpuField.text += str;
    }
开发者ID:pontura,项目名称:Proyectate,代码行数:7,代码来源:KeyboardVirtual.cs

示例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();
 }
开发者ID:WEASEL4994,项目名称:GameJam2016,代码行数:26,代码来源:PauseInputMenu.cs

示例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 ();
 }
开发者ID:lucyktan,项目名称:ItTakesAVillage,代码行数:15,代码来源:UserInput.cs

示例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;
    }
开发者ID:blewert,项目名称:bangor-benchmark,代码行数:8,代码来源:EnvironmentButtonListener.cs


注:本文中的Button.GetComponentInChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。