コード例 #1
0
        public void ApplyTrees(TCUnityTerrain sTerrain = null)
        {
            if (!CheckValidUnityTerrain())
            {
                return;
            }
            if (sTerrain == null)
            {
                sTerrain = this;
            }

            if (sTerrain.treePrototypes.Count == 0)
            {
                ResetTrees();
            }

            List <TreePrototype> treePrototypesCleaned = new List <TreePrototype>();

            for (int i = 0; i < sTerrain.treePrototypes.Count; i++)
            {
                TC_TreePrototype s = sTerrain.treePrototypes[i];

                if (s.prefab == null)
                {
                    continue;
                }

                TreePrototype d = new TreePrototype();
                d.bendFactor = s.bendFactor;
                d.prefab     = s.prefab;
                treePrototypesCleaned.Add(d);
            }

            terrain.terrainData.treePrototypes = treePrototypesCleaned.ToArray();
        }
コード例 #2
0
        public void SwapTree(int index1, int index2)
        {
            if (index2 >= 0 && index2 < treePrototypes.Count)
            {
                TC_TreePrototype treePrototype2 = treePrototypes[index1];

                treePrototypes[index1] = treePrototypes[index2];
                treePrototypes[index2] = treePrototype2;
            }
        }
コード例 #3
0
        public void GetTrees()
        {
            if (!CheckValidUnityTerrain())
            {
                return;
            }
            treePrototypes.Clear();

            for (int i = 0; i < terrain.terrainData.treePrototypes.Length; i++)
            {
                TreePrototype    s = terrain.terrainData.treePrototypes[i];
                TC_TreePrototype d = new TC_TreePrototype();
                d.bendFactor = s.bendFactor;
                d.prefab     = s.prefab;
                treePrototypes.Add(d);
            }
        }
コード例 #4
0
 public void CopyTree(TC_TreePrototype treePrototype1, TC_TreePrototype treePrototype2)
 {
     treePrototype2.prefab     = treePrototype1.prefab;
     treePrototype2.bendFactor = treePrototype1.bendFactor;
 }