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


C# GameObject.Generate方法代码示例

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

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

示例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;
        }
开发者ID:thetobinator,项目名称:udg2,代码行数:41,代码来源:CityPopulator.cs


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