本文整理汇总了C#中Seed.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Seed.GetComponent方法的具体用法?C# Seed.GetComponent怎么用?C# Seed.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Seed
的用法示例。
在下文中一共展示了Seed.GetComponent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onLeftMouseDown
//For testing purposes we print out plant species
public string onLeftMouseDown(Seed playerSeed, Plant playerPlant)
{
if(occupied)
{
return "Space is occupied!";
// Call remove function?
}
//If player is holding seed, set it.
else if(playerSeed)
{
currentSeed = playerSeed;
occupied = true;
currentSeed.GetComponent<Seed>().currentSpace = this.gameObject.GetComponent<Plantable_Space>();
//Spawn GameObject of Seed
return "Planted " + playerSeed.species;
}
//Else if holding a plant, set that.
else if(playerPlant)
{
currentPlant = playerPlant;
occupied = true;
currentPlant.GetComponent<Plant>().currentSpace = this.gameObject.GetComponent<Plantable_Space>();
return "Planted " + playerPlant.species;
}
else
{
//Player has no plant or seed selected in inventory, nothing happens.
return null;
}
}