UnityEditor.TreeWizard.IsValidTree C# (CSharp) Method

IsValidTree() private static method

private static IsValidTree ( GameObject tree, int prototypeIndex, Terrain terrain ) : bool
tree UnityEngine.GameObject
prototypeIndex int
terrain UnityEngine.Terrain
return bool
        private static bool IsValidTree(GameObject tree, int prototypeIndex, Terrain terrain)
        {
            if (tree == null)
            {
                return false;
            }
            TreePrototype[] treePrototypes = terrain.terrainData.treePrototypes;
            for (int i = 0; i < treePrototypes.Length; i++)
            {
                if ((i != prototypeIndex) && (treePrototypes[i].m_Prefab == tree))
                {
                    return false;
                }
            }
            return true;
        }

Usage Example

示例#1
0
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();
            this.m_Tree = (GameObject)EditorGUILayout.ObjectField("Tree Prefab", (Object)this.m_Tree, typeof(GameObject), !EditorUtility.IsPersistent((Object)this.m_Terrain.terrainData), new GUILayoutOption[0]);
            if (!TerrainEditorUtility.IsLODTreePrototype(this.m_Tree))
            {
                this.m_BendFactor = EditorGUILayout.FloatField("Bend Factor", this.m_BendFactor, new GUILayoutOption[0]);
            }
            bool flag = EditorGUI.EndChangeCheck();

            if (flag)
            {
                this.m_IsValidTree = TreeWizard.IsValidTree(this.m_Tree, this.m_PrototypeIndex, this.m_Terrain);
            }
            return(flag);
        }
All Usage Examples Of UnityEditor.TreeWizard::IsValidTree