本文整理汇总了C#中UnityEngine.GameObject.Generate方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.Generate方法的具体用法?C# GameObject.Generate怎么用?C# GameObject.Generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.Generate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProceduralTree
static void CreateProceduralTree()
{
var procTree = new GameObject(string.Format("Tree_{0:X4}", Random.Range(0, 65536))).AddComponent<ProcTree>();
procTree.seed = Random.Range(0, 65536);
procTree.RandomizeSettings();
procTree.Generate(Random.Range(0f, 1f) <= 0.5f ? true : false);
}
示例2: CreateProceduralBuilding
static void CreateProceduralBuilding()
{
var procBuilding = new GameObject(string.Format("Building_{0:X4}", Random.Range(0, 65536))).AddComponent<Building>();
procBuilding.seed = Random.Range(0, 65536);
procBuilding.RandomizeSettings();
procBuilding.Generate();
}
示例3: CreateListOfPrefabs
public List<GameObject> CreateListOfPrefabs(List<GameObject> prefabList, int cone, int house, float scale)
{
List<GameObject> prefabs = new List<GameObject>();
if (prefabList.Count == 0)
{
if (house == -1)
Debug.Log("Please choose number of tree types");
else
Debug.Log("Please choose number of building types");
}
else
{
for (int i = 0; i < prefabList.Count; i++)
{
if (prefabList[i] == null)
{
if (house == -1)
{
ProcTree procTree = new GameObject("tree").AddComponent<ProcTree>();
procTree.RandomizeSettings();
procTree.Generate(cone == 0 ? true : false);
prefabs.Add(procTree.gameObject);
}
else
{
Building procBuilding = new GameObject("building").AddComponent<Building>();
procBuilding.RandomizeSettings();
procBuilding.Generate();
procBuilding.floors = house == 0 ? Random.Range(1, 5) : Random.Range(5, 9);
prefabs.Add(procBuilding.gameObject);
}
}
else
{
prefabs.Add(prefabList[i]);
}
}
}
return prefabs;
}