本文整理汇总了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);
}