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


C# PlayerStats.GetComponentInChildren方法代码示例

本文整理汇总了C#中PlayerStats.GetComponentInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerStats.GetComponentInChildren方法的具体用法?C# PlayerStats.GetComponentInChildren怎么用?C# PlayerStats.GetComponentInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerStats的用法示例。


在下文中一共展示了PlayerStats.GetComponentInChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetPlayerStats

 /// <summary>
 /// Tie this HUD to a player's PlayerStats.cs script to visualize the correct player
 /// </summary>
 /// <param name="playerStats"></param>
 public void SetPlayerStats(PlayerStats playerStats)
 {
     ps = playerStats;
     pl = playerStats.GetComponent<PlayerLogic>();
     playerNameText.text = "";
     pl.CmdWhatNumberAmI();
     // Turn off world-space healthBar
     ps.GetComponentInChildren<Canvas>().enabled = false;
     #region Abilities
     try {
         ability1.sprite = ps.abilities[0].Icon;
         actionBar.GetComponentsInChildren<Image>()[0].sprite = ps.abilities[0].Icon;
         ability2.sprite = ps.abilities[1].Icon;
         actionBar.GetComponentsInChildren<Image>()[2].sprite = ps.abilities[1].Icon;
         ability3.sprite = ps.abilities[2].Icon;
         actionBar.GetComponentsInChildren<Image>()[4].sprite = ps.abilities[2].Icon;
         SetTooltips();
     } catch { Debug.Log("Actionbar (automatic) setup for abilities failed.."); }
     #endregion
     #region Inventory
     //Activate Inventory GO
     inventory.gameObject.SetActive(true);
     //Set count status text
     inventory.transform.FindChild("Banana").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().bananaCount;
     inventory.transform.FindChild("Stick").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("Sap").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("Leaf").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("BerryR").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryRCount;
     inventory.transform.FindChild("BerryG").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryGCount;
     inventory.transform.FindChild("BerryB").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryBCount;
     #endregion
     // TODO: Do stuff with setting up correct ability images
     SetCursorState(true);
     if (miniMap) foreach (MinimapBlip mmb in miniMap.GetComponentsInChildren<MinimapBlip>()) Destroy(mmb.gameObject); //Removes previous icons if players reconnect (important when they swap teams)
     SetupMiniMap(playerStats.transform);
 }
开发者ID:PeWiNi,项目名称:MonguinsAndBeyond,代码行数:40,代码来源:HUDScript.cs


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