/// Sets up the terrain neighbors structure.
    public void ConnectTerrainNeighbors()
    {
        Terrain myTerrain = GetComponentInChildren <Terrain>();

        if (myTerrain)
        {
            myTerrain.SetNeighbors(LeftTerrain ? LeftTerrain.GetComponentInChildren <Terrain>() : null,
                                   TopTerrain ? TopTerrain.GetComponentInChildren <Terrain>() : null,
                                   RightTerrain ? RightTerrain.GetComponentInChildren <Terrain>() : null,
                                   BottomTerrain ? BottomTerrain.GetComponentInChildren <Terrain>() : null);
        }
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        SECTR_Sector mySector = (SECTR_Sector)target;

        base.OnInspectorGUI();
        List <SECTR_Member.Child> sharedChildren = mySector.GetSharedChildren();

        if (sharedChildren.Count > 0 && GUILayout.Button(new GUIContent("Fix Shared Children", "Adds Member components to any children that extend beyond this Sector and into other sectors.")))
        {
            MakeSharedChildrenMembers(mySector, sharedChildren, "Fix Shared Children");
        }

        if (mySector.GetComponentInChildren <Terrain>())
        {
            terrainFoldout = EditorGUILayout.Foldout(terrainFoldout, "Terrain Connections");
            if (terrainFoldout)
            {
                serializedObject.Update();
                DrawProperty("TopTerrain");
                DrawProperty("BottomTerrain");
                DrawProperty("LeftTerrain");
                DrawProperty("RightTerrain");

                if (GUILayout.Button("Reconnect Neighbors"))
                {
                    mySector.ConnectTerrainNeighbors();
                }
                serializedObject.ApplyModifiedProperties();
            }
        }
    }